[Lxc-users] minimum fstab?

Serge Hallyn serge.hallyn at canonical.com
Mon Feb 6 15:28:47 UTC 2012


Quoting Gary Ballantyne (gary.ballantyne at haulashore.com):
> Hello List
> 
> Various templates have differing fstab definitions (at least for 
> ubuntu). For example, [1] includes only /proc and /sys, [2] further adds 
> /dev/pts,

You don't need devpts in there.  Lxc sets that up itself regardless while
setting up the container.

Beside that, you do not want to try mounting devpts again.  If you
mount it without -o newinstance, the container will get the host devpts
instance.  If you do with -o newinstance, then you get a new instance
separate from the one lxc has already set up.

> and [3] further adds /var/lock and /var/run.

That's actually somewhat clever.  The container can't mount tmpfs on
/var/run, because it'll overmount the /var/run/utmp that the lxc
monitor is watching to distinguish reboot from shutdown.  But the
/var/lib/lxc/<container>/fstab is processed before the utmp watch is
set up.  So (until about now) if you wanted tmpfs on /var/run, this
was the way to do it.

Fortunately, if you run bleeding edge (-mm) kernel and (github.com/hallyn/lxc)
lxc, you no longer need utmp watching at all.  So you can let the
distro in the container mount {/var}/run however it wants.

> Could someone please explain the pros/cons of including more than /proc 
> and /sysfs? (which I assume is the bare minimum)?

It comes down to the order you need things to happen in.  For instance
you might want to arrange read-only bind mounts inside the container.  Or
perhaps bind-mount lxc-init into the container before executing it.

Finally, if you want to run a container without cap_sy_admin, then it
won't be able to mount things through its $rootfs/etc/fstab, so you
need to do it in /var/lib/lxc/container/fstab which is done before
privilege is dropped.

> Many thanks,
> 
> Gary
> 
> [1] https://github.com/hallyn/lxc/blob/master/templates/lxc-ubuntu.in
> [2] 
> http://www.activestate.com/blog/2011/10/virtualization-ec2-cloud-using-lxc
> [3] 
> https://github.com/dereks/lxc-ubuntu-x/blob/master/lxc-ubuntu-x/hooks.d/configure_fstab
> 
> ------------------------------------------------------------------------------
> Try before you buy = See our experts in action!
> The most comprehensive online learning library for Microsoft developers
> is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
> Metro Style Apps, more. Free future releases when you subscribe now!
> http://p.sf.net/sfu/learndevnow-dev2
> _______________________________________________
> Lxc-users mailing list
> Lxc-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-users




More information about the lxc-users mailing list