- How to get the complete and exact list of mounted filesystems in Linux?
- 5 Answers 5
- What is a Mount Point in Linux
- What is a Mount Point in Linux
- Practical Example: Mounting an External Device
- How Do I See all Used Mount Points in Linux?
- Conclusion
- About the author
- David Adams
- 3 ways to list mount points in Linux
- what is mount point in Linux
- List mount points with df command in Linux
- List mount points with mount command in Linux
- List mount points with cat /proc/mounts command in Linux
How to get the complete and exact list of mounted filesystems in Linux?
I usually use mount to check which filesystems are mounted. I also know there is some connection between mount and /etc/mtab but I’m not sure about the details. After reading How to check if /proc/ is mounted I get more confused. My question is: How to get the most precise list of mounted filesystems? Should I just use mount , or read the contents of /etc/mtab , or contents of /proc/mounts ? What would give the most trustworthy result?
I can’t help linking to What is /etc/mtab in Linux? because it covers non-Linux details that none of the answers here give.
5 Answers 5
The definitive list of mounted filesystems is in /proc/mounts .
If you have any form of containers on your system, /proc/mounts only lists the filesystems that are in your present container. For example, in a chroot, /proc/mounts lists only the filesystems whose mount point is within the chroot. (There are ways to escape the chroot, mind.)
There’s also a list of mounted filesystems in /etc/mtab . This list is maintained by the mount and umount commands. That means that if you don’t use these commands (which is pretty rare), your action (mount or unmount) won’t be recorded. In practice, it’s mostly in a chroot that you’ll find /etc/mtab files that differ wildly from the state of the system. Also, mounts performed in the chroot will be reflected in the chroot’s /etc/mtab but not in the main /etc/mtab . Actions performed while /etc/mtab is on a read-only filesystem are also not recorded there.
The reason why you’d sometimes want to consult /etc/mtab in preference to or in addition to /proc/mounts is that because it has access to the mount command line, it’s sometimes able to present information in a way that’s easier to understand; for example you see mount options as requested (whereas /proc/mounts lists the mount and kernel defaults as well), and bind mounts appear as such in /etc/mtab .
What is a Mount Point in Linux
After reading this tutorial, you will understand what a mount point is and how to use it to read files from unmounted storage devices or partitions. Additionally, in this document, you will find practical commands related to mounting tasks.
What is a Mount Point in Linux
A mount point is a directory where an external partition, storage device, or file system can become accessible to the user or application requiring it (e.g., when a Linux installation process requires access to the USB device containing the ISO image or installation files).
Mounting means attaching a partition, hard disk, or file system to the system in use. Similarly, when we insert a CD in Windows operating systems, the default mount point would be D:/ or Cdrom, the “directory” where files become accessible to the user. Of course, this is different than in Linux because in Linux mount points are regular directories, like any other directory.
Usually, the mount point is a dedicated directory for mounting purposes, but users can use any directory as a mount point, including directories containing files and subdirectories. But it is important to remember that only mounted files will be accessible. Original files will only become accessible again after the user unmounts the mounted filesystem.
Normally, the default mount points in Linux are /media, /mnt, /usb and /media/mnt, but users can mount devices in any directory.
Practical Example: Mounting an External Device
To understand what a mounting point is, the best explanation is a practical example.
Let’s suppose my computer has only one hard drive, in this case, an SSD hard disk.
The first hard disk, if SSD, by default will be named as /dev/sda, if the hard disk has two partitions, the first will be /dev/sda1, and the second partition will be /dev/sda2. If there is another partition, it will be /dev/sda3, etc.
If I attach a second storage hardware device, it will be named as /dev/sdb. The first partition will be /dev/sdb1, the second /dev/sdb2, etc.
As said previously, let’s assume I have only one hard drive device, /dev/sda. I want to attach an external hard drive, which will be named as /dev/sdb.
If the automatic mounting function is disabled, when I plug in the second hard disk, it won’t be accessible. The operating system will detect a new device that has been plugged in but won’t be able to read its content.
To allow the operating system to read the content, I need to mount the specific partition of the second device (/dev/sdb1 in this case) in a directory where files will become accessible.
It is important to remember that to mount a device, you don’t need to specify the device but also the partition you want to access. In other words, instead of /dev/sdb, you mount /dev/sdb1 or /dev/sdb2, etc.
The command to mount devices or filesystems is the mount command. Followed by the device and partition I want to mount or attach (/dev/sdb1) and the mount point (the directory in which I will be able to browse and read the disk content, in this case, /media/linuxhint/).
In this case, the command I need to execute is the one shown below. And once executed, the disk will become accessible through the mount point, in the directory /media/linuxhint.\
As you can see in the following screenshot, after mounting it, a ls command shows me the disk content: The file firewall.nft and the directories lost+found and python3.
To unmount the storage device, the command is umount followed by the device and partition to unmount, as shown below.
This time, as you can see with a new ls execution, after unmounting the device, the mount point is empty (it was empty) and the external drive is inaccessible.
In the previous example, the mount point was /media/linuxhint.
How Do I See all Used Mount Points in Linux?
To list all mount points, you can execute the command findmnt. The findmnt command fetches the information by reading the files /etc/fstab, /etc/fstab.d, /etc/mtab or /proc/self/mountinfo.
This command will print a list of mount points with 4 columns where:
- TARGET: This shows the mount point.
- SOURCE: This column shows the mounted device or mounted filesystem.
- FSTYPE: The filesystem type.
- OPTIONS: Shows mount point options, such as Read-Only or Writable.
You can see mount points accurately by reading the /proc/mounts file using a command like a cat. While this method is less human-friendly, the result is useful because the information is directly fetched from the kernel.
Conclusion
Mount points can be considered as doors to inaccessible devices. Many Linux distributions by default mount filesystems when they are attached. This is not a good option and can be disabled because it is always recommended the intervention of a sysadmin to make sure the attached device will not harm the system, for example, when the user tries to recover information. Also, it is recommended to unmount devices properly, this may save the storage device’s health (like when you extract a USB device in Microsoft Windows). The content in this article is valid for all Linux distributions.
About the author
David Adams
David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.
3 ways to list mount points in Linux
In Linux, there are three ways to list mount points: using the df command, using the mount command, and using the cat /proc/mounts command. In this blog post, we will discuss each of these commands in detail. We will also provide examples of how to use each command. By the end of this blog post, you will be able to list all of the mount points on your Linux system!
what is mount point in Linux
In Linux, a mount point is a directory where a filesystem is mounted. This means that the contents of the filesystem are stored in the mount point directory, and the filesystem can be accessed from there. For example, if you have a filesystem on your hard drive that you want to access from Linux, you would need to mount it on a mount point.
List mount points with df command in Linux
To list the mount points in Linux, we can use df command. This command can be used to display information about mounted filesystems. By default, df command will list all the mount points on your system. You can also specify the mount point of the filesystem that you want to check.
For example, if you wanted to check the amount of free space on the filesystem that is mounted at /, you would use the following command: df /
This command would output the following information:
Filesystem Size Used Avail Use% Mounted on
/dev/sda 100G 12G 88G 12% /
The df command can be also used to display information about how much disk space is free on a filesystem.
List mount points with mount command in Linux
The mount command is used to list all of the mounted filesystems on a system. To use the mount command, you need to specify the -l option. For example, if you wanted to list all of the mounted filesystems on your system, you would use the following command: mount -l
This command would output the following information:
/dev/sda on / type ext (rw,noatime)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /dev type devtmpfs (rw,noexec,nosuid)
List mount points with cat /proc/mounts command in Linux
The cat /proc/mounts command is used to list all of the mounted filesystems on a system. To use this command, you do not need to specify any options. For example, if you wanted to list all of the mounted filesystems on your system, you would use the following command: cat /proc/mounts
This command would output the following information:
/dev/sda / ext (rw,noatime)
proc /proc proc (rw,noexec,nosuid,nodev)
sysfs /sys sysfs (rw,noexec,nosuid,nodev)
You can combine this command with grep command together to get the info of the specific mount point info.
As you can see, all three of these commands provide different information about mounted filesystems. However, all three commands can be used to list all of the mount points on a Linux system.
Example:To list all the mount points on your system, you would use any of the following commands: df /, mount -l, or cat /proc/mounts.
By the end of this blog post, you will be able to list all of the mount points on your Linux system! Try using one of the commands discussed in this post today and see what mount points are available on your system.