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
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs
-
Juno Computers Launches Another Linux Laptop
If you're looking for a powerhouse laptop that runs Ubuntu, the Juno Computers Neptune 17 v6 should be on your radar.
-
ZorinOS 17.1 Released, Includes Improved Windows App Support
If you need or desire to run Windows applications on Linux, there's one distribution intent on making that easier for you and its new release further improves that feature.
-
Linux Market Share Surpasses 4% for the First Time
Look out Windows and macOS, Linux is on the rise and has even topped ChromeOS to become the fourth most widely used OS around the globe.
-
KDE’s Plasma 6 Officially Available
KDE’s Plasma 6.0 "Megarelease" has happened, and it's brimming with new features, polish, and performance.
-
Latest Version of Tails Unleashed
Tails 6.0 is based on Debian 12 and includes GNOME 43.
-
KDE Announces New Slimbook V with Plenty of Power and KDE’s Plasma 6
If you're a fan of KDE Plasma, you'll be thrilled to hear they've announced a new Slimbook with an AMD CPU and the latest version of KDE Plasma desktop.
-
Monthly Sponsorship Includes Early Access to elementary OS 8
If you want to get a glimpse of what's in the pipeline for elementary OS 8, just set up a monthly sponsorship to help fund its continued existence.