root@tefnet:/tmp/bindtest# mkdir -p 1/11 2 3 When I mount -o bind,ro a directory: root@tefnet:/tmp/bindtest# mount 1 2 -o bind,ro root@tefnet:/tmp/bindtest# touch 2/foo touch: cannot touch `2/foo': Read-only file system and then mount part of it with -o bind: root@tefnet:/tmp/bindtest# mount 2/11 3 -o bind root@tefnet:/tmp/bindtest# touch 3/foo root@tefnet:/tmp/bindtest# the mounted part is read-write despite no specification of ro/rw option on the mount command line. I expected the "3" directory to be read-only as well.
This issue seems to be solved in the latest kernel. Remember 2.6 onwards kernel doesnt support to bind mount a rw file system to ro, the first step itself doesnt work in my kernel. root@host:/# mount 1 2 -o bind,ro mount: warning: 2 seems to be mounted read-write. http://lwn.net/Articles/281157/ Besides that the filesystem subdirectories tend to retain their properties... In your case /2 is ro, But /2/11 is rw having inherited from 1/11 So 2/11 which is rw when bind mounted to /3 retains the rw... Can this issue be closed...?
Thanks for the update, it seems more reasonable now: root@klocek:/tmp/bindtest# mkdir -p 1/11 2 3 root@klocek:/tmp/bindtest# mount 1 2 -o bind,ro mount: warning: 2 seems to be mounted read-write. root@klocek:/tmp/bindtest# mount 2 -o remount,ro root@klocek:/tmp/bindtest# touch 2/foo touch: cannot touch `2/foo': Read-only file system root@klocek:/tmp/bindtest# mount 2/11 3 -o bind,rw mount: warning: 3 seems to be mounted read-only. root@klocek:/tmp/bindtest# touch 3/foo touch: cannot touch `3/foo': Read-only file system root@klocek:/tmp/bindtest# The original problem I had with that (unexpected write possibilities) does not seem to occur anymore, so I think that the issue can be closed :).
Can somebody close this..?