Linux – Doubts About the Linux Root File System

linux

In my understanding, the term 'root file system' is ambiguous, it actually refers to two different things. One is the absolute minimal file system needed to accomplish system setup together with the kernel. It contains some early user space programs which perform hardware detection, module loading, device discovery and so on. This file system is often referred to as 'rootfs'. The other is the 'real' root file system. It may locates on a local disk or on a remote server (for systems that support boot from ethernet).

I've explored several Linux Distros using 'mount' command. Some have 'rootfs on / type rootfs' in the result, while others don't. And all of them have something like '/dev/sdaX on / type extX'.

I'm wondering whether the mechanism has changed or the rootfs is just unmounted for those that don't have 'rootfs on / type rootfs'.

I've tried to seek the answer by wiki and google, but ended up more confused.

Can anybody help me?

Best Answer

The mount command takes information about current mounts from /etc/mtab.

In the past, mtab was a normal file re-created after every boot and updated by the mount command – so it wouldn't have a rootfs / entry simply because the rootfs is never explicitly mounted; it just always exists. (Such a mtab sometimes also has duplicate entries, or entries for filesystems that aren't mounted anymore...)

Many current distros now symlink mtab to /proc/self/mounts, which (like everything else in /proc) is directly generated by the kernel. Because of this, it always shows everything that is currently mounted, including both rootfs / and /dev/blah /.

You can use cat /proc/self/mounts on all distros to compare the mounts. (There also is /proc/self/mountinfo, which uses an incompatible syntax but adds more detail.)

Related Question