Labels Instead of UUID
YOU ARE HERE :: Main Page >> HowTo >> Labels Instead of UUID
- This script is relevant to ALL editions of PCLinuxOS.
Using Labels for partitions instead of the UUID
Using labels for partitions in Linux is a convenient way to identify partitions, especially when the UUIDs are long and harder to remember. Here's a step-by-step guide on how to use labels for partitions:
All command to be executed from a konsole window as the root user.
Label the Partition
To assign a label to a partition, you can use e2label (for ext2/ext3/ext4) or tune2fs, ntfslabel (for NTFS), or dosfslabel (for FAT32).
For ext2/ext3/ext4:
e2label /dev/sdXn new_label or tune2fs -L new_label /dev/sdXn
For NTFS:
ntfslabel /dev/sdXn new_label
For FAT32:
dosfslabel /dev/sdXn new_label
Replace `/dev/sdXn` with the partition's device name (e.g., `/dev/sda1`), and `new_label` with your desired label.
Verify the Label
You can verify that the label has been set using:
lsblk -o NAME,LABEL,UUID or blkid
Update `/etc/fstab` to Use the Label
To mount the partition using its label, update the `/etc/fstab` file:
1. Open `/etc/fstab` in a text editor:
nano /etc/fstab
2. Replace the UUID entry with the `LABEL=your_label` format:
LABEL=new_label /mount/point ext4 defaults 0 2 - `new_label` is the label you assigned to the partition. - `/mount/point` is where you want to mount the partition. - `ext4` (or other) is the filesystem type.
Mount the Partition
To test the configuration, either reboot the system or manually mount the partition using:
mount -a
Confirm the Change
Ensure the partition is mounted correctly using:
df -h
By using labels, you simplify the identification and management of partitions, making it easier to move or replace drives without worrying about changing UUIDs.
For External SATA (eSATA) Drives
Include "users" and "nofail" in fstab options. "nofail" allows the computer to be booted with the eSATA drive powered off. "users" allows the user to mount or unmount the drive. After the drive is unmounted, the eSATA drive can be powered off while the computer is running without causing errors.
LABEL=ext4-1 /home/(username)/EXT4-1 ext4 rw,exec,auto,nofail,users 0 0 LABEL=NTFS-1 /home/(username)/NTFS-1 ntfs rw,exec,auto,nofail,users 0 0
The eSATA drive used by this writer could not be configured using UUID and could not be configured using GParted. Successful configuration was done using KDE Partition Manager. This does not necessarily mean that eSATA will not work with other desktop environments. Drives are mounted before the DE is loaded. User experimentation may be required to configure and use eSATA solid state drives or mechanical hard drives. Ensure that the O/S and all user data on internal drives is backed up before attempting to set up an eSATA drive that has an option to be powered off at boot and can be powered off while the computer is running.