I've seen on various Linux systems where instead of the real device node (for example: /dev/sda1
), the root device appears as /dev/root
, or instead of the real filesystem, mtab
says it is a filesystem called rootfs
(which appears as a real filesystem in /proc/filesystems
, but doesn't have code in <linux-kernel-source-tree>/fs
). Various utilities have been made to use certain attributes to determine the real root device node (such as rdev, and the Chromium OS rootdev). I can find no logical explanation to this other than reading somewhere that very-small embedded devices don't always have to have a /dev
device node for their root device. (Is this true, and if so, is that the answer to my question?) Why does mtab sometimes say /dev/root
(and I think I might have seen it say rootdev
once) instead of the real device node, and how can I make it always say the real device node? The kernel first mounts the root device following the root
parameter in the cmdline, then init/systemd
re-mounts it according to the fstab
, correct? If so, then I presume I noticed that init
maintains mtab
. If my theory is correct, how can I make init
write the real root device node to mtab
?/etc/mtab
is actually a symbolic link to /proc/mounts
, which would mean mtab
is maintained by the kernel. So how do I configure/patch a kernel to, instead of saying the root devices node path is /dev/root
, have mtab
contain the real device node?
Linux Root Filesystem – Why Does Root Filesystem Appear as /dev/root Instead of /dev/ in mtab?
linuxroot-filesystem
Best Answer
This is generally an artifact of using an initramfs.
From the kernel documentation (https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt)
Thus
rootfs
is the root filesystem that was created for the initramfs, and can't be unmounted.In regards to
/dev/root
, I'm less certain on this, but if I recall correctly/dev/root
is created when using an initrd (not the same as an initramfs).