[lxc-devel] [PATCH 1/4] Automatic mounts: improvements for /proc and /sys

Serge Hallyn serge.hallyn at ubuntu.com
Thu Sep 26 19:22:15 UTC 2013


Quoting Christian Seiler (christian at iwakd.de):
...
> +		/* Read-only bind-mounting... In older kernels, doing that required
> +		 * to do one MS_BIND mount and then MS_REMOUNT|MS_RDONLY the same
> +		 * one. According to mount(2) manpage, MS_BIND honors MS_RDONLY from
> +		 * kernel 2.6.26 onwards. However, this apparently does not work on
> +		 * kernel 3.8.

I'm still not sure what is going on for you with this.  Running with the
latest 3.11 userns-enabled kernel (at ppa:ubuntu-lxc/kernel), I can
still do

	sudo mkdir /tmp/{a,b}
	sudo mount -t tmpfs tmpfs /tmp/a
	sudo mount --bind /tmp/a /tmp/b
	sudo mount -o remount,bind,ro /tmp/b

and end up with /tmp/b roand /tmp/a rw.  This works for me in 3.2, 3.8,
and userns-enabled 3.11.

> Unfortunately, on that very same kernel, doing the
> +		 * same trick as above doesn't seem to work either, there one needs
> +		 * to ALSO specify MS_BIND for the remount, otherwise the entire
> +		 * fs is remounted read-only or the mount fails because it's busy...

That's actually understandable - there are two things which both have
a readonly.vs.readwrite state - the vfsmount, and the superblock.  If
you don't add MS_BIND, then you are requesting remount of the
superblock.

-serge




More information about the lxc-devel mailing list