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: e2label gives an ext4 disk a name you can mount it by

Disk
~/tips/tip-disk-e2label-mount-by-label

e2label /dev/sdX1 backup2

Sets a readable label on an ext4 filesystem and uses that label in fstab.

UUIDs are the safe way to name a filesystem in fstab, but nobody can read them. A label is just as stable as long as you keep it unique, and it says what the disk is for.

e2label /dev/sdX1 backup2

I’d run it without the name first, to read the current label. On a filesystem in an image file, e2label fs.img backup2 sets it and blkid then shows LABEL="backup2". The label can be up to 16 characters; with a longer one, e2label warns and cuts it off.

In fstab you can then write:

LABEL=backup2  /mnt/backup2  ext4  defaults,nofail  0  2

udev also adds a link under /dev/disk/by-label/, so mount /dev/disk/by-label/backup2 /mnt/backup2 works by hand.

Other filesystems have their own tools: xfs_admin -L for XFS (only when unmounted), fatlabel for FAT and btrfs filesystem label for Btrfs. And here’s the risk: two disks with the same label, for example after cloning one onto another, make the LABEL= line pick one of them, and you can’t be sure which. After a clone, give the copy a new label right away, or stay with UUIDs.

Further reading: e2label(8) manual page, fstab(5) 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