[Toybox] Remount feature of mount

Rob Landley rob at landley.net
Tue Aug 1 01:12:58 PDT 2017


On 07/31/2017 11:30 PM, Liwei Jiang wrote:
> No. I have pulled and compiled the latest code. The same problem still
> exist. It reports, "mount: '/usr/local' not in /proc/mounts"

That's a separate error.

Could you show me your /proc/mounts file?

Remount needs to get the previous mount's flags from /proc/mounts. For
example, my root filesystem (ubuntu 14.04's defaults) has:

  $ grep sda1 /proc/mounts
  /dev/sda1 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0

Without that, remount doesn't (for example) know to set the relatime
flag on the remount, and if it doesn't that flag gets removed. A remount
has to apply your current flags as an offset to the previous flags,
meaning it needs to know the previous flags.

Way back in the dark ages mount used to maintain its own file
(/etc/mtab) with this info, but this couldn't reliably keep track of the
data: for example if you mounted or umounted anything in an overlapping
chroot, the host's /etc/mtab wouldn't get the updates. If a program ever
mounted anything with the system call instead of the mount command,
/etc/mtab wouldn't be updated. When the 'shared subtree' stuff went into
2.6.15 mounts became a per-process attribute and a single systemwide
/etc/mtab made no _sense_ anymore. And then we built containers on top
of that combining the "in a chroot" with "per-process-attribute" and
everybody finally gave up on /etc/mtab. (I was arguing they _should_ do
so back in 2005, but nobody listened back then...)

Since the kernel knows this information, the kernel exports it in
mtab/fstab format, so people could symlink /etc/mtab to that and always
get the right information. Newer mount commands just look for it
straight out of proc without needing the symlink.

Rob


More information about the Toybox mailing list