<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">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.<br><br>This is the contents of the /etc/lxc.init file that is run at container start.<br><br>#!/bin/bash<br><br>lxctab=/etc/lxc.fstab<br>mtab=/etc/mtab<br><br>[ -e $tab ] || return 0;<br><br>first=1<br>cat <<EOF > $mtab<br>none / ext4 rw 0 0<br>proc /proc proc nodev,noexec,nosuid 0 0<br>devpts /dev/pts devpts defaults 0 0<br>sysfs /sys sysfs defaults 0 0<br>EOF<br><br>while read src dst type opts x y; do<br> if [ $first = 1 ]; then<br> first=0<br> prefix=${dst%/etc/lxc.fstab}<br> continue<br> fi<br><br> case $src in<br> \#df) src=none ;;<br> esac<br><br> dst=${dst#$prefix}<br> case $dst in<br> /tmp)<br> src=none<br> chmod 1777 /tmp<br> ;;<br><br> /var/tmp)<br> src=none<br> ;;<br> esac<br><br> echo "$src $dst $type $opts $x $y" >> $mtab<br>done < $lxctab<br><br>umount $lxctab<br>exit 0<br><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Here is a sample lxc.fstab file:<br><br>/containers/data-access1/lxc.fstab /containers/data-access1/rootfs/etc/lxc.fstab none bind,ro 0 0<br>#/containers/data-access1/tmpfs /containers/data-access1/rootfs/tmp ext4 defaults 0 0<br>/containers/data-access1/rootfs/tmp /containers/data-access1/rootfs/var/tmp ext4 bind 0 0<br>/containers/glade /containers/data-access1/rootfs/glade none rbind,create=dir 0 0<br>/containers/data /containers/data-access1/rootfs/data none rbind,create=dir 0 0<br>/nfs/home/dasg/authdb /containers/data-access1/rootfs/nfs/home/dasg/authdb nfs bind 0 0<br>#df /glade/p gpfs bind 0 0<br>#df /glade/scratch gpfs bind 0 0<br>#df /glade/u gpfs bind 0 0<br>#df /data/share gpfs bind 0 0<br><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">Craig Ruff<br>NCAR/CISL<br></div></div></div>
<br></div></div>