Filesystem labels

Filesystem labels can be used to specify a partition before its respective device number is known and is accessible through a fixed mountpoint name. This becomes essential when the devices are reordered. You would need to manually adjust /etc/fstab and boot loader configuration files. Even changing an IDE drive from master to slave requires this.

When mounting a device, all partitions (that would appear in /proc/partitions) are probed for the filesystem label. It will postload modules if necessary. This even works when the kernel mounts the root partition. Of course it is best to have the code for the root filesystem in the kernel.

The command to give a filesystem label is fs dependant. Some fs also can only be assigned a label if they are not mounted. Reiser3 and XFS are known to require the unmounted state. Ext2 and Ext3 do not require unmount, but that should not make you preferring them. Here are the different fs commands for a fictive home partition:

reiserfstune -l home /dev/hdc1
xfs_admin -L home /dev/hdc1
e2label /dev/hdc1 home

If your root fs is one of those who can only be tuned in unmounted or read-only state, you will need to boot into another system, i.e. rescue CD, live CD, another Linux on disk, etc.

After the filesystem(s) have been given a label, you could mount them with e.g.:

mount LABEL=home /home

The same applies to fstab where our example home partition entry could now look like this:

LABEL=home /home xfs defaults,usrquota,grpquota 0 0