[lxc-users] lxc config device add

Gabriel Marais gabriel.j.marais at gmail.com
Wed Apr 19 08:22:59 UTC 2017


Thanks Spike, I did the following to create a container as per my needs:-

I used the script - 
https://gist.github.com/bloodearnest/ebf044476e70c4baee59c5000a10f4c8

Created the container - lxc launch ubuntu:14.04 vmh01-db-master-01 -p 
default -p root

Added my storage device - lxc config device add vmh01-db-master-01 
mysql_storage disk source=/mnt/db-master-01-mysql/ path=/mysql_data

---
had to change permissions and owner of the new location within the container

chown mysql:mysql /mysql_data
chmod 700 /mysql_data
---

---
Changed the datadir entry in the mysql config (my.cnf) to point to 
/mysql_data
---

---
Ran rsync -av /var/lib/mysql/ /mysql_data/
---

---
Added an entry to apparmor on the container - this was needed to ensure 
write permissions on the /mysql_data folder.

alias /var/lib/mysql/ -> /mysql_data/
---

Rebooted the container, and all was working fine...

On 2017/04/18 5:05 PM, Spike wrote:
> Hi,
>
> I've just gone through this recently to expose a data/ partition and
> found a bunch of docs with several different methodologies (and some
> scripted utils):
>
> - https://github.com/lxc/lxd/issues/2025 (explains the theory/problem)
> - https://github.com/lxc/lxd/issues/2526
> - https://gist.github.com/nottrobin/a66d3d5b9722149136d7fc6f93dae59f (Script)
> - https://github.com/antitoine/lxd-functions
> - https://gist.github.com/bloodearnest/ebf044476e70c4baee59c5000a10f4c8 (another
> script)
>
> for myself I arrived to the same conclusion as Sjoerd, the easiest thing
> was to chown the dir on the host to match the uuid on the guest. If you
> read the links above you'll understand the uuid mapping and by running
> ls on the container's data you can double-check your root's uuid on the
> guest (by default it should be 100000 on ubuntu). After a chown/chgrp
> root will have access to it on the guest and will be able to further add
> dirs for specific users. Do not that even root on the guest won't be
> able to chown the folder itself so if you want the entire partition to
> be owned by mysql you need to find mysql's uid and chown on the host to
> that.
>
> hope that helps,
>
> Spike
>
> On Tue, Apr 18, 2017 at 4:59 AM Gabriel Marais
> <gabriel.j.marais at gmail.com <mailto:gabriel.j.marais at gmail.com>> wrote:
>
>
>     >> I was trying to mount a block device where my mysql data would live.
>     >> How do I go about changing the permissions/ownership?
>     >
>     > I guess the easiest is to change the uid/guid on the host to match
>     the desired uid/gid in the container.
>
>     Is there any pointer/doc on how to do that?
>
>     >
>     > Cheers,
>     > Sjoerd
>     > _______________________________________________
>     > lxc-users mailing list
>     > lxc-users at lists.linuxcontainers.org
>     <mailto:lxc-users at lists.linuxcontainers.org>
>     > http://lists.linuxcontainers.org/listinfo/lxc-users
>     >
>
>     --
>
>
>
>
>     Regards
>
>     Gabriel Marais
>
>     Office: +27 861 466 546 x 7001 <tel:+27%2086%20146%206546>
>     Mobile: +27 83 663 2222 <tel:+27%2083%20663%202222>
>     Mail: gabriel.j.marais at gmail.com <mailto:gabriel.j.marais at gmail.com>
>
>     Unit 11, Ground Floor, Berkley Office Park
>     Cnr Bauhinia & Witch Hazel Str,
>     Highveld, Centurion, South-Africa
>     0157
>
>     PO Box 15846, Lyttelton, South Africa, 0140
>     _______________________________________________
>     lxc-users mailing list
>     lxc-users at lists.linuxcontainers.org
>     <mailto:lxc-users at lists.linuxcontainers.org>
>     http://lists.linuxcontainers.org/listinfo/lxc-users
>
>
>
> _______________________________________________
> lxc-users mailing list
> lxc-users at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-users
>

-- 




Regards

Gabriel Marais

Office: +27 861 466 546 x 7001
Mobile: +27 83 663 2222
Mail: gabriel.j.marais at gmail.com

Unit 11, Ground Floor, Berkley Office Park
Cnr Bauhinia & Witch Hazel Str,
Highveld, Centurion, South-Africa
0157

PO Box 15846, Lyttelton, South Africa, 0140


More information about the lxc-users mailing list