Identify mounted filesystems
Transparency
Tools like mount and findmnt reveal which partitions and filesystems are mounted on your computer.
When creating a boot medium or expanding a system, you often need to create a new partition or add a filesystem to an existing partition. Selecting the wrong device can cost you valuable data.
Tools like partx
, fdisk
/cfdisk
, gdisk
/cgdisk
, mount
, lsblk
, and findmnt
help you discover which partitions and filesystems are present on the system and where they are currently mounted. We take you on a quick tour of some of these partition and filesystem tools, which are found on most of the standard Linux distributions.
Disk Tools
To make sure that you pass the correct parameters to the commands, you first need an overview of the volumes that exist on the system. The partx
program will help you here. The --show
switch tells it to list the individual partitions (Figure 1).
The output includes six columns with the partition number, start and end blocks, number of blocks, size, name, and UUID of the partition. The example shows six partitions /dev/sda1
, /dev/sda2
, and /dev/sda5
to /dev/sda8
.
This output already gives you a brief overview. However, it does not yet show you how the individual partitions are structured. fdisk
, which outputs the individual partitions if you pass in the -l
option (Figure 2), provides a little more information. However, the program only works for disks with a capacity of up to 2TBe, whereas the gfdisk
and Parted tools can analyze larger disks.
Next up is cfdisk
. As you can see in Figure 3, cfdisk
provides even more information. This information includes the fact that /dev/sda1
is a primary partition, /dev/sda2
is an extended partition, and /dev/sda5
through /dev/sda8
contain logical partitions. In addition, it shows you the partition type – /dev/sda6
turns out to be a swap partition.
cfdisk
has a counterpart named cgdisk
, which works the same way as fdisk
/gdisk
. When it comes to partition tables, fdisk
and cfdisk
only support Master Boot Record (MBR) format. MBR is a boot sector format that was popular with BIOS-based computers for many years. On the other hand, gdisk
and cgdisk
also support the GUID Partition Table (GPT) format. GPT is the successor to MBR for partition tables on hard disks and part of the UEFI standard. FigFigure 4 shows the cgdisk
menu after calling cgdisk -l /dev/sda
.
However, all these programs do not help to detect whether the listed partitions are mounted in the filesystem or where they sit in the directory tree. If you want answers to these questions, the lsblk
program comes into play.
Mounted Disks
lsblk
(the abbreviation stands for "list block devices") shows all block devices. The default view in lsblk
includes only the devices or partitions currently in use (Figure 5). In the right-hand column, you will find the mount point (i.e., the position at which the device is mounted in the directory tree).
The output of lsblk
has six columns. Table 1 gives an overview of the information you get from this list.
Table 1
lsblk
NAME |
Device name |
MAJ:MIN |
Main and extension numbers of the device |
RM |
0 for fixed and 1 for removable devices (like CD/DVD drives) |
SIZE |
Storage capacity of the device in human readable form |
TYPE |
Type of device (see Table 2) |
MOUNTPOINT |
Directory in which the device is mounted |
Table 2
lsblk Types
disk |
Hard disk |
loop |
Loop device |
lvm |
Logic Volume Manager (LVM)1 partition |
part |
Partition on a storage medium |
rom |
CD/DVD drive |
1 LVM is the abstract partitioning schema across disks, partitions, and filesystems. LVM enables dynamically changeable partitions (logical volumes) across multiple hard disks. |
---|
Using the -a
switch helps lsblk
bring more devices to light by including devices that are not currently in use. For example, Figure 6 shows a series of loop devices (virtual block devices that do not map to a physical device, but use a file for underlying storage) from /dev/loop0
to /dev/loop7
.
Filesystems
The -a
switch tells you which partitions exist and under which mount points they are mounted in the filesystem. So far, however, you do not know which options were set when mounting the partition. The mount
command shows these kinds of details (Figure 7).
The output from the command is quite extensive and often includes numerous virtual devices managed by the kernel and system programs. In many cases, however, only the physical mass storage devices and their mounted partitions are of interest.
Since Linux partitions mostly have the ext filesystem (today mostly ext4), you could filter the output of mount
with grep
accordingly. However, this detour is not actually necessary. Mount offers a -t
(short for --type
) switch that outputs filesystems of a certain type only. For example, the command in Figure 8 only returns partitions formatted with ext4.
mount
provides so much information that clarity can suffer. The output of findmnt
from the same software package offers a better structure. When called without further options, findmnt
shows a tree view (Figure 9) from which you can see how the individual filesystems are mounted. The findmnt
command also identifies the origin and type of the filesystem and the options with which it was mounted.
findmnt
also supports the -t
option, with which you can filter for ext4 filesystems, for example (Figure 10). Unlike mount
, findmnt
isn't limited to a single filesystem parameter but lets you enter several if required.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
AlmaLinux OS Kitten 10 Gives Power Users a Sneak Preview
If you're looking to kick the tires of AlmaLinux's upstream version, the developers have a purrfect solution.
-
Gnome 47.1 Released with a Few Fixes
The latest release of the Gnome desktop is all about fixing a few nagging issues and not about bringing new features into the mix.
-
System76 Unveils an Ampere-Powered Thelio Desktop
If you're looking for a new desktop system for developing autonomous driving and software-defined vehicle solutions. System76 has you covered.
-
VirtualBox 7.1.4 Includes Initial Support for Linux kernel 6.12
The latest version of VirtualBox has arrived and it not only adds initial support for kernel 6.12 but another feature that will make using the virtual machine tool much easier.
-
New Slimbook EVO with Raw AMD Ryzen Power
If you're looking for serious power in a 14" ultrabook that is powered by Linux, Slimbook has just the thing for you.
-
The Gnome Foundation Struggling to Stay Afloat
The foundation behind the Gnome desktop environment is having to go through some serious belt-tightening due to continued financial problems.
-
Thousands of Linux Servers Infected with Stealth Malware Since 2021
Perfctl is capable of remaining undetected, which makes it dangerous and hard to mitigate.
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.