Contents[Hide]

Labeling a hard-drives under unix system gives a user a better way so organize block system's devices. Labels are allowed within /etc/fstab files so instead of refering to a partition /dev/sda1 you can provide LABEL=MY_BACKUP . We are going to mention two ways on how to label partition.

1. PARTITION LABEL

The first method is by using e2label command

# blkid /dev/hdb1
/dev/hdb1: UUID="50722b6b-dfd8-4faf-bb27-220fd69b0deb"
TYPE="ext3"

this will show current partition label ( if any ) and UUID of the partition. Now to change or add label with e2label:

# e2label /dev/hdb1 "MY_BACKUP"
# blkid /dev/hdb1
/dev/hdb1: UUID="50722b6b-dfd8-4faf-bb27-220fd69b0deb"
TYPE="ext3" LABEL="MY_BACKUP"

Other way on how to label partition with a name is to use tune2fs command

#blkid /dev/hdb1
/dev/hdb1: UUID="50722b6b-dfd8-4faf-bb27-220fd69b0deb" TYPE="ext3" LABEL="MY_BACKUP"
# tune2fs -L "SECRET" /dev/hdb1
tune2fs 1.41.3 (12-Oct-2008)
# blkid /dev/hdb1
/dev/hdb1: UUID="50722b6b-dfd8-4faf-bb27-220fd69b0deb" TYPE="ext3" LABEL="SECRET"

2. USAGE

Now we can refer to a /dev/hdb1 partition as SECRET within /etc/fstab as follows:

LABEL=SECRET /mount/point           ext3    defaults        0       2


Free Linux eBooks

Go to top