-1

I'm following a recipe I created a couple of years ago, where at one point I need to use blkid to obtain a filesystem UUID.

I have this command noted, along with an expected example return value:

blkid -o export -s UUID /dev/mapper/thathost_crypt_md3
UUID=JNbF5T-vhSD-3aVv-intG-1Tk2-IEOZ-ABWXYZ

However, times have moved on and I'm no longer using Debian "wheezy" but instead "jessie". I see that on this more recent version of Debian I now have a different return value for the same command:

blkid -o export -s UUID /dev/mapper/thishost_crypt_sdb
DEVNAME=/dev/mapper/thishost_crypt_sdb
UUID=bddac63e-3510-4d24-a6fb-4d0a89abcdef

The man page for blkid seems to say that -s UUID should include only values matching that key, yet there's this extraneous DEVNAME in there, too.

I have a work-around, in that I can write this in both cases, but it seems strange the output structure should have changed:

echo "UUID=$(blkid -o value -s UUID /path/to/device)"
UUID=bddac63e-3510-4d24-a6fb-4d0a89abcdef

Package util-linux versions are 2.20.1-5.3 and 2.25.2-6, respectively.

Questions

  1. Why the change in UUID shape, and does it matter?
  2. Why the change in the output format?
  • 1
    I checked on the latest Gentoo with util-linux 2.28.2 as well as CentOS 6 with util-linux-ng 2.17.2 and I see the same difference as you do. I can see there have been other parameter changes in between those version such as the version parameter changed from -v to -V. Your solution seems consistent with the syntax changes done. – Julie Pelletier Apr 21 '17 at 16:10
2

DEVNAME is the alias of the device see Persistent device name using alias

Furthermore, it seems UUID is now required to be lowercase by International standards.

From Type of Character generated by UUID

To clarify, a UUID is actually a 128-bit value, not text or digits. You could think of them as 128-bit unsigned integers.

The latest international spec dated 2008-08 states (emphasis mine):

6.5.4 Software generating the hexadecimal representation of a UUID shall not use upper case letters. NOTE – It is recommended that the hexadecimal representation used in all human-readable formats be restricted to lower-case letters. Software processing this representation is, however, required to accept both upper and lower case letters as specified in 6.5.2.

As for printing the UUID and the alias/DEVNAME

From util-linux/blkid.c is evident that DEVNAME is printed because you are using the -o export

} else if (ctl->output & OUTPUT_EXPORT_LIST) {
        if (num == 1 && devname)
            printf("DEVNAME=%s\n", devname); 

So I suspected that without -o export it would only print the UUID, and indeed:

$blkid -s UUID /dev/sda2
/dev/sda2: UUID="67169dd7-f319-4402-a9b2-cebcf2f3657a"
$ blkid -o export -s UUID /dev/sda2
DEVNAME=/dev/sda2
UUID=67169dd7-f319-4402-a9b2-cebcf2f3657a
| improve this answer | |
  • @roaima Added to the question. – Rui F Ribeiro Apr 21 '17 at 18:33
  • 1
    Problem with omitting -o export is that the output format is of little use to me (I wanted the original UUID=abc...xyz style of output). I can either get two lines, one of which is the unwanted DEVNAME=... or I can have the UUID value which I then have to prefix with UUID=. The earlier revision of the program seems to have got it right and the newer version wrong. IMO, of course. – roaima Apr 21 '17 at 23:13
  • @roaima There are clearly changes #define OUTPUT_PRETTY_LIST (1 << 3) /* deprecated */ – Rui F Ribeiro Apr 22 '17 at 0:08
  • 1
    So you're saying it's an intentional upstream code-change? Thank you. Appreciated. – roaima Apr 22 '17 at 7:40

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.