brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: findmnt -T tells you which mount a path lives on

Linux and shell
~/tips/tip-linux-findmnt-target

findmnt -T /var/lib/docker

Prints which mounted filesystem a given path lives on.

You write a big file somewhere and the wrong disk fills up. The question is which filesystem a path actually sits on, and df is a clumsy way to ask it.

Ask for the mount that contains a path:

findmnt -T /var/lib/docker

-T (--target) takes any path, not only a mount point, and prints the mount that holds it: source device, filesystem type and options. Run plain findmnt with no argument and you get the whole mount tree, which reads far better than mount output.

I also like findmnt --verify, which checks your /etc/fstab for mistakes such as unknown options or missing mount points before you reboot into a surprise.

The caveat: you see the mounts of the namespace you are in. Inside a container, the answer describes the container view, not the host.

It is also nicer than grepping /proc/mounts. The output is aligned, the tree view shows what is mounted below what, and the options column makes things like noexec or ro easy to spot. When a service claims it cannot write somewhere, this is one of the first things I would check.

Further reading: findmnt man page, On this site: lsblk -f shows filesystems, labels and UUIDs in one view, On this site: du -h -d1 | sort -h finds what is eating your disk

More Linux and shell tips zoxide query -ls project eval "$(fzf --bash)" comm --total a.txt b.txt diff -r -x .git -x '*.log' one two printf '%s\n' a b c d e f | xargs -n1 -P3 --process-slot-var=SLOT sh -c 'echo "slot $SLOT got $0"; sleep 0.2' All Linux and shell tips (178) All topics

Link