[Unionfs] Can't make branch read only

Erez Zadok ezk at cs.sunysb.edu
Tue Oct 23 13:19:34 EDT 2007


In message <200710231056.23952.herton at mandriva.com.br>, Herton Ronaldo Krzesinski writes:
> Hi,
> 
> Just following documentation at Documentation/filesystems/unionfs/usage.txt,
> it says:
> 
> "Finally, to change the mode of one existing branch, say /foo, from read-only
> to read-write, and change /bar from read-write to read-only:
> 
> # mount -t unionfs -o remount,mode=/foo=rw,mode=/bar=ro none MOUNTPOINT"
> 
> Here I tried the same on a branch to change it to read only mode, but isn't
> working (branch continues to be read/write, writes still appears on it), the
> testcase is similar to the other bug I posted previously:
> 
> - mkdir -p /live/distrib
> - if wished install some files at /lib/distrib
> - mkdir /live/memory
> - mount -t tmpfs none /live/memory
> - mkdir /live/union
> - mount -o dirs=/live/memory=rw:/live/distrib=ro -t unionfs unionfs /live/union
> - mkdir /live/foo
> - mount -t unionfs -o remount,add=/live/foo=rw none /live/union
> - do some writes/changes at /live/union (probably optional)
> - mount -t unionfs -o remount,mode=/live/foo=ro none /live/union
> 
> The last command, while should switch the branch to read only mode as the
> documentation specifies, doesn't work, the branch /live/foo continues to be
> read-write, and if you write something to /live/union you confirm this as there
> will be still writes to /live/foo (and /proc/mounts continues to show /live/foo as
> rw too). Any ideas?
> 
> I tried this with unionfs 2.1.3 and also with 2.1.7 but with same results.

Herton, you cannot set the leftmost branch to be readonly, in a union
mounted read-write.  If the union is mounted read-write, then the leftmost
branch must be writeable, to allow copyup.  If you want to set the leftmost
branch to readonly, it is the same as saying that you want the whole union
to be readonly.  In that case, remount your entire filesystem readonly:

# mount -t unionfs -o remount,ro none /live/union

Check your kernel console messages (e.g., run dmesg).  You'll should have
seen this message:

	printk(KERN_ERR "unionfs: leftmost branch cannot be read-only "
		"(use \"remount,ro\" to create a read-only union)\n");

I will document this better in usage.txt.

Cheers,
Erez.


More information about the unionfs mailing list