How to Get the List of Mounted Filesystems in Linux

  1. Using the mount Command
  2. Using the /proc/mounts File
  3. Using the df Command
  4. Conclusion
  5. FAQ
How to Get the List of Mounted Filesystems in Linux

If you’re navigating the world of Linux, knowing how to list mounted filesystems is a fundamental skill that can come in handy in various situations. Whether you’re troubleshooting, optimizing performance, or simply curious about your system’s storage, understanding how to access this information is crucial.

In this article, we will explore several methods to retrieve the list of mounted filesystems in Linux. We will also provide clear examples and explanations to help you grasp each method quickly. So, let’s dive into the world of Linux filesystems and discover how to get the information you need efficiently.

Using the mount Command

One of the most straightforward ways to see a list of mounted filesystems in Linux is by using the mount command. This command displays all currently mounted filesystems along with their mount points and filesystem types. It’s a powerful tool that can provide you with a wealth of information in just a single line of code.

To use the mount command, simply open your terminal and type:

mount

Output:

/dev/sda1 on / type ext4 (rw,relatime)
/dev/sda2 on /home type ext4 (rw,relatime)
/dev/sr0 on /media/cdrom0 type iso9660 (ro,nosuid,nodev,relatime)
/dev/sdb1 on /mnt/usb type vfat (rw,nosuid,nodev,relatime)

The output of the mount command provides you with detailed information about each mounted filesystem. You can see the device name, the mount point, the filesystem type, and various mount options. This command is particularly useful for quickly checking the status of your filesystems and ensuring everything is functioning correctly.

Using the /proc/mounts File

Another effective method to list mounted filesystems is by examining the contents of the /proc/mounts file. This file provides a real-time view of all mounted filesystems in your Linux environment. You can access it using the cat command, like so:

cat /proc/mounts

Output:

/dev/sda1 / ext4 rw,relatime 0 0
/dev/sda2 /home ext4 rw,relatime 0 0
/dev/sr0 /media/cdrom0 iso9660 ro,nosuid,nodev,relatime 0 0
/dev/sdb1 /mnt/usb vfat rw,nosuid,nodev,relatime 0 0

When you run this command, you’ll see a list similar to what you get with the mount command. However, /proc/mounts can provide additional details that might not be visible with other commands. This method is particularly useful for system administrators who need to monitor filesystem activity and performance in real-time.

Using the df Command

The df command, which stands for “disk filesystem,” is another powerful tool for listing mounted filesystems. It not only shows you which filesystems are mounted but also provides information about their disk usage. This can be especially helpful if you’re trying to manage disk space effectively.

To use the df command, simply type the following in your terminal:

df -h

Output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G   20G   28G  43% /
/dev/sda2        100G  40G   55G  43% /home
/dev/sr0        1.5G  1.5G     0 100% /media/cdrom0
/dev/sdb1        32G   10G   22G  31% /mnt/usb

The -h option makes the output human-readable by displaying sizes in a format that is easy to understand (e.g., gigabytes, megabytes). The df command not only tells you which filesystems are mounted but also how much space is used and available on each filesystem. This makes it an invaluable tool for anyone looking to optimize their Linux system.

Conclusion

In this article, we’ve explored various methods to list mounted filesystems in Linux. Whether you prefer the simplicity of the mount command, the real-time data from /proc/mounts, or the disk usage insights from the df command, each method offers its unique advantages. By mastering these commands, you’ll enhance your ability to manage your Linux system effectively. So, go ahead and try these commands in your terminal to gain better insights into your filesystems!

FAQ

  1. How can I see detailed information about a specific mounted filesystem?
    You can use the df -h command followed by the mount point to get detailed information about a specific filesystem.

  2. What does the rw and ro mean in the mount command output?
    rw stands for read-write, meaning you can read and write to that filesystem. ro stands for read-only, meaning you can only read from that filesystem.

  3. Is there a graphical way to view mounted filesystems in Linux?
    Yes, many Linux distributions come with graphical disk management tools that can display mounted filesystems visually.

  4. Can I unmount a filesystem using the commands discussed?
    Yes, you can use the umount command followed by the mount point or the device name to unmount a filesystem.

  1. What should I do if a filesystem is not listed as mounted?
    If a filesystem is not listed, it may not be mounted. You can mount it using the mount command followed by the device name and the desired mount point.
Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
Author: Yahya Irmak
Yahya Irmak avatar Yahya Irmak avatar

Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.

LinkedIn

Related Article - Linux File