Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 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.

share|improve this answer
    
It looks to be working. Thanks for the answer. –  Guss Apr 4 '12 at 22:19
    
Works for me too. Thanks a lot. –  Doc Feb 20 '13 at 0:11

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.

share|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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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