I'm using mount --bind to attach a certain directory under another path (it is part of a system that holds multiple copies of mirrors where some copies are slightly different then others but I don't want some parts to be duplicated, such as ISOs).

The problem is that I would really like the bind mounts to be read-only, but when I write in /etc/fstab that these mounts have the options ro,bind and issue mount -a, I get this:

mount: warning: /some/target/path seems to be mounted read-write.

And indeed it is - it looks like the ro option is being ignored and the warning is probably because mount rechecks the mount after its done.

According to the mount man page:

Note that the filesystem mount options will remain the same as those on the original mount point, and cannot be changed by passing the -o option along with --bind/--rbind. The mount options can be changed by a separate remount command

And the solution given is to issue the mount command followed by mount -o remount,ro - which doesn't work well when using /etc/fstab for mounting. Any ideas how to work around that?

link|improve this question

feedback

2 Answers

up vote 2 down vote accepted

I found the answer which works for me on debian. It's from:

http://www.sagui.org/~gustavo/blog/fedora/read-only-bind-mount.html

/source/dir            /destination/dir    none  bind            0 0
/source/dir            /destination/dir    none  remount,bind,ro 0 0

If that doesn't work, you could do put the mount commands in rc.local. Which is ugly.

link|improve this answer
It looks to be working. Thanks for the answer. – Guss Apr 4 at 22:19
feedback

I would say it'd be easiest to get over your desire to have the mounts read-only. Based on the information provided I see no reason why they need to be so.

link|improve this answer
Granted, but I'm stubborn that way ;-) – Guss Jul 27 '11 at 11:12
Unfortunately, all that gets you is an ulcer and a hatred of your job; it doesn't get you read-only bind mounts. – womble Jul 27 '11 at 11:21
Got your point, thanks. – Guss Jul 27 '11 at 20:45
feedback

Your Answer

 
or
required, but never shown

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