3

In Linux it is possible to mount a device (disk) by UUID or label. I have used UUID for a while mainly because I was picked up a discussion on IRC that mounting by label was a really horrible idea.

I fail to see why mounting by label would be a bad idea if one would choose a pretty unique label name like 6581_var, 6502_root, 8580_home, DFF180_usr, 68030_boot, BFEC01_WD_Disk05. etc.... ;)

So my questions are:

  1. Why is it a good idea to always mount with UUID?
  2. Why is it a bad idea to always mount with UUID?
  3. Why is it a good idea to always mount with LABEL?
  4. Why is it a bad idea to always mount with LABEL?
  5. Is there a benefit to choose one over the other for systems using systemd ?!
  6. What is more likely to get corrupted. A LABEL or UUID
  7. If a disk for example gets a firmware upgrade can that change the UUID?!
  • 1) and 3) good because it doesn't matter if you create/delete partitions or change SATA/ATA disk channel- partition numbers will be changed and your system still will work properly. 6) both have the same chances to get corrupted. 7) I don't thinks so- UUID has been generated during partition creation and has nothing to do with hardware. – jet Mar 5 '14 at 23:49
5

Answers

  • Q1-4: It's not. Right tool should be used for specific purpose. See below.
  • Q5: System using systemd are developed enough to show no difference.
  • Q6: In common case - neither. They are both stored in the same place (formatting header or so) and changed by the same mechanism.
  • Q7: No. Partition UUID can be only changed directly (see below) or by reformatting (i.e. creating new formatting) the partition.

Actually

Assuming we are talking about partition formatting (e.g. file system) UUID and Label.

There are also partition UUID and Label - commonly referred as partUUID and partlabel - if disk partitioning scheme supports them: e.g. GPT, but not MBR. They are also could be used to identify partition and, in some cases (see below), could an only way to do it.

Both UUID and Label are managed using tools specific to partition formatting used:

  • ext2/3/4: tune2fs
  • FAT: mlabel
  • swap: swaplabel
  • LUKS: cryptsetup luksUUID
  • ...

Please note, both UUID and Label exist only if partition formatting exists (and supported by your kernel) and the formatting supports UUID and/or Label attributes. For example partition encrypted using dm-crypt without LUKS extension does not have UUID and Label as it does not use any header (but file system inside encrypted container could have them both). FAT-family file systems don't support UUID (they have serial number instead), but do support Label.

The main differences between using Label and UUID are:

  • UUID is for lower level
    • created automatically (always exists)
    • managed automatically
    • guaranteed to be unique (in the most cases)
    • not human friendly
  • Label is for higher level
    • should be created explicitly
    • managed manually
    • human friendly (easy to remember and type)

So if you not going to manage labels for partition(s) the choice is obvious - UUID. If you need more flexibility and/or readability for you system configuration - you could use labels.

For example, for cloned or automanaged systems using labels could be more suitable: after system cloned UUID's could change. If not for ext2/3/4 (depends on cloning method), it definitely change for LUKS-encrypted partitions (we need do luksFormat at least to create new encryption key). So using Label in this case could be convenient.

Also Udev rule mounts removable media to /media/<user>/<label> if Label exits. If not - /media/<user>/<UUID> used instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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