/etc/mtab

Lennart Poettering mzerqung at 0pointer.de
Thu Dec 23 11:12:12 UTC 2010


On Wed, 22.12.10 22:38, Bernie Innocenti (bernie at codewiz.org) wrote:

> What's preventing us from symlinking /etc/mtab to /proc/mounts and get
> rid of confusing situations when mtab gets out of sync with the
> kernel?

Some of the mount options that /bin/mount uses currently are seen by
userspace only and cannot be attached to the mount point in-kernel. The
effect of that is that if you symlink /etc/mtab to /proc/mounts these
options get silently dropped after mount, and while they might have
effect at mount time, afterwards (i.e. umount time) they will have zero
effect. An example of such an option is "user" and "users".

It is definitely planned to get rid of /etc/mtab, but before that
happens the kernel must either learn to store userspace mount options
along kernel mount options for each mount point in some way (Miklos
Szeredi has been working on this IIRC), or /bin/mount must learn to
store these options somewhere in userspace (for example /dev/.mount or
so), and then augment its output with these options. (Karel Zak has been
thinking about adding this).

Sooner or laer we will definitely make /etc/mtab a symlink, which should
take us one definite step nearer to supporting r/o root by default. 

In fact, in systemd we already warn during boot if /etc/mtab is not a
symlink, and we do not longer clear that file on bootup, all to put a
tiny bit of pressure on the folks involved to fix this properly once and
for all, in the F15 timeframe...

> I tried running my system for a few months this way. The only
> regressions I'm seeing are:
> 
> 1) the Gnome Disk Mounter panel applet seems to get confused. After a
> loopback mount gets unmounted, there's still an icon to remount the
> device. (the loopback device is correctly cleaned up at umount time).

Loop devices use userspace-only mount options too, afair.

> 2) on boot, the system tries to remount /sys even though it's already
> mounted, thus spitting this harmless error:
> 
> Remounting root filesystem in read-write mode: [  OK  ]
> mount: according to mtab, /dev/sda1 is already mounted on /
> Mounting local filesystems:  mount: sysfs already mounted or /sys busy
> mount: according to mtab, /sys is already mounted on /sys [FAILED]
> Enabling /etc/fstab swaps: [  OK  ]

This problem is gone on F15/Rawhide anyway, since systemd mounts this dir.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the devel mailing list