LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 09-02-2022, 05:58 AM   #1
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Rep: Reputation: 13
how come /etc/fstab can be read before / is mounted?


This might be a stupid question, but I think I have missed some information somewhere.

In /etc/fstab are the partitions to be mounted
/ is one of those partitions
/etc/fstab is a subfolder of /

How can /etc/fstab be read, to know that / has to be mounted before it is mounted?
 
Old 09-02-2022, 06:13 AM   #2
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,501

Rep: Reputation: Disabled
When you start up, you load a ram based system (initrd) first, before transferring to the disk based system.

initrd = initial ramdisk

Last edited by fatmac; 09-02-2022 at 06:14 AM.
 
1 members found this post helpful.
Old 09-02-2022, 06:20 AM   #3
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Original Poster
Rep: Reputation: 13
Then I have to read up on that.
Thanks.
 
Old 09-02-2022, 06:29 AM   #4
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,604
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
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?
 
Old 09-02-2022, 06:32 AM   #5
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Original Poster
Rep: Reputation: 13
Good question. I assume that you can unmount / for whatever reason and then mount it again with mount -a
 
Old 09-02-2022, 06:36 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,137

Rep: Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122Reputation: 4122
No, you can't umount the root. But you can remount it rw in need - which needs an entry in fstab IIRC.
 
2 members found this post helpful.
Old 09-02-2022, 06:41 AM   #7
KatrinAlec
Member
 
Registered: Feb 2012
Posts: 116

Original Poster
Rep: Reputation: 13
I never thought remount was different from "unmount then mount", but I guess in case of / it makes a big difference.

Also explains how /bin/mount doesn't need to be used, once / would have been dismounted... it all makes sense.
 
Old 09-02-2022, 06:48 AM   #8
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,604
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
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.
 
Old 09-02-2022, 04:10 PM   #9
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,670
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
And, actually, it is possible to avoid the "initrd" step entirely.
 
Old 09-02-2022, 05:57 PM   #10
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by hazel View Post
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.
 
Old 09-03-2022, 07:50 AM   #11
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,604
Blog Entries: 19

Rep: Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458Reputation: 4458
Quote:
Originally Posted by computersavvy View Post
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.
 
Old 09-03-2022, 12:33 PM   #12
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by hazel View Post
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.
 
Old 09-04-2022, 05:03 AM   #13
fatmac
LQ Guru
 
Registered: Sep 2011
Location: Upper Hale, Surrey/Hants Border, UK
Distribution: Mainly Devuan, antiX, & Void, with Tiny Core, Fatdog, & BSD thrown in.
Posts: 5,501

Rep: Reputation: Disabled
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.
 
Old 09-04-2022, 06:06 AM   #14
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: SE USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,827
Blog Entries: 1

Rep: Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069Reputation: 2069
Quote:
Originally Posted by hazel View Post
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.

Last edited by mrmazda; 09-04-2022 at 06:12 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
udev rules running before fstab partitions mounted genogebot Linux - General 6 05-23-2016 12:13 PM
\vi/etc/fstab works fine . vi /etc/fstab throws bash command not found in Rescue mode jsaravana87 Linux - Server 1 05-13-2013 02:08 PM
server startup error: "cannot find / in /etc/fstab or /etc/mtab"; /etc/fstab readonly knee-co Linux - Newbie 8 09-12-2010 05:37 PM
fstab problem: mount: can't find dvd in /etc/fstab or /etc/mtab Nikon01 Slackware 5 11-17-2006 06:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:55 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration