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: blkid prints the UUID to use in fstab for a disk

Disk
~/tips/tip-disk-blkid-uuid-for-fstab

sudo blkid /dev/sdb1

Prints the stable UUID and filesystem type of a partition so fstab does not depend on changing device names.

Device names like /dev/sdb1 can change between boots, and a wrong one in fstab mounts the wrong disk. I put the UUID in fstab instead.

sudo blkid /dev/sdb1
# /dev/sdb1: UUID="3f2c..." TYPE="ext4"
UUID=3f2c...  /mnt/data  ext4  defaults,nofail  0  2

blkid reads the filesystem signature and prints the UUID and the type. Copy the UUID into the first column of the /etc/fstab line. The nofail option lets the machine boot even when that disk is missing. Run it with sudo, because without root it can show cached or empty data.

Further reading: blkid manual page

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' lsscsi -s udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h All Disk tips (44) All topics

Link