All articles

Read Linux mounts with findmnt

4 minutes read


Linux publication

Share this article

𝕏✉

Illustration for Read Linux mounts with findmnt

When a path behaves strangely, the device name from df is often not enough. The path might sit under a bind mount, an overlay, a network filesystem, or a mount visible only inside one namespace. findmnt answers the more useful question: which mount applies here?

Resolve a path

findmnt --target /var/lib/app \
  --output TARGET,SOURCE,FSTYPE,VFS-OPTIONS,FS-OPTIONS

--target accepts any file or directory and finds the filesystem that contains it. The explicit column list keeps scripts and incident notes stable instead of relying on the default output, which may change.1

The columns answer different questions:

  • TARGET: where the filesystem is attached.
  • SOURCE: the backing device, remote export, or mount source.
  • FSTYPE: the filesystem type, such as ext4, xfs, nfs4, or overlay.
  • VFS-OPTIONS: options handled by the virtual filesystem layer.
  • FS-OPTIONS: filesystem-specific options.1

This distinction matters when an option appears inherited or when a bind mount has different VFS flags from its source.

Prefer structured output in scripts

findmnt --json --target /var/lib/app \
  --output TARGET,SOURCE,FSTYPE,OPTIONS

JSON avoids splitting aligned terminal output on spaces. Still request the columns you need. Treat unrequested fields and presentation details as unstable interfaces.1

See what the current process can see

Linux records mount information per mount namespace. /proc/self/mountinfo describes the namespace of the process reading it, including mount IDs, parent relationships, roots, targets, and optional propagation fields.3

findmnt --kernel
head -n 5 /proc/self/mountinfo

This explains a common container surprise: a path visible to a service may not match what you see from a host shell. Inspect from the same namespace when possible.

Check an fstab copy safely

You can validate the shape of a copied table without editing the live file:

lab=$(mktemp -d)
cp -- /etc/fstab "$lab/fstab"
findmnt --verify --verbose --tab-file "$lab/fstab"

findmnt --verify checks parsability and usability of entries. It does not prove that a remote server will be reachable during the next boot.1

[!CAUTION] Inspection is safe; mounting is state-changing. Do not run mount -a, edit /etc/fstab, or unmount a busy target during diagnosis unless you understand the service impact.2

Sources and further reading
  1. findmnt(8)
  2. mount(8)
  3. proc_pid_mountinfo(5)