Creating Disk Labels in Linux
Updated: 2014-04-24
Here are the basic commands to create Labels to use instead of those awkward and user unfriendly UUIDs. Make all labels very clear and specific, for example, if you computers name is mybox, a good safe label would be: mybox-root-1 It's very important that labels never conflict with each other or linux gets confused. An external usb disk, for example, could be: usb-320gb-1 swap could be: mybox-swap-1 Here's a nice list of methods from Arch Linux Wiki :: Code :: swap
swaplabel -L <label> /dev/XXX using util-linux ext2/3/4 e2label /dev/XXX <label> using e2fsprogs btrfs btrfs filesystem label /dev/XXX <label> using btrfs-progs reiserfs reiserfstune -l <label> /dev/XXX using reiserfsprogs jfs jfs_tune -L <label> /dev/XXX using jfsutils xfs xfs_admin -L <label> /dev/XXX using xfsprogs fat/vfat dosfslabel /dev/XXX <label> using dosfstools fat/vfat mlabel -i /dev/XXX ::<label> using mtools (when you create the filesystem, use mkdosfs -n <label> <other options>. ) ntfs ntfslabel /dev/XXX <label> using ntfs-3g Now, to update your system to use these, you'll need to edit, at least: /boot/grub/menu.list Replace all /dev/sdxy or /dev/hdxy to use LABEL=<your partition label> ie: root=/dev/sda1 becomes root=LABEL=mybox-root-1 or: root=UUID=YOERWTKJJSH873WHWY97ARWWERYE becomes: root=LABEL=mybox-root-1 Hopefully no further examples of UUIDs totally userunfriendly character is required. Do the same in /etc/fstab. Note that if you for example have to reformat or expand or move a partition, you don't need to change any system that accesses that disk, all you need to do is make sure that partition receives the correct label, then linux will find it fine. Other tests you can run to find hidden use of UUID or /dev/sdx: :: Code :: grep -REis '(/dev/[sh]d.*|UUID)' /etc/* | grep -Eiv '(binary|mtab|udev|bash|blkid|^#|^[[:space:]]*#|init.d|/rc)'Back to top |
All times are GMT - 8 Hours |