How to List Mounted Drives on Linux

List Mounted Drives on Linux

Understanding how to view mounted drives is an essential skill for any Linux user. Knowing which drives are connected to your system and where they are mounted allows you to effectively manage your storage and access the correct directories. This guide will provide a comprehensive overview of the various methods to list mounted drives on Linux.

Table of Contents

An Introduction to Mounted Drives

On a Linux system, a drive must be ‘mounted’ onto a directory location in order to be accessible to the operating system and users. This directory is known as the ‘mount point’ and creates an access point through which the data on the drive can be read and written to. Some typical mount points in Linux include:

  • /mnt – Used for temporarily mounted drives
  • /media – Used for removable media like USB drives or CDs
  • /run/media – Another location for removable drives based on udev rules

When a drive is mounted, Linux maintains a list of the mount points and drives in the /etc/mtab file. Understanding this file and the various mount commands allows a user to view vital information about connected drives.

Commands to List Mounted Drives

There are several simple terminal commands that display details on currently available and mounted drives on Linux.

df

The most common command is df (disk free). This displays all mounted file systems along with details like disk space usage.

df -h

The -h flag displays the output in human-readable format, with drive sizes in MB/GB rather than blocks.

This will display the file system, size, used space, available space, percentage used, and the mount point of each drive.

lsblk

lsblk (list block) displays information about all available block devices, including hard drives:

lsblk

This will list all drives connected to the system, whether mounted or not. The output includes the device name, major/minor device numbers, filesystem type, mount points, and drive size.

mount

The mount command by itself will show only currently mounted drives:

mount

While not as detailed as df or lsblk, this provides a quick overview of all mounted filesystems and their mount points.

/etc/mtab

The /etc/mtab file is the actual list of mounted devices that Linux maintains:

cat /etc/mtab

Viewing this file will display all mounted drives and their mount points in the format device_name mount_point file_system_type options.

This file is kept up-to-date by the OS whenever drives are mounted or unmounted.

/proc/mounts

/proc/mounts provides information similar to /etc/mtab but is managed by the kernel itself:

cat /proc/mounts

This contains a list of actively mounted filesystems and can be useful if /etc/mtab is not updating correctly.

Interpreting Mount Command Outputs

The various mount commands display related but slightly different details about the connected drives on a system. Here are some key points about interpreting their outputs:

  • df focuses specifically on filesystem disk usage statistics like free space.
  • lsblk provides low-level block device attributes like device names and filesystem types.
  • mount and /etc/mtab display only actively mounted filesystems. Unmounted drives will not appear.
  • Drive sizes may be represented in different units like bytes, KB, MB, or GB. Use the flags like df -h to standardize the display format.
  • The filesystem type identifies formats like Btrfs, Ext4, XFS or VFAT for USB drives.
  • If any output shows a filesystem mounted at / (root), that is the main system disk.

Understanding what each command shows and how to interpret the results allows you to match drives, mountpoints, and filesystem formats to get a clear picture of your connected storage.

Advanced Techniques for Listing Drives

In addition to the basic commands already covered, there are some more advanced tools and techniques to list disks on Linux:

ls -l /dev/disk/by-id

This will display all drives connected to the system by their unique hardware ID:

ls -l /dev/disk/by-id

This ID mapping remains persistent even if device names change. So it can help identify drives even if they move between controller ports or get enumerated in a different order after a reboot.

hwinfo

hwinfo is a handy tool that discovers and lists all hardware devices on a system, including disk drives and storage volumes:

hwinfo --short --disk

It will print out a tree overview of all disks, partitions, RAID volumes and logical devices.

blkid

blkid displays identifiers and filesystem details for block devices:

blkid

It works on both mounted and unmounted drives to display hardware serial numbers, filesystem LABELs, UUIDs, and supported filesystem types.

System Logs

Linux log files can provide information about recently connected drives and mount operations:

grep mount /var/log/messages

This can be useful when troubleshooting to trace back mounting issues on drives.

Best Practices for Mounted Drives

Follow these guidelines when working with mounted storage to avoid issues:

  • Don’t mount multiple filesystems to the same mount point.
  • Don’t mount drives using normal users. Always use root or sudo privileges.
  • Validate filesystem integrity with fsck before mounting after an improper shutdown.
  • Backup critical data regularly in case of filesystem corruption issues.
  • Monitor disk health and smart metrics to catch issues early.

Conclusion

This covers the key commands and techniques to effectively list mounted drives on Linux. Whether you need disk usage statistics, device names, filesystem labels, or just a simple list of mount points, these tools provide comprehensive visibility into connected storage. Mastering drive mounting in Linux is a key skill for administrators and power users.

Marshall Anthony is a professional Linux DevOps writer with a passion for technology and innovation. With over 8 years of experience in the industry, he has become a go-to expert for anyone looking to learn more about Linux.

Related Posts