[Lxc-users] how to mount inside of running container
Serge Hallyn
serge.hallyn at canonical.com
Thu Sep 22 15:10:09 UTC 2011
Quoting Arie Skliarouk (skliarie at gmail.com):
> I managed to mount the partition! For that the procedure looks as follows:
Excellent.
> 1. On the master:
>
>
> mkdir /share/containerX
> mkdir /var/lib/lxc/containerX/rootfs/share
> mount -t tmpfs share /share/containerX
> mount --make-rshared /share/containerX
Note you shouldn't need the tmpfs - you just need to bind mount it onto
itself because you need a vfsmount object to exist before you can tweak
its mount propagation.
BTW, since you asked earlier about the order of make-rslave etc, check
out the table at bottom of
http://kernel.ubuntu.com/git?p=ubuntu/ubuntu-oneiric.git;a=blob;f=Documentation/filesystems/sharedsubtree.txt;h=4ede421c9687a71d33027b95118c90dc743da0fe;hb=HEAD
which shows you what each action actually does based on current state.
So for instance if you do make-rslave on an unbindable node, you're
not really turning it into a slave (bc there is nothing for it to be
a slave of).
> cat >> /var/lib/lxc/containerX/fstab << EOF
> /share/containerX /var/lib/lxc/containerX/rootfs/share none bind 0 0
> EOF
>
> 2. On the container: modify the /etc/rc.local to remount the /share
> directory with slave option enabled:
> mount --make-slave /zfs
Did you mean 'mount --make-slave /share' ?
I tried for about a minute to get this done with /var/lib/lxc/containerX/fstab,
i.e.
cat >> /var/lib/lxc/containerX/fstab << EOF
/share/containerX /var/lib/lxc/containerX/rootfs/share none bind 0 0
none /var/lib/lxc/containerX/rootfs/share none make-rslave 0 0
EOF
but make-rslave doesn't seem to be valid for fstab. I can dig around the
source later, but does anyone know offhand of a way to do make-rslave
through fstab?
> The only problem remains is that the partitions mounted under /share are
> unmounted the moment the container is shut down. Is there a "clean" way to
> avoid that?
Hm, turning it into a slave should prevent that.
-serge
More information about the lxc-users
mailing list