Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What will happen to all the remaining partition labels if I remove a single partition?
For example if I have a layout that looks like this:


and if I remove /dev/sda2 will /dev/sda3, /dev/sda4 and /dev/sda5 "shift" their numbers, and am I going to get this:


or will the "gap" stay there without any changes for the labels, giving me this:

share|improve this question
up vote 8 down vote accepted

Traditionally, Linux on x86 hardware has used MSDOS partition tables. In this case, removing /dev/sda2 won't shift any of the higher numbered partitions down, because the primary partitions act like "slots": you can use them in any order you like, and removing one doesn't affect any of the others.

If instead you had sda{1-7} with sda4 being the extended partition and sda{5-7} being logical partitions within that extended partition, deleting sda6 would shift sda7 down. Logical partitions simply behave differently in this regard.

Newer versions of Linux are switching to GPT partition tables instead, though this is a slow process since there are limitations that prevent wholesale switching at this time.

In the GPT case, you don't need to use extended partitions to get more than 4 partitions on a single disk, and like MSDOS primary partitions, GPT partition numbers work like slots. You can delete a partition from the middle of a range and only leave a hole, with the existing partitions keeping their number. If you then create a new one, it fills the hole.

Your question asks about partition labels, however, and nothing I've talked about so far has anything to do with labels. Partition labels, in the sense used in Linux, are attributes of the filesystem, not the partition table. They exist to prevent changes to device names from causing problems with mounting filesystems. By using filesystem labels, you don't have to worry about device name changes because you're mounting partitions by label, not by device name. This is particularly helpful in cases like USB, where the device naming scheme is dynamic, and depends in part on what has been plugged in previously since the last reboot.

Linux mkfs.* programs typically use the -L flag to specify the label.

To mount a partition by label instead of by device name, use LABEL=mypartname in the first column of /etc/fstab. If you check your current /etc/fstab, you'll probably find that there are already partitions being mounted that way. Linux GUI installers typically do this for you as a convenience.

You can mount a filesystem by label interactively, too, by passing the label with -L to mount(8).

GPT does allow you to name a partition, but I don't know that it has anything to do with anything discussed above.

EDIT: One thing you do get with GPT which is relevant here, however, is a unique identifier for each partition, called a UUID. They work similarly to labels, but are different in several ways:

  1. UUIDs are automatically assigned pseudorandom numbers, rather than a logical name you pick yourself.

  2. You use -U instead of -L to mount(8) a partition by UUID rather than by label.

  3. You use UUID=big-ugly-hex-number instead of LABEL=mynicelabel in /etc/fstab.

  4. They are attributes of the partition, not the filesystem, so they will work with any filesystem as long as you can use GPT. A good example is a FAT32 partition on a USB stick: FAT32 doesn't have a filesystem label, and since it's on a USB stick you can't reliably predict which /dev/sd* name it will get.

share|improve this answer
hmm, ok so I think I maybe used the wrong term in my question. I was referring to sda{1-7} and not to user-generated "LABEL=mypartname". anyway, how do I know if I use the first or the second case that you described? I mean, I know I have 2 primary and 4 or 5 logical partitions (which leads to conclusion of your second case), but I also know that it's all written to the /dev/sda -> which is MBR.. (which leads to conclusion of your first case). I guess it's probably the second case? – pootzko Aug 23 '11 at 10:52
/dev/sda2 must be a primary partition, since logical partitions get numbers beginning with 5, no matter which parition number you used for the extended partition. So, your issue should be covered by the first case: removing /dev/sda2 should cause no renumbering. And again, using UUIDs or labels will avoid the need to worry about this entirely. – Warren Young Aug 23 '11 at 11:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.