2

I'm trying to hide some directories on a mounted file system (it's not about security, just aesthetics). I've mounted the file system regularly on /mnt/data and wanted to use aufs to overlay a directory with the appropriate whiteouts, like so:

# ls -lA /mnt/data
total 12
drwx------ 2 root root 4096 Jul 28 18:26 dir1
drwx------ 2 root root 4096 Jul 28 18:26 dir2
drwx------ 2 root root 4096 Jul 28 18:26 dir3
# ls -lA /mnt/overlay
total 8
-r--r--r-- 2 root   root      0 Jul 28 18:27 .wh..wh.aufs
-r--r--r-- 2 root   root      0 Jul 28 18:27 .wh.dir2
drwx------ 2 root   root   4096 Jul 28 18:27 .wh..wh.orph
drwx------ 2 root   root   4096 Jul 28 18:27 .wh..wh.plnk
# mount -t aufs -o br:/mnt/overlay:/mnt/data none /mnt/test
# ls -lA /mnt/test
total 8
drwx------ 2 root root 4096 Jul 28 18:26 dir1
drwx------ 2 root root 4096 Jul 28 18:26 dir3

So far, so good. Now, any newly created files in /mnt/test should be written to the /mnt/data branch, so I tried to make the /mnt/overlay branch read-only:

# umount /mnt/test
# mount -t aufs -o br:/mnt/overlay=ro+wh:/mnt/data=rw none /mnt/test
mount: warning: /mnt/test seems to be mounted read-only.

This is where I am stuck: why is the union mounted read-only though there is a writable branch? I could only imagine that a branch cannot be rw if there is a readonly branch above it – I cannot find any clear statement on that in the aufs docs, however, the "Policies to Select One among Multiple Writable Branches" section reads:

If there is a readonly branch with ’wh’ attribute above the policy-selected branch, …

I'd interpret this so that it should be possible. So am I missing something else?

0

The first branch in the aufs br needs to be rw so that the union is writable. If you select the first branch to be ro then the union is mounted as read-only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.