[SOLVED] how come /etc/fstab can be read before / is mounted?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
But what is the function of the root partition line in fstab given that the system already knows where its root is? Is that line just for the benefit of the sysadmin or does it actually do something?
Now I get it. Root is usually mounted read only to start with in case it needs to be fscked. Then it gets remounted read-write. Having it listed in fstab makes that sequence unproblematic.
But what is the function of the root partition line in fstab given that the system already knows where its root is? Is that line just for the benefit of the sysadmin or does it actually do something?
The initrd (or initfs) file is a ramdisk image of the actual root file system. It needs all the parts (including everything in /etc) to be there when the initrd file is created so that the initial load of the file system from ramdisk has everything that is needed to load the kernel and start the system up properly. Once the kernel is loaded and the system is running then the actual root file system is now mounted over the ramdisk image and that memory is freed up for other use. The system only knows where the actual root file system is by reading the content of /etc/fstab in the initrd image file.
There are 4 basic files that are needed to handle booting on my system (and all exist in the /boot directory).
config, initrd (initramfs on fedora), vmlinuz (the actual kernel), and System.map. All are needed for each kernel version installed and bootable.
The system only knows where the actual root file system is by reading the content of /etc/fstab in the initrd image file.
That's not the case on my system. I use elilo and it passes a kernel command line of the form "append="root=/dev/sda7 vga=normal ro". Lilo used to do the same. I don't know much about GRUB.
That's not the case on my system. I use elilo and it passes a kernel command line of the form "append="root=/dev/sda7 vga=normal ro". Lilo used to do the same. I don't know much about GRUB.
I said that wrong. The system needs certain files and the actual file system structure that is contained in the initrd once the kernel is loaded. The kernel itself has to have that structure available before it can actually finish setting up the system then mount the drives, which happens quite a ways into the boot process.
My system uses systemd and journalctl for logging and I see more than 700 lines in the logs before it even sees and starts to configure the sata devices, then another 150 lines in the log before it configures the boot drive.
This means the initrd image has been in use for some time before the system is able to use the main root file system.
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,501
Rep:
I believe that the initrd system looks for & reads the /etc/fstab to find the location of the system to be transferred into by 'switchroot' or some other mechanism.
But what is the function of the root partition line in fstab given that the system already knows where its root is? Is that line just for the benefit of the sysadmin or does it actually do something?
root= in bootloader is optional in most installations. root= is normally included in initrd, making the one in bootloader superfluous, unless the location in the initrd isn't valid for the current boot, such as a clone migration where the clone / filesystem has different UUID, LABEL and/or device name. root= in bootloader is also required when there is no initrd.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.