[SOLVED] How does kernel know which filesystems to mount where?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
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.
How does kernel know which filesystems to mount where?
Hello,
I was wondering: where is information about mountpoints stored? i.e. how does the kernel know, for example, that "/dev/sda0p1" is mounted on "/" or that "/dev/sda0p2" is mounted on "/efi".
I'm not sure it's that simple. On one level, one of the startup scripts calls mount -a (mount all) and /etc/fstab tells the mount command which partitions are included and where they are to go. That's simple. But to access the data on the disks, the kernel has to know which partition to go to when a mountpoint appears in a path. How does it know that? afaik the kernel doesn't read data out of files like fstab.
/etc/fstab is already a filesystem path, isn't it? Maybe my reasoning is not correct here, but I assume has to know where "/etc" is mounted from somewhere else.
As I understand the boot process basically /etc is part of the root filesystem and the kernel knows where to find the root filesystem because it is passed as a kernel option. During the init process the kernel initializes all of the storage systems and mounts the root filesystem, as the init process continues the /etc/fstab is read and the rest of the filesystems are mounted.
/etc/fstab is already a filesystem path, isn't it? Maybe my reasoning is not correct here, but I assume has to know where "/etc" is mounted from somewhere else.
Some directories must be in the / partition. /etc is one of those directories.
/etc/fstab is already a filesystem path, isn't it? Maybe my reasoning is not correct here, but I assume has to know where "/etc" is mounted from somewhere else.
It was already explained, /etc should be available during that init phase, therefore it need to be located on the root filesystem.
Additionally when you boot you need to specify the location of the root filesystem and the kernel itself in the boot loader (grub, lilo, whatever), so when the kernel starts the identifier of the root filesystem is passed.
You can read about it (for example) here: https://en.wikipedia.org/wiki/Linux_startup_process (and explained much better).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.