Havee
2017-06-06 15:48:40 +08:00
man mount
...
mount(8) since v2.27 allows to change the mount options by passing the relevant options along with --bind.
For example:
mount --bind,ro foo foo
This feature is not supported by the Linux kernel; it is implemented in userspace by an additional mount(2)
remounting system call. This solution is not atomic.
The alternative (classic) way to create a read-only bind mount is to use the remount operation, for example:
mount --bind olddir newdir
mount -o remount,bind,ro olddir newdir
Note that a read-only bind will create a read-only mountpoint (VFS entry), but the original filesystem
superblock will still be writable, meaning that the olddir will be writable, but the newdir will be read-only.
It's also possible to change nosuid, nodev, noexec, noatime, nodiratime and relatime VFS entry flags by
"remount,bind" operation. It's impossible to change mount options recursively (for example with -o rbind,ro).