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: lsblk -f shows filesystems, labels and UUIDs in one view

Filesystems
~/tips/tip-linux-lsblk-f

lsblk -f

Shows every disk and partition with its filesystem type, label, UUID and mount point.

Before I touch a disk, I want to know what is on it. fdisk -l answers part of that. lsblk with one flag answers more.

Run:

lsblk -f

You get a tree of disks and partitions with the filesystem type, label, UUID, free space and mount point. An empty FSTYPE column means there is no filesystem on that partition. A swap partition shows up as swap.

This is also where you copy the UUID for /etc/fstab. Using the UUID instead of /dev/sdb1 keeps the mount working when device names change after a reboot or a new disk.

The caveat: the UUID belongs to the filesystem, not to the physical disk. If you clone a partition byte for byte, both copies carry the same UUID, and mounting by UUID can pick the wrong one. Check twice before you format anything based on a name.

I would run this as a habit before every mount, resize or format. It takes a second and can stop you wiping the wrong drive. The columns are also a quick way to see whether a disk is in use by LVM, RAID or encryption, because those show up as nested layers in the tree.

Further reading: lsblk man page, On this site: du -h -d1 | sort -h finds what is eating your disk, On this site: findmnt -T tells you which mount a path lives on

More Filesystems tips sudo fsfreeze -f /srv/data filefrag /var/lib/libvirt/images/vm1.qcow2 sudo btrfs filesystem usage /mnt/pool sudo tune2fs -l /dev/sdX1 | grep -iE 'mount count|check' findmnt --df All Filesystems tips (6) All topics

Link