On Thu, Nov 13, 2014 at 6:17 PM, Craig Ruff <[email protected]> wrote: > I do this by creating /etc/mtab inside the container at startup based on the > contents of the lxc.fstab file that was bind mounted inside the container. > I add lines prefixed with "#df" for other file systems bind mounted inside > the container by means external to the lxc startup mechanisms. > > This is the contents of the /etc/lxc.init file that is run at container > start. > > #!/bin/bash > > lxctab=/etc/lxc.fstab > mtab=/etc/mtab > > [ -e $tab ] || return 0; > > first=1 > cat <<EOF > $mtab > none / ext4 rw 0 0 > proc /proc proc nodev,noexec,nosuid 0 0 > devpts /dev/pts devpts defaults 0 0 > sysfs /sys sysfs defaults 0 0 > EOF > > while read src dst type opts x y; do > if [ $first = 1 ]; then > first=0 > prefix=${dst%/etc/lxc.fstab} > continue > fi > > case $src in > \#df) src=none ;; > esac > > dst=${dst#$prefix} > case $dst in > /tmp) > src=none > chmod 1777 /tmp > ;; > > /var/tmp) > src=none > ;; > esac > > echo "$src $dst $type $opts $x $y" >> $mtab > done < $lxctab > > umount $lxctab > exit 0 > > Here is a sample lxc.fstab file: > > /containers/data-access1/lxc.fstab > /containers/data-access1/rootfs/etc/lxc.fstab none bind,ro 0 0 > #/containers/data-access1/tmpfs /containers/data-access1/rootfs/tmp ext4 > defaults 0 0 > /containers/data-access1/rootfs/tmp /containers/data-access1/rootfs/var/tmp > ext4 bind 0 0 > /containers/glade /containers/data-access1/rootfs/glade none > rbind,create=dir 0 0 > /containers/data /containers/data-access1/rootfs/data none rbind,create=dir > 0 0 > /nfs/home/dasg/authdb /containers/data-access1/rootfs/nfs/home/dasg/authdb > nfs bind 0 0 > #df /glade/p gpfs bind 0 0 > #df /glade/scratch gpfs bind 0 0 > #df /glade/u gpfs bind 0 0 > #df /data/share gpfs bind 0 0 > >
Many thanks to all. I will do some test and I will see how it goes. _______________________________________________ lxc-users mailing list [email protected] http://lists.linuxcontainers.org/listinfo/lxc-users
