Disk partition labels

That’s something I never had the habit of doing… labeling my disk partitions. However, I’d like to make things a bit easier to remember. After searching a bit, I came up with the following. I was doing a fresh install of Slackware and was going to format the partitions anyway.

Do not just copy and paste, as you may format a partition you wanted to keep! I have commented out the lines that create the respective filesystems. More info about the commands in the Arch wiki.

I am booting with Grub in UEFI mode, so the EFI partition comes first:

# mkfs.vfat -F 32 /dev/sda1
fatlabel /dev/sda1 EFI

I like to keep /boot separately, using EXT2 (old habits)…

# mkfs.ext2 /dev/sda2
e2label /dev/sda2 BOOT

I use XFS for /, /home, /var and /tmp

# mkfs.xfs /dev/sda3
xfs_admin -L ROOT /dev/sda3
# mkfs.xfs /dev/sda4
xfs_admin -L HOME /dev/sda4
# mkfs.xfs /dev/sda5
xfs_admin -L VAR /dev/sda5
# mkfs.xfs /dev/sda6
xfs_admin -L TMP /dev/sda6

Finally, this is my SWAP

# mkswap /dev/sda7
swaplabel -L SWAP /dev/sda7

The labels can be used in /etc/fstab (as demonstrated), like this:

LABEL=SWAP        swap             swap        defaults         0   0
LABEL=ROOT        /                xfs         defaults         1   1
LABEL=BOOT        /boot            ext2        defaults         1   2
LABEL=HOME        /home            xfs         defaults         1   2
LABEL=VAR         /var             xfs         defaults         1   2
LABEL=TMP         /tmp             xfs         defaults         1   2
LABEL=EFI         /boot/efi        vfat        defaults         1   0

Of course, in this way, the order of partitions on the disk is not (that) clear.



Leave a comment