Set an ext4 partition label
By default, partitions in /etc/fstab are referenced by UUID.
UUID=a141d416-dbc6-4b4e-9095-24b3f48eab6d / ext4 errors=remount-ro,noatime 0 1
The correspondence between a UUID and a block device can be seen under the path /dev/disk/by-uuid/:
ls -la /dev/disk/by-uuid/a141d416-dbc6-4b4e-9095-24b3f48eab6d
The output is a symbolic link to the block device:
a141d416-dbc6-4b4e-9095-24b3f48eab6d -> ../../sda2
UUIDs are used because block device paths are not stable. After an additional drive is installed, a partition that was /dev/sdb may appear as /dev/sdc. Referencing partitions by UUID or LABEL avoids confusion and reduces the risk of data loss.
UUIDs are not very human-friendly. Alternatively, a label can be set for a partition.
The current partition label can be viewed with the e2label utility:
sudo e2label /dev/sda2
On a freshly installed system, the output is typically an empty string, meaning no label is set for the partition.
A partition label can be set by adding the new label to the e2label command:
sudo e2label /dev/sda2 SYS
Note: On ext4, partition labels are limited to 16 characters.
The label can then be verified by running e2label again without the new label argument:
sudo e2label /dev/sda2
The output is the assigned label:
SYS
After that, the partition can be referenced in /etc/fstab using LABEL identifier instead of UUID:
LABEL=SYS / ext4 errors=remount-ro,noatime 0 1
The system can be rebooted to confirm that the partition mounts correctly.
After a reboot, partition layout can be inspected with lsblk:
lsblk -o NAME,LABEL,FSTYPE,SIZE,MOUNTPOINT
The output may show that the device path has changed from /dev/sda2 to /dev/sdc2, while the SYS label and mount point remain correct:
NAME LABEL FSTYPE SIZE MOUNTPOINT
...
sdc 149.1G
├─sdc1 vfat 976M /boot/efi
├─sdc2 SYS ext4 140.4G /
└─sdc3 swap 7.7G [SWAP]
This post showed how to view and set ext4 partition labels and reference them in /etc/fstab.