Home Beginner's Guide How to display currently mounted file systems in Linux

How to display currently mounted file systems in Linux

This guide provides various ways to show these mounted file systems using simple but powerful Linux commands such as df, lsblk, mount, and findmnt. Each method offers unique benefits, so you can choose the one that best fits your needs.

by Divya Kiran Kumar
showing mounted file systems in linux

Understanding the currently mounted file systems in your Linux machine is crucial for system management and troubleshooting. Mounted file systems include disk partitions, device drivers, and remote servers that your Linux system recognizes and uses.

This guide provides various ways to show these mounted file systems using simple but powerful Linux commands such as df, lsblk, mount, and findmnt. Each method offers unique benefits, so you can choose the one that best fits your needs.

A primer on file systems in Linux

First, let’s understand what a file system in Linux is. It is a method that controls how data is stored and retrieved on your device. Without a file system, it would be a strenuous task to locate and manage data, something we do not want.

Throughout my experience with Linux, I’ve had the chance to interact with different types of file systems, each with its unique characteristics. I must admit, I’ve developed quite a fondness for ext4 due to its superior performance and reliability. However, let’s not forget that Linux supports a myriad of other file systems like FAT32, NTFS, and more, which are equally captivating in their unique ways.

Why it’s important to know about mounted file systems

So, why should we even care about mounted file systems? Well, there are several reasons. Foremost, it’s crucial for administering disk space, which is, frankly, a perpetual concern for anyone working in a data-intensive environment. I’ve been there, trust me, and it’s not fun to see your system struggle due to lack of disk space.

Besides that, understanding mounted file systems also aids in device management and data allocation, providing insights into which resources are currently in use and their respective locations. Now, as a fan of neatness and system organization, this feature provides a sense of satisfaction like no other. Although, it could get overwhelming at times, especially when dealing with a large number of devices and data.

Viewing mounted file systems: The ‘df’ command

The journey to unravel mounted file systems begins with a simple yet effective command: ‘df’. Short for ‘disk free’, ‘df’ provides a detailed report of the system’s disk space usage.

There’s a sense of nostalgia every time I type ‘df’ into the terminal, a reminder of the time I first dipped my toes into the Linux world. While the output can initially seem confusing, it is incredibly informative.

To use the ‘df’ command, open your terminal and type ‘df’. By default, it displays the information in bytes, which isn’t exactly user-friendly. To display in a more readable format, you can use ‘df -h’, with ‘-h’ standing for ‘human-readable’. Now, isn’t that thoughtful!

df command usage

df command usage

The output will show the file system name, total size, used space, available space, percentage of space used, and the mount point – everything you need to keep track of your disk usage. Let’s look at another example.

Using the ‘df’ command

Let’s start with the ‘df’ command. When you open your terminal and type ‘df’, you’ll get an output similar to this:

df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 10238404 0 10238404 0% /dev
tmpfs 2049736 49004 2000732 3% /run
/dev/sda1 102384040 48904500 53379540 48% /
tmpfs 10248668 365516 9885152 4% /dev/shm
tmpfs 5120 4 5116 1% /run/lock
tmpfs 10248668 0 10248668 0% /sys/fs/cgroup
/dev/sdb1 102384040 48904500 53379540 48% /mnt/mydisk
tmpfs 2049732 144 2049588 1% /run/user/1000

The ‘df -h’ command provides a human-readable format, which I find more intuitive:

df -h
Filesystem Size Used Avail Use% Mounted on
udev 9.8G 0 9.8G 0% /dev
tmpfs 2.0G 47M 1.9G 3% /run
/dev/sda1 98G 47G 51G 48% /
tmpfs 9.8G 349M 9.5G 4% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 9.8G 0 9.8G 0% /sys/fs/cgroup
/dev/sdb1 98G 47G 51G 48% /mnt/mydisk
tmpfs 2.0G 140K 2.0G 1% /run/user/1000

Delving deeper: The ‘/etc/fstab’ file and ‘mount’ command

The ‘df’ command is handy but lacks a certain level of detail that advanced users might require. This is where the ‘/etc/fstab’ file and the ‘mount’ command come in. I’ve got to admit, these two are like the holy grail of managing mounted file systems. The level of granularity they provide is simply unmatched.

The ‘/etc/fstab’ file, often referred to as the file systems table, contains information about available disks and disk partitions. Personally, this file is like a well-kept ledger for me, albeit one that requires a bit of understanding to decipher.

As for the ‘mount’ command, well, it’s the powerhouse of file system management. Simply typing ‘mount’ into your terminal with no arguments will yield a list of currently mounted file systems, which might be all you need in some instances. It provides information about the device, the file system type, and the mount options used, amongst others. The amount of information can be overwhelming, but it’s also why I find the ‘mount’ command so endearing.

However, the true strength of ‘mount’ lies in its versatility. It allows mounting and unmounting file systems manually, a feature I’ve often found useful during system maintenance or when dealing with external storage devices.

An example – exploring ‘/etc/fstab’

Next, let’s look into the ‘/etc/fstab’ file. This file might look something like this:

UUID=a14g67d9-f26c-45ef-babc-3a1234b5c67d / ext4 errors=remount-ro 0 1
UUID=654A-16FD /boot/efi vfat umask=0077 0 1
UUID=5f01abc7-8b4c-469e-9eaa-8761234f0aa8 /home ext4 defaults 0 2
UUID=c6d8f2ae-5352-4b69-a0f8-5678h9i0jkl1 none swap sw 0 0
/dev/sdb1 /mnt/mydisk ext4 defaults 0 0

Here, each line represents a file system, and the columns specify the device or partition, the mount point, the file system type, mount options, and dump and pass options.

Working with the ‘mount’ command
The ‘mount’ command when run without arguments gives you information about all the currently mounted file systems.

$ mount
/dev/sda1 on / type ext4 (rw,relatime,errors=remount-ro)
udev on /dev type devtmpfs (rw,nosuid,noexec,relatime,size=10238404k,nr_inodes=2559601,mode=755)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=2049736k,mode=755)
/dev/sdb1 on /mnt/mydisk type ext4 (rw,relatime)

If you want to mount a new file system, you might use a command like this:

$ mount /dev/sdc1 /mnt/newdisk

This command mounts the file system on the device ‘/dev/sdc1’ to the directory ‘/mnt/newdisk’. Remember to replace ‘/dev/sdc1’ and ‘/mnt/newdisk’ with your specific device and directory.

Other methods

Using ‘lsblk’ to display file systems

While ‘df’ gives us excellent insights into disk usage, ‘lsblk’ (list block devices) dives into the details of your block devices, essentially your drives, which includes hard drives, flash drives, and CD-ROMs.

An example of the ‘lsblk’ command is:

lsblk
viewing list of partitions using lsblk

Viewing list of partitions using lsblk

This command displays a tree-like structure of all block devices along with their mount points (if mounted).

The power of the ‘mount’ command

When it comes to managing file systems, the ‘mount’ command is a powerhouse. Simply typing ‘mount’ into your terminal with no arguments will yield a list of currently mounted file systems, providing information about the device, the file system type, and the mount options used, amongst others.

You can manually mount and unmount file systems, making it a potent tool during system maintenance or when handling external storage devices.

mount
mount command usage

mount command usage

Using ‘findmnt’ to locate a file system

‘findmnt’ is another helpful command for exploring your mounted file systems. It locates a file system in the file system hierarchy and provides a well-structured overview of the file systems and their mount points.

Here’s a simple usage example:

findmnt
findmnt command usage

findmnt command usage

This command will list all mounted file systems in a tree-like format.

Choosing the right tool for your needs

As you can see, Linux offers a range of commands for interacting with mounted file systems, and each command has its strengths. ‘df’ is excellent for a quick overview of disk usage. ‘lsblk’ gives a deeper understanding of your block devices. ‘mount’ provides detailed information about each mounted file system, and ‘findmnt’ displays a well-structured tree of all file systems.

let’s dive into some common issues that you might encounter when dealing with mounted file systems in Linux and how to troubleshoot them.

Troubleshooting common issues

1. The file system is not mounted

Sometimes, you might find that a file system you expected to be mounted is not. First, check the ‘/etc/fstab’ file to see if the file system is listed there. If it isn’t, you need to add it. If it is, use the ‘mount’ command to manually mount it and see if any error messages come up. If the device is not found, there might be a problem with the hardware or the device name might be incorrect.

Here’s how you can mount a file system manually:

$ sudo mount /dev/sdc1 /mnt/newdisk

Replace ‘/dev/sdc1’ with your device and ‘/mnt/newdisk’ with your directory.

2. The file system is read-only

If you find that you can only read files and not write to them, it’s possible that the file system is mounted as read-only. This might be a safety feature, or it might be due to a problem with the file system.

Check the ‘/etc/fstab’ file for the entry for this file system. If the options include ‘ro’ (which stands for ‘read-only’), you might want to change it to ‘rw’ (which stands for ‘read-write’).

Remember that this is a potentially risky operation, especially if the file system was set to read-only for a reason. Make sure to back up any important data before making changes.

3. Insufficient space on the file system

Another common issue is running out of space on a file system. If you try to write data to a file system and there’s not enough space, you’ll get an error message.

You can use the ‘df’ command to check the available space on your file systems:

$ df -h

If a file system is near capacity, you might want to delete unneeded files or move them to another file system. You can use the ‘du’ command to check which directories are taking up the most space:

$ du -sh /*

This command gives the size of each directory in the root directory (‘/’).

4. File system is not in /etc/fstab

If a file system is not in ‘/etc/fstab’, it will not be automatically mounted at startup. If you find yourself manually mounting a file system every time you boot your computer, you should add the file system to ‘/etc/fstab’.

Here’s an example of what an entry in ‘/etc/fstab’ might look like:

/dev/sdc1 /mnt/newdisk ext4 defaults 0 0

This line mounts the device ‘/dev/sdc1’ to the directory ‘/mnt/newdisk’ using the ‘ext4’ file system type with default options.

Linux File Systems FAQ

Here are ten frequently asked questions about Linux file systems and their answers.

1. What is a file system in Linux?

A file system in Linux is a method used to control how data is stored and retrieved. It structures data into files and directories, which are organized in a hierarchical fashion.

2. How can I see the available space on my file system?

The ‘df’ command is used to check the available disk space. By typing ‘df -h’ in the terminal, you’ll see the disk usage in a human-readable format.

3. What is the ‘mount’ command used for?

The ‘mount’ command is used to mount file systems in Linux. It’s also used to view the current status of the system’s file systems.

4. What is the ‘/etc/fstab’ file?

The ‘/etc/fstab’ file is the file system table in Linux. It contains information about the disks and disk partitions, specifying how they should be initialized or integrated into the system’s file system.

5. How can I manually mount a file system?

To manually mount a file system, use the ‘mount’ command followed by the device identifier and the mount point. For example: ‘mount /dev/sdc1 /mnt/newdisk’.

6. How do I make a file system mount at startup?

To mount a file system at startup, add an entry for the file system to the ‘/etc/fstab’ file. This entry should include the device identifier, mount point, file system type, and any necessary options.

7. Why is my file system read-only?

A file system might be mounted as read-only due to errors in the file system, as a safety measure, or because of how it was configured in ‘/etc/fstab’. If you want to change this, you can modify its entry in ‘/etc/fstab’, but do so with caution.

8. How do I unmount a file system?

To unmount a file system, use the ‘umount’ command followed by the device identifier or the mount point. For example: ‘umount /mnt/newdisk’ or ‘umount /dev/sdc1’.

9. How do I check the type of a file system?

You can check the type of a file system using the ‘df’ command with the ‘-T’ option, like so: ‘df -T’.

10. How do I find the size of a directory?

To find the size of a directory, use the ‘du’ command. For instance, ‘du -sh /home/user’ will give the size of the ‘/home/user’ directory in a human-readable format.

Conclusion

In our journey through Linux file systems, we’ve come to realize the power and flexibility Linux provides in managing and displaying mounted file systems. Through hands-on examples, we’ve explored the ‘df’, ‘lsblk’, ‘mount’, and ‘findmnt’ commands, each offering unique insights and advantages.

The ‘df’ command offers a concise, quick look at disk usage, making it an invaluable tool for routine checks. In contrast, ‘lsblk’ delves deeper into block devices, enabling a comprehensive view of your drives and their characteristics.

The ‘mount’ command, both powerful and versatile, allows us to view and control mounted file systems, equipping us to tackle complex scenarios involving various file systems and their management. Finally, the ‘findmnt’ command, with its clear and hierarchical view of file systems, provides a well-structured representation that aids our understanding of the file system hierarchy.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.