In Linux, “mounting a drive” refers to making a storage device accessible to the file system hierarchy. When a drive is mounted, it can be accessed and manipulated like any other directory on the system. If you have multiple drives mounted and want to perform any operations such as repartitioning them, it is crucial to have on-point information.
There are several ways to show the mounted drives on a Linux system, some of the most common methods are:
findmnt is a command line utility that is used to display information about mounted file systems on Linux and Unix-like operating systems. It is part of the util-linux package, which contains a variety of system utilities for Linux.
The findmnt command can be used to list all mounted file systems, or to display information about a specific file system. Some examples of how the findmnt command can be used are:
- findmnt: Lists all mounted file systems
- findmnt /: Displays information about the file system that the root directory “/” is mounted on
- findmnt -o TARGET,FSTYPE,SIZE,AVAIL: Lists all mounted file systems and displays their target, file system type, size, and available space
- findmnt -t ext4: Lists all mounted file systems of type ext4
findmnt command could be used in conjunction with other commands like umount to unmount file system, mount to mount file system, df to show the file system usage and many more.
cat /proc/mounts is a command that displays the file systems that are currently mounted on a Linux or Unix-like operating system. The cat command is used to concatenate and display the contents of a file, and in this case, the file that is being displayed is /proc/mounts.
The /proc/mounts file is a virtual file that is provided by the kernel’s proc filesystem and contains information about all file systems that are currently mounted on the system. The file includes entries for all file system types, including local file systems, network file systems, and others. Each line in the file represents one mounted file system and contains the following fields:
- The device or file system that is being mounted
- The mount point (directory where the file system is mounted)
- The file system type
- The mount options
- The dump frequency (used by the backup program dump)
- The pass number (used by the backup program fsck)
The cat /proc/mounts command can be useful for viewing the current state of the mounted file systems on a system, and for troubleshooting issues related to file system mounts.
mount -l is a command that is used to display information about all file systems that are currently mounted on a Linux or Unix-like operating system. The mount command is used to mount file systems and devices, and the -l option is used to display information about the currently mounted file systems.
When mount -l is executed, it shows a list of all the file systems currently mounted on the system, including the device or file system being mounted, the mount point (directory where the file system is mounted), the file system type, and the mount options. Each file system is listed on a separate line.
The -l option of the mount command shows the same information as the /proc/mounts file. It shows the device or file system that is being mounted, the mount point (directory where the file system is mounted), the file system type, the mount options, the dump frequency (used by the backup program dump) and the pass number (used by the backup program fsck)
This command can be useful for viewing the current state of the mounted file systems on a system, and for troubleshooting issues related to file system mounts.
Similarly, if you are looking for mounted drives with a specific filesystem, all you need to do is append the filesystem type with the -t option:
Command: mount -l -t ext4
The df command is also used to check the free disk space and so for listing mounted drives. To list mounted drives with the df command, you’d need to use 3 options with it:
Command: sudo df -a -T -h
The above command shows the file system, the total size, the used space, the available space, the used percentage and the mount point of the file system.
And if you want to list mounted drives specific to a filesystem type, all you need to do is add the -t option with the previous ones.
Command: sudo df -a -T -h -t ext4
You may also read:
- 50+ Useful Linux Commands with Examples
- Top 5 Best Linux Distros Every Developer Must Use
- 200+ Kali Linux Commands – Updated Cheatsheet
- [Tutorial] How to Install MobSF on Kali Linux 2022.1
- How To Install Jenkins on Ubuntu Machine
- [Tutorial] How To Install Webmin in Ubuntu
- How to Install Apache Tomcat on Ubuntu Machine
- A Step-by-Step Guide to Installing the LAMP Stack on Ubuntu
- [Linux] MySQL: The Easy Way to Check Your Version
- How To Install Remmina in Ubuntu – A Remote Desktop Client