Where are all mount points stored in Linux
Asked Answered
A

1

5

I want to know where all mount points are stored; i.e. under any specific directory?

I want to be able to list all the existing mount points using a C Program. Which system call or function should I use?

Axolotl answered 2/5, 2012 at 10:43 Comment(2)
#5071301 helpful?Fillister
/etc/mtab holds the table with mounted filesystems.Rinse
R
8

They are located in the /proc/mounts "file", which you can read and parse.

Renee answered 2/5, 2012 at 10:45 Comment(6)
Since it in /proc directory, looks like it is not persistent in disk. So how it get stored when power is off?Rafi
They're stored in /etc/fstabRenee
Is /etc/fstab stored in a filesystem of partition? If yes, how does kenel find /etc/fstab during booting when no file system mounted?Rafi
Yes it is. The kernel boot configuration stores which filesystem is to be mounted at / , When the / filesystem (that has to include atleast the basic /bin/ /etc /lib/ /sbin/ and similar) is mounted , /etc/fstab can be read to mount other filesystems.Renee
So kernel boot configuation is stored in a specifial place like MBR or something, instead of file system?Rafi
Almost. The MBR configuration does not have a lot of space, it just stores which disk/partition the actual configuration is stored on, so the next stage of the boot loader can read that configuration.(usually stuff in the /boot/ filesystem - which a boot loader can read before the kernel is even loaded.Renee

© 2022 - 2024 — McMap. All rights reserved.