14

I've followed the procedure in the raspberry pi forums to make my Raspberry Pi 3 use an USB key instead of the SD card as root filesystem in the hope to make it more robust to power loss.

The process worked, but I lost time because I confused UUID and PARTUUID for partition (use blkid and see how they can be different). What's the purpose of both? It was simpler to fix my confusion by using UUID instead of PARTUUID everywhere, but that failed, I had to use PARTUUID (I think it would have been possible to use a mix, but I didn't try to search for one).

Note that the cited page hints that the UUID is for the drive is PARTUUID for the partition, but then I'd expect that the UUID be the same for all partitions of a drive, that's not the case.

  • 1
    Hi AProgrammer, and welcome to the Raspberry Pi stack exchange. I think you should consider that this isn't a question about Raspberry Pi! More people would see this question (both to answer it and to benefit from answers offered) if it were in, perhaps, the main Linux forum. – Tai Viinikka Nov 10 '17 at 16:47
  • @TaiViinikka, I admit having hesitated between this and unix.se, but considering that I met the issue with a raspberry pi and that I never met the issue after having working with debian and debian derived distributions for 23 years on x86, including UUID without meeting it -- my reflexes were part of the cause of my issue --, I though that there could be a relationship with raspberry pi. – AProgrammer Nov 10 '17 at 17:01
  • That's quite understandable and I'm glad you got an answer. My [much briefer] experiences have been different from yours; every partition I have has mismatched UUID and PARTUUID: root@herald:~# cat /proc/cpuinfo vendor_id : GenuineIntel model name : Intel(R) Atom(TM) CPU D2550 @ 1.86GHz root@herald:~# blkid /dev/sda1: LABEL="Boot" UUID="e92827af-6c5d-4438-b22a-8f9b3b4dc4f0" TYPE="ext4" PARTUUID="44e5688f-01" And so I reached the opposite conclusion. – Tai Viinikka Nov 21 '17 at 19:32
13

On Difference between UUID and PARTUUID

You can get a few hints about the difference between UUID and PARTUUID by specifying the -p option.

blkid -p /dev/sda1

or whatever device/partition you are looking at. You may have noticed that if there are multiple partitions on the same UUID device, the PARTUUID is mostly the same with the partition number appended.

A UUID is guaranteed to be unique. As far as I know, collisions will not happen within the lifetime of the universe. However, you'll note that the PARTUUID is much shorter. These are meant to be "locally" unique, and collisions most likely occur between all known PARTUUIDs.

On UUIDs

A UUID is simply a unique identifier. They are used for many different purposes. You can generate them using the uuidgen function.

For further reading about UUIDs:

$man uuidgen 

Or Internet:

manpage for uuidgen

Some more UUID use examples

$cat /etc/fstab

For newer GNU/Linux systems, you'll have a list of all the partitions and their UUIDs. A new UUID is generated for each new partition. So, if re-partition a given drive, all the blkid UUIDs for that drive will change.

Part of the reason UUIDs are used as identifiers of partitions and drives is to maintain identifiers even when drives are added or mounted in a different order. In a prior time, the fstab would have identifiers such as /dev/sda1 ... This had the disadvantage of possibly having sda1 be a physically different drive or partition if somehow the mount order was changed.

On PARTUUIDs

PARTUUIDs are a component of GUID Partition Tables (GPT) which are a replacement for Master Boot Record (MBR) related disk partitioning.

For further reading see Linux.com - Using the New GUID Partition Table in Linux

Linux.com says:

The GPT GUIDs (Globally unique identifiers) and our familiar Linux UUIDs (Universally Unique Identifiers) are not the same thing, though they serve the same useful purpose: giving block devices unique names. Linux UUIDs are a function of filesystems, and are created when the filesystem is created. To see Linux UUIDs just fire up the blkid command Note the Partition GUID code, and how it says "Microsoft basic data." Yeah, ole Microsoft always party-crashing, because this an EXT4 partition, so there is no way for Windows to read it, but will see it as an unformatted partition. You won't see this with current releases of gdisk, because until 2011 there were no Linux filesystem GUIDs. Now there are, so if you're not using an old Linux like mine (Mint 13) you'll see a proper Linux GUID instead (0FC63DAF-8483-4772-8E79-3D69D8477DE4).

The Partition unique GUID is what you'll use in fstab, like this:

PARTUUID=8C208C30-4E8F-4096-ACF9-858959BABBAA /data ext4 user,defaults 0 0

  • The mystery deepen. Looking at several block devices, there is a device PTUUID and there is a UUID and a PARTUUID per partition; depending on the disk and probably the tool which formated and partitioned it, the PARTUUID are derived from the disk PTUUID or not. My question was about the partition UUID which you can get along with the PARTUUID with blkid. – AProgrammer Nov 10 '17 at 17:15
  • @AProgrammer: Added some information to my answer. – RubberStamp Nov 10 '17 at 18:16
  • 1
    Ok, in summary, there is a disk UUID that you can get with blkid -p which call it PTUUID, there is a partition UUID that blkid calls PARTUUID and some file system have an UUID that blkid calls UUID. I'm still unclear why I had to use the PARTUUID instead of the UUID, at least in some places, when moving the root file system to an USB key on the raspberry when my Linux system only reference UUID, but I'm not volunteering to make some more tests and check where there is really a need for PARTUUID and where I could still use the UUID if I wanted but I guess that only cmdline.txt needs it. – AProgrammer Nov 11 '17 at 17:31
  • I have two partitions on two different disks with the same UUID. So much for "lifetime of the universe"... – étale-cohomology Nov 11 at 19:14
3

As I understand it.

The term UUID in general refers to a "Universally unique identifier", known in the windows world as a GUID. There are a few different schemes but for the most part modern UUIDs/GUIDs are essentially a big random number or hash and a few flag bits.

In the specific case of mounting filesystems on linux "UUID" reffers to a unique identifier that is part of the metadata stored inside the filesystem. "PARTUUID" refers to a unique identifier for a partition stored in or derived from the partition table.

These unique identifiers may or may not be actual UUIDs. As far as I can tell.

  • For GPT partition tables the "PARTUUID" is the GUID from the GPT partition table.
  • For MBR partition tables the "PARTUUID" is formed by concatenating the disk identifier with the partition number
  • For EXT4, Linux swap, BTRFS and probablly other linux-native filesystem types the "UUID" is a UUID stored in the filesystem metadata.
  • For FAT and NTFS the "UUID" appears to be the volume serial number, 32 bits for FAT and 64 bits for NTFS.

Note that support for mounting the root filesystem by "UUID" and "PARTUUID" varies. IIRC the kernel running without an initrd can mount by "PARTUUID" but not by "UUID". Older versions of initramfs-tools can mount by "UUID" but not "PARTUUID", recent initramfs-tools supports both.

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.