Mounting information appears when you run `mount` without parameters, showing every mounted filesystem and its mount point. If you want to learn how to list mounted drives in linux, you are in the right place. This guide covers all the commands and tools you need to see what is mounted on your system.
Listing mounted drives is a common task for Linux users. It helps you understand storage usage, troubleshoot issues, and manage filesystems. You will find multiple methods here, from simple commands to detailed output.
Let us start with the most basic command and then explore more advanced options. Each method has its own strengths, so you can choose what fits your needs.
Why List Mounted Drives In Linux
Knowing your mounted drives helps you manage disk space. It also shows you which filesystems are active. This is useful when adding new storage or debugging mount problems.
You might need to check if a USB drive is mounted. Or you may want to see network shares. Whatever the reason, listing drives is a core skill.
Using The Mount Command
The `mount` command is the most direct way. Type `mount` in the terminal and press Enter. You will see a list of all mounted filesystems.
Each line shows the device, mount point, filesystem type, and options. For example:
/dev/sda1 on / type ext4 (rw,relatime)
This output can be long. It includes system filesystems like `proc` and `sysfs`. To focus on real drives, you can filter the output.
Filtering Mount Output
Use `grep` to show only certain devices. For example, to see only ext4 filesystems:
mount | grep ext4
You can also filter by device name. For instance, to see only `/dev/sda` entries:
mount | grep /dev/sda
This makes the output easier to read. You can combine filters for specific needs.
Using The Df Command
The `df` command shows disk space usage. It also lists mounted filesystems. Run `df -h` for human-readable sizes.
The output includes the device, size, used space, available space, and mount point. This is great for checking storage capacity.
To see only local filesystems, use `df -h -l`. This excludes network mounts like NFS. You can also use `df -T` to show filesystem types.
Df With Specific Filesystems
You can limit `df` to certain types. For example, to show only ext4 filesystems:
df -h -t ext4
To exclude a type, use `-x`. For instance, to exclude tmpfs:
df -h -x tmpfs
These options help you focus on what matters.
Using The Lsblk Command
The `lsblk` command lists block devices. It shows a tree view of disks and partitions. This includes mounted and unmounted drives.
Run `lsblk` to see all block devices. The output shows device names, sizes, and mount points. Mounted drives have a mount point listed in the MOUNTPOINT column.
To see filesystem types, use `lsblk -f`. This adds FSTYPE and LABEL columns. You can also use `lsblk -o NAME,SIZE,TYPE,MOUNTPOINT` to customize columns.
Lsblk For Detailed Info
Use `lsblk -l` for a list format instead of a tree. This is easier to parse in scripts. You can also use `lsblk -n` to hide headers.
To see only mounted drives, filter with `grep`. For example:
lsblk -l | grep /
This shows only devices with a mount point.
Using The Findmnt Command
The `findmnt` command is designed to list mounted filesystems. It provides a clean tree view. Run `findmnt` to see all mounts.
The output includes the target mount point, source device, filesystem type, and options. It is more readable than `mount` for many users.
To see only real filesystems, use `findmnt -D`. This shows only directories that are mount points. You can also use `findmnt -l` for a list format.
Findmnt With Filters
You can filter by filesystem type. For example:
findmnt -t ext4
To see only specific devices, use:
findmnt /dev/sda1
This shows the mount details for that device.
Using The /Proc/Mounts File
The `/proc/mounts` file contains current mount information. You can read it with `cat`. This is the same data that `mount` shows.
Run `cat /proc/mounts` to see the list. Each line has the device, mount point, filesystem type, and options. This file is always up-to-date.
You can also use `/etc/mtab` but it may be outdated. `/proc/mounts` is more reliable.
Filtering /Proc/Mounts
Use `grep` to filter the output. For example:
cat /proc/mounts | grep ext4
This shows only ext4 filesystems. You can also use `awk` to extract specific columns.
Using The Blkid Command
The `blkid` command shows block device attributes. It lists UUIDs, labels, and filesystem types. This helps identify drives even without mount points.
Run `blkid` as root or with `sudo`. The output shows each device and its properties. This is useful for unmounted drives.
To see only mounted drives, combine with `mount` or `lsblk`. For example:
sudo blkid | grep -f <(mount | cut -d' ' -f1)
This is more advanced but powerful.
Using The Lsof Command
The `lsof` command lists open files. It can show which processes use a mounted filesystem. This is helpful for troubleshooting.
Run `lsof /mnt` to see files open on a specific mount point. You can also use `lsof +D /mnt` for a deeper scan.
This is not for listing drives but for checking activity.
Using The Mountpoint Command
The `mountpoint` command checks if a directory is a mount point. It returns true or false. This is useful in scripts.
Run `mountpoint /mnt` to check. Use `-q` for quiet mode. This is a simple tool for validation.
How To List Mounted Drives In Linux With GUI Tools
If you prefer a graphical interface, use the Disks utility. It shows all drives and partitions. You can see mount points and filesystem types.
Open Disks from the application menu. Click on a drive to see details. Mounted drives have a green indicator.
Another tool is GParted. It shows partitions and mount points. You can also use system monitors like GNOME System Monitor.
Comparing Commands For Listing Mounted Drives
Here is a quick comparison of the commands:
- mount: Shows all mounts, including pseudo filesystems.
- df: Shows disk usage and mount points.
- lsblk: Shows block devices, including unmounted.
- findmnt: Shows mounts in a tree format.
- blkid: Shows device attributes.
Each command has its own use case. Choose based on what you need to see.
Common Issues When Listing Mounted Drives
Sometimes you may not see a drive you expect. This could be due to permissions. Run commands with `sudo` if needed.
Another issue is missing mount points. Check if the drive is connected. Use `lsblk` to see all block devices.
If a drive is not listed, it may be unmounted. Use `mount` with the device name to mount it.
Automating The Listing Process
You can create scripts to list mounted drives. For example, a simple bash script:
#!/bin/bash
echo "Mounted drives:"
mount | grep /dev/sd
Save this as a file and make it executable. Run it anytime you need a quick list.
You can also use cron to log mounts periodically. This helps with monitoring.
Understanding Mount Output Columns
The `mount` output has several columns. The first is the device, like `/dev/sda1`. The second is the mount point, like `/`. The third is the filesystem type, like `ext4`. The fourth is options, like `rw` for read-write.
Options include `ro` for read-only, `noexec` for no execution, and `nosuid` for no suid bits. These are important for security.
Knowing these columns helps you interpret the output.
Using Grep To Find Specific Drives
You can search for specific drives with `grep`. For example, to find all USB drives:
mount | grep /dev/sd
To find network mounts:
mount | grep nfs
This makes it easy to filter.
Listing Mounted Drives In Scripts
In scripts, use `findmnt -n -o TARGET` to get mount points. Use `df -h --output=target` for disk usage. These are reliable for automation.
You can also parse `/proc/mounts` with `awk`. For example:
awk '{print $1, $2}' /proc/mounts
This prints device and mount point.
How To List Mounted Drives In Linux For Different Filesystems
Different filesystems may appear differently. For example, `tmpfs` is a temporary filesystem. `proc` is a pseudo filesystem. These are not real drives.
To list only real drives, filter out pseudo filesystems. Use `mount | grep -E '^/dev/'` to show only device-backed mounts.
You can also use `findmnt -D` to show only directories.
Using Aliases For Quick Access
Create an alias in your `.bashrc` file. For example:
alias mounted='mount | grep /dev/sd'
Then type `mounted` to see your drives. This saves time.
You can also alias `df -h` or `lsblk -f`.
Frequently Asked Questions
What Is The Easiest Way To List Mounted Drives In Linux?
The easiest way is to run the `mount` command without arguments. It shows all mounted filesystems. For a cleaner view, use `lsblk`.
How Can I See Only Real Hard Drives And Not Pseudo Filesystems?
Use `mount | grep /dev/sd` to filter for device-backed mounts. Or use `findmnt -D` to show only directory mount points.
Can I List Mounted Drives Without Using The Terminal?
Yes, use the Disks utility or GParted. These graphical tools show mounted drives and their details.
Why Does My USB Drive Not Appear In The Mount List?
It may not be mounted. Use `lsblk` to see if it is detected. If it is, mount it with `mount /dev/sdb1 /mnt`. Check permissions if it fails.
How Do I List Mounted Drives In A Script?
Use `findmnt -n -o TARGET` for mount points. Use `df -h --output=target` for disk usage. Parse `/proc/mounts` with `awk` for raw data.
Conclusion
Now you know several ways to list mounted drives in Linux. The `mount` command is the simplest. The `lsblk` command gives a clear block device view. The `df` command shows disk usage. The `findmnt` command offers a tree format.
Choose the method that works best for your task. Use filters to focus on specific drives. Script the process for automation. With these tools, you can manage your storage effectivly.
Remember to check permissions if you cannot see a drive. Use `sudo` when needed. Practice these commands to become confident. Listing mounted drives is a fundamental skill that will serve you well.
If you have any issues, refer back to this guide. The commands are reliable and widely used. Happy listing!