While running commands to get mount points information is pretty easy, dealing with the output may not be comfortable for some users. After reading this tutorial, you’ll know how to get different outputs through different available commands: cat, findmnt, mount and df. Yet no format is really human friendly.
See mount points using findmnt:
The command findmnt lists all mount points. To do this the findmnt reads files /etc/fstab, /etc/fstab.d, /etc/mtab or /proc/self/mountinfo.
To run it, simply just the command below.
As you can see in the output, there are 4 columns:
- TARGET: This column shows the mount point.
- SOURCE: In this column, you can see the mounted device.
- FSTYPE: Here is described the file system.
- OPTIONS: This column shows mount point options, such as Read-Only or Writable.
You can get additional information on findmnt at https://linux.die.net/man/8/findmnt.
Show mount points using cat:
The most accurate technique to see mount points in Linux is reading the /proc/mounts file using cat. This is also the less human-friendly way, with the worse visual output.
The advantage of this method is that the kernel directly provides the information to see mount points over more human-friendly ways as alternatives explained in this tutorial
To see all mount points using cat, run the command as shown below.
As you can see, the output isn’t user friendly, but it is considered the most accurate method to check mounted devices in Linux.
See mount points using the mount command:
The mount is probably the most known command explained in this tutorial. Once we needed to run it every time we wanted to mount a device, it wasn’t automatic like today. By running it, you’ll get an output with all mounted filesystems. If followed by the -l flag, it will also show the mount point name; the output is similar to the mount command without flags.
As you can see, in the last two lines, there is a mounted pen drive containing a Kali Linux distribution.
You can read more about mount at https://en.wikipedia.org/wiki/Mount_(Unix).
Show mount points using df (Disk Free):
The df (Disk Free) command is also useful to print all mount points. The df command is mainly used to show available and used space on all storage devices.
To get an output with all mount points using df, just run it without additional options, as shown below.
Again you can see in the last line the /dev/sdb1 storage device is mounted.
This output displays 4 columns:
- Filesystem: This column shows the filesystem.
- 1K-Blocks: Here, you can see the size.
- Used: This column shows used space (in 1K blocks).
- Available: Available used space (in 1K blocks).
- Use%: Percentage of used space
- Mounted on: Mount point.
You can get more information on df at Linux Commands for Disk Space.
What happens when we mount or unmount a device in Linux?
When you mount a filesystem, like a cd, or a hard disk or USB stick, you create a mount point within your system. This mount point means virtually storing the cd, hard disk or USB stick’s content within your system. The files are not really stored in your system’s storage, but the system makes them accessible from itself by importing them under its filesystem hierarchy.
When you unmount a device, do exactly the opposite and instruct the system to stop providing mount points for external files.
Today mounting devices isn’t a common task since more user-friendly Linux distributions took over the market. Once, users needed to mount every external device manually, specifying the external device path and filesystem.
Conclusion:
As you can see, seeing all mounts in Linux is pretty easy. Linux offers you a variety of techniques to achieve this task by just running a command. As highlighted in the tutorial, the cat method is the most accurate and less human-friendly.
Other tools like findmnt feature a little improvement in the format, making it more user-friendly. Mounting, unmounting, and checking mount points status is a basic knowledge any Linux user-level must hold. Some Unix-like Linux distributions like Slackware don’t include automount enabled by default.
Thank you for reading this tutorial explaining how to see all mounts in Linux. Keep following Linux Hint for more Linux tips and tutorials.