![]()
|
SysAdmin Topics
|
Disk Labels in Linux BackgroundOne of the annoying things with PC hardware is the mapping of disk devices On PC Linux systems, hard coding of disk devices should be avoided (like in From man fstab: Instead of giving the device explicitly, one may indicate the (ext2 or xfs) filesystem that is to be mounted by its UUID or volume label (cf. e2label(8) or xfs_admin(8)), writing LABEL=<label> or UUID=<uuid>, e.g., LABEL=Boot or UUID=3ede-813... This will make the system more robust: adding or removing a SCSI disk changes the disk device name but not the filesystem volume label. ext2, ext3, xfs and swap file systems can have labels. FAT file udev configures the disk labels and other device naming (by-id, labeling for ext3 and xfs file systemsFor creating ext3 and xfs file systems, mkfs.ext3 and mkfs.xfs have Examples of initializing new file systems with a label: mkfs.ext3 -L ROOT /dev/sda1 mkfs.xfs -L BIGRAID /dev/sde Examples of e2label and xfs_admin for existing files systems: e2label /dev/sda1 PRIMARY_ROOT e2label /dev/sda1 xfs_admin -L DATA1 /dev/sdf xfs_admin /dev/sdf labeling swap devicesYou can label a swap device by using the mkswap -L label option. mkswap -L SWAP0 /dev/sdb5 Alternative / by-idAlternatively, you can use the udev by-id specification (look /dev/disk/by-id/scsi-3500000e01632b7d0-part2 swap swap defaults 0 0 Examples of UseFinally, the following are examples of using disk labels in Example of /etc/fstab with disk labels: LABEL=ROOT / ext3 defaults 1 1 LABEL=BOOT /boot ext3 defaults 1 2 LABEL=SWAP swap swap defaults 0 0 LABEL=HOME /home ext3 nosuid,auto 1 2 Example of /boot/grub/grub.conf with disk labels: title astrid CentOS primary system root (hd0,0) kernel (hd0,0)/vmlinuz ro root=LABEL=ASTRID_ROOT0 rhgb quiet initrd (hd0,0)/initrd-astrid.img SummaryLinux systems support disk labels via the udev device manager. Using disk |