Disks and filesystems
findmnt
Show mounted filesystems as a tree, or look up which filesystem a path is on and how it is mounted.
findmnt [OPTION...] [SOURCE|TARGET]
findmnt is the modern, readable replacement for running mount with no arguments or reading
/proc/self/mountinfo. Without arguments it draws every mount as a tree. With a mount point or
device it shows just that entry, and with -T PATH it finds the filesystem that contains any
file or directory.
Its options make it script-friendly: -o chooses columns, -n drops the header, -J prints
JSON, -t filters by type, and the exit status says whether anything matched. It can also read
and check /etc/fstab (-s, --verify), which is worth doing after every edit: a broken fstab
can stop a machine from booting.
The examples here run in a container. Its root filesystem is an overlay, and the full mount
tree is left out because it describes the build server rather than anything useful; the
examples look at specific mounts instead.
Examples
Which filesystem is this directory on
findmnt -T . -o TARGET,SOURCE,FSTYPE
TARGET SOURCE FSTYPE / overlay overlay
-T (--target) walks up from the path to the mount point that contains it. Here that is
/, an overlay filesystem, the usual root of a container. On a laptop you would see
something like /home on /dev/nvme0n1p3.
Details of one mount point
findmnt /proc
TARGET SOURCE FSTYPE OPTIONS /proc proc proc rw,nosuid,nodev,noexec,relatime
Given a mount point, findmnt prints its source, type and mount options. nosuid, nodev
and noexec are typical hardening options for virtual filesystems.
All mounts of certain types
findmnt -t devpts,mqueue
TARGET SOURCE FSTYPE OPTIONS /dev/pts devpts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666 /dev/mqueue mqueue mqueue rw,nosuid,nodev,noexec,relatime
-t takes a comma-separated list of filesystem types. findmnt -t ext4,xfs,btrfs is the
usual way to see only the real disk filesystems on a machine.
Print just the mount options
findmnt -n -o OPTIONS /dev/shm
rw,nosuid,nodev,noexec,relatime,size=65536k,inode64
-n drops the header and -o OPTIONS keeps one column, so a script can test for, say,
noexec. Here /dev/shm is a 64 MiB tmpfs, the container's default.
Find mounts with a given option
findmnt -O ro -t sysfs,proc -o TARGET,FSTYPE,OPTIONS
TARGET FSTYPE OPTIONS /proc/bus proc ro,nosuid,nodev,noexec,relatime /proc/sys proc ro,nosuid,nodev,noexec,relatime /proc/irq proc ro,nosuid,nodev,noexec,relatime /proc/sysrq-trigger proc ro,nosuid,nodev,noexec,relatime /proc/fs proc ro,nosuid,nodev,noexec,relatime /sys sysfs ro,nosuid,nodev,noexec,relatime
-O ro keeps only read-only mounts. The container runtime mounts /sys and parts of
/proc read-only so that processes inside cannot change kernel settings.
Usage figures like df
findmnt -D /dev/shm
SOURCE FSTYPE SIZE USED AVAIL USE% TARGET shm tmpfs 64M 0 64M 0% /dev/shm
-D (--df) switches to df-style columns, with the mount point last.
JSON for scripts
findmnt -J /dev/pts
{
"filesystems": [
{
"target": "/dev/pts",
"source": "devpts",
"fstype": "devpts",
"options": "rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=666"
}
]
} -J prints JSON; every mount is an object under filesystems.
Test whether something is mounted
if findmnt -rn /mnt/backup > /dev/null; then
echo "backup disk mounted"
else
echo "backup disk NOT mounted, skipping"
fi
backup disk NOT mounted, skipping
The exit status is 0 when a match is found and 1 otherwise, which makes findmnt a reliable
guard before writing a backup into what might be an empty directory on the root disk.
Read an fstab file
# <source> <target> <type> <options> <dump> <pass>
UUID=0a3407de-014b-458b-b5c1-848e92a327a3 / ext4 errors=remount-ro 0 1
UUID=6E2C-8F1A /boot/efi vfat umask=0077 0 1
/dev/sdb1 /data ext4 defaults,noatime 0 2
tmpfs /tmp tmpfs size=2G,mode=1777 0 0
server:/export/home /mnt/home nfs defaults,_netdev 0 0
findmnt -F fstab
TARGET SOURCE FSTYPE OPTIONS / UUID=0a3407de-014b-458b-b5c1-848e92a327a3 ext4 errors=remount-ro /boot/efi UUID=6E2C-8F1A vfat umask=0077 /data /dev/sdb1 ext4 defaults,noatime /tmp tmpfs tmpfs size=2G,mode=1777 /mnt/home server:/export/home nfs defaults,_netdev
-s reads /etc/fstab; -F FILE (--tab-file) reads any file in that format, as here.
The result is the same table as for live mounts, which is easier to check than the raw file.
Check an fstab for mistakes
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs size=1G,mode=1777 0 0
/dev/sdc1 /backup ext5 defaults 0 2
findmnt --verify --tab-file fstab
0 parse errors, 1 error, 3 warnings /backup [E] unreachable on boot required target: No such file or directory [W] unreachable source: /dev/sdc1: No such file or directory [W] ext5 seems unsupported by the current kernel [W] cannot detect on-disk filesystem type (No such file or directory)
--verify checks every entry: does the source exist, does the target directory exist, is
the filesystem type known. The /backup line has a typo (ext5), and neither /dev/sdc1
nor /backup exists in this sandbox. Run findmnt --verify (it reads /etc/fstab by
default) before rebooting after an fstab edit.
Common pitfalls
A directory that should be a mount point but is not looks exactly like an empty mounted filesystem; scripts that write backups there fill the root disk. Check with
findmnt(ormountpoint -q) first.findmnt PATHonly matches when PATH is itself a mount point. To find the filesystem that contains a path, use-T.
GNU vs BSD and macOS
The examples above ran the GNU/Linux version. These are the differences that matter on macOS and the BSDs (written from their documentation, not run here).
findmntis Linux-only (util-linux). On macOS and BSD,mountwith no arguments anddf PATHcover the same questions.
Options worth knowing
A selection, described in our own words. For the full list, see findmnt(8) or findmnt --help.
| Option | What it does |
|---|---|
-T, --target PATH | Show the filesystem that contains PATH. |
-S, --source SPEC | Match mounts by source device or spec. |
-M, --mountpoint PATH | Match mounts by mount point. |
-t, --types LIST | Only filesystems of these types. |
-O, --options LIST | Only mounts with these options. |
-o, --output LIST | Print the listed columns. |
-n, --noheadings | Omit the header line. |
-l, --list | Plain list instead of a tree. |
-r, --raw | Raw output for parsing. |
-J, --json | Print JSON. |
-D, --df | Show df-style size and usage columns. |
-s, --fstab | Read /etc/fstab instead of the live mount table. |
-F, --tab-file FILE | Read mounts from FILE. |
-x, --verify | Check an fstab file for errors. |
--real | Only real filesystems, not pseudo ones. |
-R, --submounts | Include mounts below the matched one. |
-f, --first-only | Print only the first match. |
-p, --poll[=LIST] | Watch for mount, umount, remount or move events. |
Related
mountAttach a filesystem (a disk partition, image, network share or tmpfs) to a directory, or list what is mounted.lsblkList block devices (disks, partitions, LVM volumes, loop devices) as a tree, with sizes and mount points.dfReport how much space is used and free on mounted filesystems.statShow a file's metadata (size, permissions, owner, inode, timestamps), or print chosen fields in your own format.