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.