Where does blkid get its information from? (/dev/block/ showing up in blkid output)

Locane asked:

I have a CentOS 7 box that is acting very strangely. On first boot, typing “blkid” produces:

[BurnC7 (2015-12-17 22:00:25) ~]# blkid
/dev/block/8:3: UUID="c83f7479-4bc1-44e5-84ae-e38a83e75219" TYPE="ext4"
/dev/block/8:2: UUID="2a5bfdfb-2b1d-4748-96bd-fe919b132ce4" TYPE="ext4"
/dev/block/8:5: UUID="94be252f-51df-44cf-afde-57214a08d149" TYPE="swap"
[BurnC7 (2015-12-17 22:00:26) ~]#

I’m looking for a UUID -> /dev/sdX device name marriage, which is the normal output. Further puzzling, specifying a partition I KNOW exists from lsblk, typing “blkid /dev/sda2”, for example, it now shows up in the regular “blkid” output:

[BurnC7 (2015-12-17 22:00:26) ~]# blkid /dev/sda2
/dev/sda2: UUID="2a5bfdfb-2b1d-4748-96bd-fe919b132ce4" TYPE="ext4"
[BurnC7 (2015-12-17 22:02:31) ~]# blkid
/dev/block/8:3: UUID="c83f7479-4bc1-44e5-84ae-e38a83e75219" TYPE="ext4"
/dev/block/8:2: UUID="2a5bfdfb-2b1d-4748-96bd-fe919b132ce4" TYPE="ext4"
/dev/block/8:5: UUID="94be252f-51df-44cf-afde-57214a08d149" TYPE="swap"
/dev/sda2: UUID="2a5bfdfb-2b1d-4748-96bd-fe919b132ce4" TYPE="ext4"
[BurnC7 (2015-12-17 22:02:33) ~]#

Even stranger STILL is that after a reboot, the blkid output now looks fine:

[BurnC7 (2015-12-17 22:04:35) ~]# blkid
/dev/sda2: UUID="2a5bfdfb-2b1d-4748-96bd-fe919b132ce4" TYPE="ext4"
/dev/sda3: UUID="c83f7479-4bc1-44e5-84ae-e38a83e75219" TYPE="ext4"
/dev/sda5: UUID="94be252f-51df-44cf-afde-57214a08d149" TYPE="swap"
[BurnC7 (2015-12-17 22:04:37) ~]#

So obviously, blkid is getting bum information from somewhere – but where?

Is there a more reliable method to get UUID -> /dev/ device name relationships?

Edit: As suggested by Michael Hampton below, “ls -l /dev/disk/by-uuid/” works, even when blkid doesn’t (this is on a different unit than the examples above):

[BurnC7 (2015-12-18 12:00:40) ~]# blkid
/dev/block/8:3: UUID="ac2e5bb8-76d9-47e1-b5f7-3b91fad9e35f" TYPE="ext4"
/dev/block/8:2: UUID="6de21dfd-956d-4593-a8f2-88eeed2198f8" TYPE="ext4"
/dev/block/8:5: UUID="f6c41a22-f962-4b71-b880-54c8afb49516" TYPE="swap"
[BurnC7 (2015-12-18 12:00:41) ~]# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Dec 18 11:41 6de21dfd-956d-4593-a8f2-88eeed2198f8 -> ../../sda2
lrwxrwxrwx 1 root root 10 Dec 18 11:41 ac2e5bb8-76d9-47e1-b5f7-3b91fad9e35f -> ../../sda3
lrwxrwxrwx 1 root root 10 Dec 18 11:41 f6c41a22-f962-4b71-b880-54c8afb49516 -> ../../sda5
[BurnC7 (2015-12-18 12:00:47) ~]#

My answer:


To find devices by UUID, you can look in /dev/disk/by-uuid.

For example:

# ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 10156170545889643033 -> ../../dm-6
lrwxrwxrwx. 1 root root  9 Dec 18 10:43 2bcef3fa-e55c-4aaa-922b-9bc142de041f -> ../../sdc
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 4fa98e08-de06-4baf-9e63-6c2bde67f75e -> ../../sda3
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 5166-F80B -> ../../sda1
lrwxrwxrwx. 1 root root  9 Dec 18 10:43 608464c3-d505-4829-bce3-520a74883c22 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Dec 18 10:43 6aebf7e8-55cc-4684-92bf-e17d8fc23dd6 -> ../../sdd
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 825aa99c-a2ef-4d4a-b739-663b58b47da8 -> ../../dm-2
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 8995619969489110662 -> ../../dm-5
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 b738c1d5-eb9b-4468-bb0c-573ceaafe485 -> ../../sda2
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 c9a0f6de-7ac5-4858-a8b3-d7312d35acbb -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 d4c56b9b-f99a-492d-a04d-749c35d556a7 -> ../../sda5
lrwxrwxrwx. 1 root root 10 Dec 18 10:43 d693f2b3-b9cf-42a6-9383-9bd62e70804c -> ../../sda4

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.