1

mount -r --bind /media/NTFSPartition/ftp/public /media/NTFSPartition/ftp/users/user1/public

This gives me warning

mount: warning: /media/NTFSPartition/ftp/users/user1/public seems to be mounted read-write.

and of course mounting in rw mode :( What I need is to make it read only mount.

1
  • Interesting. I don't get that warning here (Fedora 12). But it also doesn't seem to make it R/O, despite what mount says :> Sep 6, 2010 at 2:51

2 Answers 2

1

Probably it needs to be done in two commands:

mount --bind /media/NTFSPartition/ftp/public /media/NTFSPartition/ftp/users/user1/public
mount -o remount,ro /media/NTFSPartition/ftp/users/user1/public

Other ways to do it:

  1. Use aufs/unionfs.
  2. Mount using FUSE (like fusexmp)
5
  • Would aufs/unionfs work in case of partition formatted as NTFS and initially mounted as ntfs-3g?
    – Pablo
    Sep 6, 2010 at 4:51
  • Yes, it should (at least aufs has compile-time configuration option "Allow FUSE as a branch").
    – Vi.
    Sep 6, 2010 at 9:48
  • Do that two commands fail for you?
    – Vi.
    Sep 6, 2010 at 9:49
  • Even if you try to delete files in the mounted folder as root?
    – user39559
    Sep 7, 2010 at 12:34
  • @user39559, Yes, it won't delete (if remounting to read-only has worked). It will say "Read-only filesystem". It is like you can't delete a file on mounted DVD even as root.
    – Vi.
    Sep 7, 2010 at 23:54
5

For a long time after bind mounts were introduced, the kernel associated mount options with devices rather than mount points, end of story. When you ran mount --bind, the kernel silently ignored all options since they couldn't be applied just to the bind mount.

Starting with kernel 2.6.26 (or earlier for distributions that patched the upstream kernel), bind mounts have a read-only status that is separate from the original mount. So read-only bind mounts do work. However, the support is not perfect, for example the kernel still ignores options passed to mount --bind. You can make a read-only bind mount by making a bind mount and mounting it read-only. This introduces a security problem in some scenarios (there is a small window of time during which the bind mount is writable).

Debian lenny has a patched 2.6.26 kernel that makes mount --bind -r create a read-only bind mount atomically. Ubuntu 10.04 doesn't include that patch.

The fuse filesystem bindfs generalizes the effect of mount --bind. It supports read-only bind mounts and many other permission and ownership changes. It is not fully equivalent to mount --bind, however. For example, reading from a read-only bind mount never updates the access time of a file, but might for a bindfs -p a-w fuse mount.

1
  • thanks for being so descriptive, it's good to know all that!
    – Pablo
    Sep 6, 2010 at 23:34

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.