NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: understanding mount_union



On Tue, May 13, 2014 at 11:28:11PM -0400, Eric Haszlakiewicz wrote:
> On May 13, 2014 6:59:56 PM EDT, Patrick Welche <prlw1%cam.ac.uk@localhost> 
> wrote:
> >I thought that one use of mount_union was to be able to layer
> >read/write
> >filesystem over a read/only filesystem, such that writing would
> >create a file in the upper filesystem, and reading would read an
> >unchanged
> >file from the lower one. Is this correct?
> 
> Yep.
> 
> >A quick experiment on -current/amd64:
> >
> ># mkdir /var/upper
> ># mkdir /var/lower
> ># touch /var/lower/file
> ># mount_union /var/upper /var/lower
> ># mount
> >...
> ><above>:/var/upper on /var/lower type union (local)
> ># ls /var/upper
> ># ls /var/lower
> >file
> >
> >I would have expected to see file in /var/upper
> 
> I would expect that too, and in fact that's what I see on my system (NetBSD 
> 6.1.3).
> 
> Is there still no file in /var/upper after unmounting the union mount?
> Maybe something is getting cached, or it's broken in -current?
> 
> ># touch /var/upper/another
> ># ls /var/upper
> >another
> ># ls /var/lower
> >another file
> >
> >I would not have expected to see another in /var/lower
> 
> Of course you would, since the kernel is causing anything in /var/upper to 
> appear at the /var/lower mount point.
> However, I think it might be "not recommended" to go mucking around in 
> /var/upper while it's in use as part of a union mount.
> On the other hand, if it's present in /var/lower after unmounting, then 
> something is very wrong.

Thanks to hints from Malcolm Herbert, it seems that rather than
  <above>:/var/upper on /var/lower type union (local)
I need: mount_union -b /var/lower /var/upper
  <below>:/var/lower on /var/upper type union

Then I see:

# ls /var/lower
file
# ls /var/upper
file
# touch /var/upper/another
# ls /var/lower
file
# ls /var/upper
another file

I can't say that I understand why the two cases are different.
"However, uniondir remains the mount point." in the -b option
explanation seems rather important.

Cheers,

Patrick


Home | Main Index | Thread Index | Old Index