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?

ArjunShankar
  • 23,020
  • 5
  • 61
  • 83
HARISH B
  • 85
  • 2
  • 4

1 Answers1

8

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

nos
  • 223,662
  • 58
  • 417
  • 506
  • 1
    Since it in /proc directory, looks like it is not persistent in disk. So how it get stored when power is off? – Jcyrss May 09 '19 at 13:35
  • 1
    They're stored in /etc/fstab – nos May 09 '19 at 16:34
  • Is /etc/fstab stored in a filesystem of partition? If yes, how does kenel find /etc/fstab during booting when no file system mounted? – Jcyrss May 10 '19 at 02:29
  • 1
    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. – nos May 10 '19 at 12:49
  • So kernel boot configuation is stored in a specifial place like MBR or something, instead of file system? – Jcyrss May 13 '19 at 03:39
  • 1
    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. – nos May 13 '19 at 12:29