Home / Alt manpages / findmnt(8)

  • findmnt(8)
  • Admin command
  • linux

Map Mounts and fstab Entries with findmnt

Someone asks which disk a path lives on and df gives you a wall of tmpfs noise, so reach for findmnt instead. You will finish able to answer three questions: which filesystem contains a path, what /etc/fstab declares, and which columns are safe to consume from a script.

Nothing here mounts, unmounts or alters anything. Allow about fifteen minutes. You need a shell and a normal user account, since reading the kernel mount table and /etc/fstab normally needs no elevated privileges.

  • Versions. This guide was checked against the local findmnt manpage, generated for util-linux 2.39.3.
  • Mismatch. The installed binary reports 2.41.3, while the Ubuntu package database says util-linux 2.39.3-9ubuntu6.6. Check findmnt --version on the machine where a detail matters.

1. Check the command you are about to use

Start with the version and help output. Both are read-only:

$ findmnt --version
findmnt from util-linux 2.41.3
$ findmnt --help | sed -n '1,12p'
Usage:
 findmnt [options]
 findmnt [options] <device> | <mountpoint>
 findmnt [options] <device> <mountpoint>
 findmnt [options] [--source <device>] [--target <path> | --mountpoint <dir>]

Option lists can grow between util-linux releases. The examples below use options present in the local manpage, so do not assume a flag copied from a newer machine exists on an older host.

Checkpoint

If findmnt --version fails, stop and install or repair the util-linux package through your normal system-management process. Do not work around a missing system utility with a downloaded binary in a production script.

2. Find the filesystem behind a path

Use --target when you mean a file or directory. It asks findmnt to identify the filesystem serving that path:

$ findmnt --target /etc/hosts -o SOURCE,FSTYPE,TARGET
SOURCE   FSTYPE TARGET
/dev/md2  ext4   /

The target can be an ordinary file, not only a mountpoint. If the exact path is not itself a mountpoint, the kernel search checks its path elements in reverse order and returns the containing mount. That is why /etc/hosts reports the root filesystem. Use --mountpoint instead when the path must be treated as the exact mountpoint, with no fallback.

Keep the output narrow when investigating one path:

  • SOURCE is the device or other source.
  • FSTYPE is the filesystem type.
  • TARGET is the mount target.

Add SIZE,USED,AVAIL,USE% for a capacity view:

$ findmnt --target /etc/hosts -o SOURCE,FSTYPE,SIZE,USED,AVAIL,USE%,TARGET
/dev/md2 ext4  3.6T 712.5G 2.7T 20% /

Sizes are human-readable by default, using powers of 1024 with shortened unit labels. Add --bytes when a consumer needs byte counts. Host capacity changes, so treat the numbers as a point-in-time observation.

3. Inspect mounted filesystems without guessing

With no source or target, findmnt lists mounted filesystems. The default is a tree-like view based on the kernel mount table, and its layout is allowed to change. For a quick human look, make the output easier to scan:

$ findmnt --real --list -o SOURCE,FSTYPE,TARGET | head -n 8
SOURCE                                    FSTYPE TARGET
/dev/loop1                                squashfs /snap/core24/1643
/dev/loop0                                squashfs /snap/canonical-livepatch/414
/dev/md2                                  ext4     /

--real filters out pseudo filesystems, and --list gives rows instead of the tree. The exact mounts and spacing belong to the host, so use the command to discover what is present, not as a fixed inventory. If you want the pseudo filesystems instead, use --pseudo.

Filter by filesystem type with --types. This lists ext4 mounts with explicit columns:

$ findmnt --types ext4 --list --output SOURCE,FSTYPE,TARGET
SOURCE   FSTYPE TARGET
/dev/md2  ext4   /

Supply more than one type as a comma-separated list. Combine type and mount-option filters only when you can explain the resulting intersection.

Warning

A filter that matches nothing is an error, not an empty success. The command exits with status 1 when no match is found.

4. Read fstab declarations separately from live mounts

findmnt can search the static file /etc/fstab with --fstab. This answers what is configured, not necessarily what is mounted now:

$ findmnt --fstab --output SOURCE,FSTYPE,TARGET,OPTIONS
SOURCE                                    FSTYPE TARGET OPTIONS
proc                                      proc   /proc  defaults
UUID=242175d2-d353-417c-98f9-341c92a571b4 ext4   /      quota,relatime,usrquota,grpquota,rw

Use --fstab --types nfs to find configured NFS entries, or --fstab --target /mnt/example to select a declared target. A bare path can also match a bind source, so use --target when you specifically mean the mountpoint column.

Tags such as UUID= and LABEL= stay useful in configuration. Add --evaluate when you want findmnt to resolve them to device names in the SOURCE column:

$ findmnt --fstab --evaluate --output SOURCE,FSTYPE,TARGET
SOURCE       FSTYPE TARGET
/dev/md2     ext4   /
/dev/sdX2    ext3   /boot

The device names here are illustrative because they depend on the host. If the same tag is found on more than one device, the manpage provides a SOURCES column to expose the ambiguity.

Warning

Do not copy a resolved device name into /etc/fstab just because it appeared in output. Device names can change; the tag is what keeps the entry stable.

5. Make output suitable for a script

Never parse the default tree display in automation. Select columns explicitly with --output, use --list, and suppress headings if the consumer expects data rows only:

$ findmnt --target /etc/hosts --list --noheadings --output SOURCE,FSTYPE,TARGET
/dev/md2 ext4 /

For shell-style key and value fields, use --pairs --shell. The shell option changes column names into valid shell variable identifiers:

$ findmnt --target /etc/hosts --pairs --shell --output SOURCE,FSTYPE,TARGET
SOURCE="/dev/md2" FSTYPE="ext4" TARGET="/"

Warning

Even with escaping, treat output as data. Do not eval a line if any part can be influenced by a user, a remote filesystem or untrusted configuration.

For a program that understands it, --json can be a clearer interchange format. Test the exact columns and format against every util-linux version you support.

Checkpoint

A stable script has an explicit column list, a deliberate list or raw format, and a defined response to exit status 1. It does not depend on column order from the default display or on a particular host's mount names.

6. Validate fstab without changing it

Use --verify to check the mount-table content. The default target is /etc/fstab, and --verbose asks for more detail:

$ findmnt --verify --verbose
0 parse errors, 0 errors, 4 warnings
... warning details for the entries in /etc/fstab ...

Wording, warning count and checks vary by util-linux release and by the file's contents. A zero status does not mean warnings can be ignored, and a non-zero status means you should read the diagnostic before attempting a mount. This command does not repair entries, mount filesystems or make a service reload its configuration.

Warning

Do not test an edited /etc/fstab by rebooting first. Keep a root shell or console recovery path open, check the file with findmnt --verify, and review every change. A bad network, encrypted or remote entry can delay boot or expose credentials. Verification is read-only, but a later mount -a is an operational change that may need elevated privileges and a maintenance window.

7. Diagnose the common traps

  • No result. The filter did not match, the path does not exist, or source and target were read differently than you meant. Repeat with an explicit selector: --source for a device, label or UUID, --target for a containing path, --mountpoint for an exact mountpoint.
  • Three different tables. The kernel view, /etc/mtab and /etc/fstab answer different questions. --kernel reports kernel-maintained mount information, --mtab can include userspace mount options, and --fstab reads declarations. Do not compare their rows as if they were three copies of one table.
  • Unquoted values. Quote paths and tag values in scripts. A space or shell metacharacter in a mount target is data, not a command boundary.
  • Blocking watcher. --poll watches mount, unmount, remount and move events and can block until a timeout. Treat it as a long-running observer, not a one-shot lookup.

Done means

  • Path to filesystem. You can identify the filesystem containing a file with --target.
  • Exact mountpoints. You know when to use --mountpoint.
  • Live vs declared. You can tell kernel mounts from /etc/fstab declarations.
  • Script-safe. Your scripts select explicit columns and handle a no-match exit status.
  • Verify first. You run --verify --verbose before considering any mount change.
  • Nothing touched. You have not mounted, unmounted or edited anything while following this guide.