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?
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
If that doesn't work, you could do put the mount commands in rc.local. Which is ugly.
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.
by i test this is not use on ubuntu 14.04 X 64 OS