2

I updated an old linux boot disk with new utilities and shared libraries. It still had an empty /etc/mtab to start with, on the old disk the /etc/mtab was updated, on the new one /etc/mtab stayed zero. I see now we link /etc/mtab to /proc/mounts but question remains:

  1. What was updating /etc/mtab to keep it up to date?

  2. When did it change from /etc/mtab to /proc/mounts

  3. How do we keep up on all the fundamental changes that occur in linux?

Thanks.

user3161924
  • 261
  • 1
  • 8

1 Answers1

3

On systems where /etc/mtab is a regular file, updating /etc/mtab is the job of the mount and umount commands. In addition, boot scripts update /etc/mtab once the root filesystem is mounted read-write, either by extracting information from /proc/mounts or by writing what the boot scripts know about what they've already mounted.

For a long time, there was a debate about whether /etc/mtab should be a regular file or a symlink to /proc/mounts. Making it a regular file has the downside that it could get out of sync with the system state (for example if the root filesystem was read-only during a mount or unmount operation). It also doesn't accommodate modern features such as mount namespaces, where processes might not see the same mount points even if they see the same /etc/mtab. But making it a symlink to /proc/mounts had the downside that the kernel used to not report all the information one would like to have:

  • The kernel used to hide default mount options, but the defaults depended on the kernel version, so it was hard to figure out the exact mount options from /proc/mounts, whereas /etc/mtab gave you exactly what was passed to the mount command.
  • The kernel used to report bind mounts as copies of the original mount, and not as bind mounts.

Modern kernels report more information through /etc/mounts so there is no longer a reason to prefer making /etc/mtab a regular file.

Debian bug #494001 is when Debian stopped maintaining /etc/mtab as a regular file. Highlights from that thread (I haven't verified the accuracy, but I have no reason to doubt):

  • The relevant part of the thread is mostly the initial message. The rest is mostly about concerns related to the transition.
  • “With linux >= 2.6.26, /proc/mounts contains all of the information in /etc/mtab, plus more”.
  • The attached patch contains the last version of the code to update /etc/mtab (/etc/init.d/mtab.sh).

How do we keep up on all the fundamental changes that occur in linux?

Good luck with that… Everybody has a different set of changes they consider fundamental. All of it must have appeared on LWN (Linux Weekly News), but that's very high-traffic and includes discussions of proposed upcoming changes.