Creating Disk Labels in Linux
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3887
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
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 ::
swaplabel -L <label> /dev/XXX using util-linux
e2label /dev/XXX <label> using e2fsprogs
btrfs filesystem label /dev/XXX <label> using btrfs-progs
reiserfstune -l <label> /dev/XXX using reiserfsprogs
jfs_tune -L <label> /dev/XXX using jfsutils
xfs_admin -L <label> /dev/XXX using xfsprogs
dosfslabel /dev/XXX <label> using dosfstools
mlabel -i /dev/XXX ::<label> using mtools (when you create the filesystem, use mkdosfs -n <label> <other options>. )
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
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
Display posts from previous:   

All times are GMT - 8 Hours