Label your partitions to make booting Linux and mounting partitions far easier


With version 2.6 of the Linux Kernel, which has been in use now for almost seven years, udev was introduced as the device manager. Udev dynamically assigns entries in /dev for among other things, drive partitions, for which it supports LABELS and UUID designations in place of the usual /dev/sda, etc. You will most likely have seen the use of UUID designations if you’ve looked at the automatically generated fstab file from a recently installed Linux distro. Labels work like just like UUID designations but are far more user friendly and work with any partition type that you can mount in Linux.

Benefits of Labelling

If you label partitions on your portable hard drives and flash drives, you can mount them without knowing if the drive has been mapped to sdc, sdd, etc, provided you maintain unique labels for each of your partitions. You can also see your partition labels in applications that display them, e.g. the file manager Dolphin, which makes it far easier to locate content if you have more than a few partitions. By using partition labels, swapping & replacing drives is far easier; there’s no need to modify your partition table if the partitions used by a Linux installation remain available. You can also add or delete partitions on any drives in the system with no impact on a Linux distro – provided of course that deleted partitions aren’t used by the distro for a critical purpose. In my experience, labels are more reliable than the UUID method, (I’ve found UUID’s can change without warning) and labels are a lot easier to remember!

Operational Requirements

A version 2.6 kernel, Grub V0.97 or later. (I haven’t checked other bootloaders)

– That means virtually any Linux user can use Partition Labels!

Installation Requirements

GParted, and if you want to label your swap partition – mkswap (most likely automatically included in your distro)

How to Label Your Partitions

To change partition labels, the partitions must be unmounted. Hence the easiest way to label the partitions is to use a Live CD such as Parted Magic. This also applies for portable hard drives and flash drives if your Linux distribution automatically mounts these. Therefore this article only describes how to use Parted Magic to label your partitions. Based on this article, those more knowledgeable in using Linux should be able to unmount any USB mounted drives and label these and unmounted partitions on installed hard drives from within their running distribution.

First grab a copy of Parted Magic from and burn it to a CD. Change your BIOS so that your computer will first attempt to boot from a CD/DVD if that’s not your default setting, then boot up your computer from the Parted Magic CD.. (I’ve used screen-shots of Parted Magic Version 5.5 applying labels to a USB connected hard drive in this article, but older versions also work.)

From the Parted Magic boot-menu, select how you want to run Parted Magic. The default selection should be fine for most users. When Parted Magic has started, click on the icon Partition Editor. GParted starts up and scans your drives. (This can take a minute or two if you have quite a few partitions.) Select the drive on which you wish to add partition labels. In Figure 1, below, I’ve shown a 400GByte hard drive with a swap, FAT32 and ext3 partition prior to labelling.

GParted showing Hard Drive Partitions before Labelling

Fig 1 GParted displaying partition information for an unlabelled USB connected hard drive.

Right click in the row of the partition you wish to label or in the relevant partition image at the top (either works) and select “label” from the list of available commands. (Note: If “label’ is greyed out then GParted doesn’t support labelling for the selected partition type.) Type in your chosen label and click on “OK”.

Entering label for FAT32 partition using GParted

Fig 2 Entering label for FAT32 partition using GParted.

Note that you are limited to a maximum of 16 characters (11 for Windows FAT partitions). I recommend you limit your character use to alpha-numerics and the dash and underscore. You can enter upper and lower case alpha characters but they will default to upper case for Windows FAT partitions. Repeat the process for all partitions you wish to label and then lick on Apply in the toolbar. You will now be asked if you want to apply the pending operations and that there is the potential to cause LOSS of DATA. You DO have your important data backed up don’t you? If so, click on Apply, and the partition will be labelled, after which you’ll get a window pop up telling you ‘All operations successfully completed’.

Ready to apply Labels to Partitions

Fig 3 Ready to apply Labels to Partitions

Click on Close. GParted will scan your disks and show the changes you’ve made. The application Mount-gtk may pop up listing all your partitions available for mounting. If so just close it. Close GParted and shut down Parted Magic (Logout from the Menu button on the bottom LHS).

By the way, Parted Magic contains several useful utilities and is worth keeping in your toolbox. For starters, you can check the status of your hard drive(s) with Smart Control to see if a drive is near failure.

Labelling your Swap Partition

From the command line use the mkswap command and specify your label name after the -L flag thus:

# mkswap -L Swap500MB /dev/sdd3

Setting up swapspace version 1, size = 522076 KiB

LABEL=Swap500MB, UUID=7633216d-4a0c-461c-a8c9-9139106025c1

If your swap partition is mounted (check with swapon -s), unmount it as root thus

#swapoff /dev/sdxn

(where x is a, b, c etc and n is the swap partition ID.)

Checking your labelling from within your Linux Distro

You can check your partition labels many ways of which several are shown below:

1. Install and run GParted from within your Distro and select the relevant drive. GParted shows all partition labels, irrespective of partition type.

GParted Showing Labels Applied to Hard Drive

Fig 4 Gparted showing hard drive with labels applied

From the command line:

2.1 $ls -l /dev/disk/by-label

This shows all labelled partitions on your system, mounted or not.

Or if you want to strip all but the labels and the partitions:

$ls -l /dev/disk/by-label |cut -d " " -f 8,9,10

(Try out ls -l /dev/disk/by-uuid and ls -l /dev/disk/by-path also.)

2.2 #cfdisk /dev/sdx

(where x is a, b, c, etc)

To exit cfdisk, tab to [ Quit ] and hit the Enter key or just type “q”.

(Note you may need to install cfdisk on your distribution. Cfdisk doesn’t show labels for swap and Windows partitions, but is much faster to use than GParted if you just want to check the spelling of a Linux partition label.)

How to Use Labelled Partitions

On External Drives

If you are trying to find which flash drive contains your latest PC build photos that you’ve thoughtfully saved on a partition labelled MyRigPhotos, assuming /mnt/tmp exists, you can easily plug in all your flash drives into all available USB slots and mount the partition you are after while root thus:

#mount LABEL=MyRigPhotos /mnt/tmp

Now isn’t that far easier than checking through all your flash drives?

When done, you can unmount the flash drive partition as normal, i.e.

#umount /mnt/tmp

Within fstab

Replacing /dev/sdxn or UUID references within your fstab file makes it easier to maintain and provides a degree of self documentation.

Example fstab entries

#root drive

LABEL=Kubuntu10.04i386 / ext4 errors=remount-ro 0 1

#Originally was:

#/dev/sda2 / ext4 errors=remount-ro 0 1

# Additional entries manually added

LABEL=LinuxData /mnt/LinuxData ext4 rw,user 0 2

LABEL=Multimedia /mnt/Multimedia ntfs-3g defaults,umask=000 0 0

LABEL=SOFTWARE /mnt/SOFTWARE vfat umask=000,iocharset=utf8 0 0

LABEL=swap2G none swap sw 0 0

Changing Grub Menu for Reduced Maintenance

Again, just replace all /dev/sdxn or UUID references with the LABEL= equivalent. One example is provided below:

Original Entry:

title Kubuntu10.04 i386 sdb1

root (hd1,0)

kernel /boot/vmlinuz root=/dev/sdb1 vga=794 showopts resume=/dev/sda5

initrd /boot/initrd.img

Modified Entry:

title Kubuntu10.04 i386 Label Reference

root (hd1,0)

kernel /boot/vmlinuz root=LABEL=Kubuntu10.04i386 vga=794 showopts resume=LABEL=swap2G

initrd /boot/initrd.img

Provided you have the grub partition correct i.e (hd1,0) in this case, your Linux Distro will boot correctly and mount the swap partition, no matter what drives the root and swap partitions are on.


As you can see from the above, partition labels can simplify your use of Linux in daily usage as well as during distro installations and hardware maintenance. Basically, udev allows you to replace the use of “/dev/sdxn” in a Linux command or configuration file with the equivalent form “LABEL=MyLabel”. I hope the above article and included examples have encouraged you to give partition labelling a try and that you find them as useful as I have done. If you’ve found other uses and benefits, then please share them in the comments section.



  1. Thanks for posting this. I had repartitioned disks prior to installing Mint 9 on a multi-boot machine already running Ubuntu 8.04. The repartitioning of course screwed up the /dev/sdxn approach it used, so 8.04 became unbootable. Luckily I had already labeled all partitions. I plan to use the above to fix my 8.04 install and make it bootable once more.

  2. Pingback: Mount disks with UUID or LABEL on Linux « Tournas Dimitrios

  3. FAT volume labels cannot contain the following characters: ? / \ | . , ; : + = [ ] ”

    If the partition you are labeling really is NTFS and not FAT, however, I don’t know why you are having a problem with the “.”. Could you just use NTFS_3-9 and avoid the problem?

Leave a Reply

Your email address will not be published. Required fields are marked *