From 9b76b0e98b7f9e8a7ea1c2b89cf9a73b89fd6bcb Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 20 Jun 2017 12:46:02 +0200 Subject: libmount: ignore "bind" from fstab on command line "remount" The current code always apply all flags from /etc/fstab on remount. Unfortunately remount+bind has special semantic and it's impossible from command line to avoid interaction with the "bind" from fstab. Example, fstab: /dev/sda1 /bar ext4 defaults 0 1 /bar /foo none bind 0 0 Command line: # mount /foo -o remount,rw produces: mount(... MS_REMOUNT|MS_BIND ) syscall This changes the per-mountpoint (VFS) ro flag to rw, but doesn't change the filesystem itself. This patch forces libmount to ignore "bind" from fstab when "-o remount" specified on command line. If you need remount+bind semantic you have to specify the "bind" flag on command line. This allow to differentiate between # mount /foo -o remount,bind,rw --> mount(MS_REMOUNT|MS_BIND) and # mount /foo -o remount,rw --> mount(MS_REMOUNT) Suggested-by: NeilBrown Signed-off-by: Karel Zak --- sys-utils/mount.8 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'sys-utils/mount.8') diff --git a/sys-utils/mount.8 b/sys-utils/mount.8 index ac410640e..3bd278e6a 100644 --- a/sys-utils/mount.8 +++ b/sys-utils/mount.8 @@ -385,6 +385,20 @@ 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 \fB-o rbind,ro\fR). + +.BR mount (8) +since v2.31 ignores the \fBbind\fR flag from +.I /etc/fstab +on +.B remount operation +(if "-o remount" specified on command line). This is necessary to fully control +mount options on remount by command line. In the previous versions the bind +flag has been always applied and it was impossible to re-define mount options +without interaction with the bind semantic. This +.BR mount (8) +behavior does not affect situations when "remount,bind" is specified in the +.I /etc/fstab +file. .RE .SS The move operation @@ -1088,6 +1102,10 @@ Attempt to remount an already-mounted filesystem. This is commonly used to change the mount flags for a filesystem, especially to make a readonly filesystem writable. It does not change device or mount point. +The remount operation together with the +.B bind +flag has special semantic. See above, the subsection \fBBind mounts\fR. + The remount functionality follows the standard way the mount command works with options from fstab. This means that \fBmount\fR does not read fstab (or mtab) only when both -- cgit v1.2.3-55-g7522