[lxc-users] shared mount and umount propogation.

Serge Hallyn serge.hallyn at ubuntu.com
Tue Feb 11 23:35:16 UTC 2014


Quoting Vijay Viswanathan (vijay.vishy at gmail.com):
> Thanks,
> seem to work only for sharepoint within / mounted as ext4
> doesnt seem to work if the shared folder is inside of a tmpfs ( ad hoc
> created /tmp etc., )
> 
> 
> container1.conf : added entry for /mnt  [ lxc.mount.entry = /mnt
> /container1/rootfs/mnt none rw,rbind 0 0 ]
> container2.conf : added entry for /mnt [ lxc.mount.entry = /mnt
> /container2/rootfs/mnt none rw,rbind 0 0 ]
> 
> works :
>   mkdir -p /mnt
>   chmod 777 -R /mnt
>   mkdir -p /media
>   mount --make-rbind /media /media

I'm sorry, --make-rbind doesn't exist in toolsets I'm aware of.  I'm
also confused by the ordering.  Could you please write two scripts
to set up the shared/slave mounts, verify that running one after a
reboot works and the other fails (meaning container mounts sharing
works the way you want), then attach the scripts as well as container
fstabs?

>   mount --make-rshared /media
>   mount --make-rbind /media /mnt
>   mount --make-rslave /mnt
> 
> 
> container1.conf : added entry for /mnt pointing to  /tmp/mnt  [
> lxc.mount.entry = /tmp/mnt /container1/rootfs/mnt none rw,rbind 0 0 ]
> container2.conf : added entry for /mnt pointing to  /tmp/mnt
> 
> doesnt work:
> mount -t tmpfs -o mode=01777 tmpfs /tmp
>   mkdir -p /tmp/mnt
>   chmod 777 -R /tmp/mnt
>   mkdir -p /tmp/media
>   mount --make-rbind /tmp/media /tmp/media
>   mount --make-rshared /tmp/media
>   mount --make-rbind /tmp/media /tmp/mnt
>   mount --make-rslave /tmp/mnt
> 
> container-2 still unmounts /tmp/mnt
> 
> what ever container1 mounts in /mnt is visible on container2
> 
> found a thread where entry in fstab matters?
> 
> Thanks.
> 
> 
> 
> On Tue, Feb 4, 2014 at 11:36 AM, Serge Hallyn <serge.hallyn at ubuntu.com>wrote:
> 
> > Quoting Vijay Viswanathan (vijay.vishy at gmail.com):
> > > Hi
> > > Is there an option where shared mount works and restrict propogation of
> > > unmounts ?
> > >
> > > This the sequence to reproduce the issue.
> > > 1) make /mnt share mount
> > > 2) mount a usb stick on it /dev/sdc -> /mnt/usb
> > >              [here mount shows : /dev/sdc on /mnt/usb type ... ]
> > > 3) Now start a container that has the mount entry for /mnt
> > > [e.g., lxc.mount.entry = /mnt /home/otvlxc/rootfs/mnt none rw,bind 0 0 ]
> > >
> > > what I see is :
> > > lxc-start      73733.655 DEBUG    lxc_conf - umounted
> > > '/myvm1_putold/mnt/usb'
> > > /mnt/usb is gone from the host also :(
> > >
> > >
> > > The reason I want to make /mnt shared is that to share a mount point that
> > > is mounted by one vm ( not just mounts done by host) be available on
> > > another vm any suggestions towards this is fine too.
> > >
> > > Any tips and tricks ?
> >
> > You can't separate umounts from mounts.  However you can do a step
> > better than what you have.  You want to have slave semantics from
> > the host to another directory, then share from that to all
> > containers.  That way, mounts on your host will be seen in the
> > containers, but umounts in the containers won't be seen on the
> > host.  Mounts done in one container will be seen in the others,
> > however umounts will as well.
> >
> > -serge
> > _______________________________________________
> > lxc-users mailing list
> > 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



More information about the lxc-users mailing list