From: NeilBrown <neilb@suse.com>
To: util-linux@vger.kernel.org
Subject: "mount -o remount,rw" sometimes doesn't work as expected.
Date: Fri, 19 May 2017 17:14:24 +1000 [thread overview]
Message-ID: <87wp9djp2n.fsf@notabene.neil.brown.name> (raw)
[-- Attachment #1: Type: text/plain, Size: 1926 bytes --]
Suppose /foo and /bar are bind mounts to the same
filesystem which is currently mounted read-only,
and suppose the /etc/fstab contains
/dev/sda1 /bar ext4 defaults 0 1
/bar /foo none bind 0 0
Now if I want /foo to be writeable I might try:
mount /foo -o remount,rw
and would then be surprised that this doesn't work.
What is happening is that because only one path has been given, mount
needs to find the other and goes looking in /etc/fstab.
If finds an appropriate line and parses out the options.
Then the mount system call used is
mount( "/bar", "/foo", ..., MS_REMOUNT | MS_BIND ,....)
This changes the per-mountpoint ro flag to rw, but doesn't change the
filesystem itself. This can be seen in /proc/self/mountinfo. There
are two r[wo] flags, and they are different.
Had I run:
mount /foo -o remount,bind,rw
I would have expected this. But as I didn't explicitly ask for "bind",
it is confusing.
I think it might be good to ignore "bind" in /etc/fstab when "remount"
is used.
However.... when "remount" is used, the "device" is ignored, so there
isn't a lot of point hunting through /etc/fstab to find it.
If mount is given just one path and the "remount" option, then maybe
it shouldn't try to find an /etc/fstab entry at all?
I guess you might want to remount a device??
Is
mount -o remount,rw /dev/sda1
allowed? In that case, don't look through /etc/fstab if the path
is a directory.
I haven't provided a patch because I'm not 100% sure what the best
approach would be.
Does anyone have opinions on what mount should or shouldn't do when
remounting and only one path is given?
You could possibly argue that the current behaviour is correct
as /foo is listed as bind mount. That doesn't stop is being surprising.
Also
mount /bar /foo -o remount,rw
doesn't pick up the "bind" flag, so the filesystem gets remounted.
So I think there is definitely something wrong.
Thanks,
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
next reply other threads:[~2017-05-19 7:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-19 7:14 NeilBrown [this message]
2017-05-19 9:11 ` "mount -o remount,rw" sometimes doesn't work as expected Karel Zak
2017-05-21 22:16 ` NeilBrown
2017-05-22 11:26 ` Karel Zak
2017-05-31 3:05 ` NeilBrown
2017-05-31 9:18 ` Karel Zak
2017-05-31 22:55 ` NeilBrown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wp9djp2n.fsf@notabene.neil.brown.name \
--to=neilb@suse.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox