LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 04-10-2022, 10:19 AM   #1
movrax
LQ Newbie
 
Registered: Apr 2022
Distribution: Arch
Posts: 2

Rep: Reputation: 0
Talking 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".

Thanks
 
Old 04-10-2022, 10:23 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,910

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
for example: /etc/fstab
 
Old 04-10-2022, 11:03 AM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,601
Blog Entries: 19

Rep: Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456Reputation: 4456
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.
 
Old 04-10-2022, 11:04 AM   #4
movrax
LQ Newbie
 
Registered: Apr 2022
Distribution: Arch
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
for example: /etc/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.
 
Old 04-10-2022, 11:36 AM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,734

Rep: Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920Reputation: 5920
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.
 
2 members found this post helpful.
Old 04-10-2022, 02:58 PM   #7
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 12
Posts: 8,340

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by movrax View Post
/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.
 
Old 04-10-2022, 11:43 PM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,910

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
Quote:
Originally Posted by movrax View Post
/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).
 
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
LXer: Everything You want to know about hard drives and filesystems LXer Syndicated Linux News 0 03-30-2015 02:11 PM
[SOLVED] Filesystems supported by the kernel (/proc/filesystems) gacanepa Linux - Newbie 5 08-22-2013 02:15 PM
The more I know the less I know I know sjb LinuxQuestions.org Member Intro 1 02-11-2008 12:50 PM
how to determine which filesystems are supported by the running kernel? acpi Linux - General 3 04-04-2005 02:38 AM
windows filesystems vs. linux filesystems irfanhab General 8 05-25-2004 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:33 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