Linux blkid Command to Find Block Devices Details

The blkid program is a command-line utility that displays information about available block devices. It can determine the type of content (e.g. filesystem, swap) a block device holds and also attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields).

In this tutorial we learn about blkid command in Linux and how to use it to find UUIDs.

blkid usage

Simply running blkid without any argument will list all the available devices with their Universally Unique Identifier (UUID), the TYPE of the file-system and the LABEL if it's set.

# blkid
blkid

Listing device UUID

If you wish to have information displayed only for a specific device you can use the device name as an option after blkid to do so:

# blkid /dev/sda1

Also if you know the UUID of a device but don't know the device name and wish to find it out you can use the 0-U option like this:

# blkid -U d3b1dcc2-e3b0-45b0-b703-d6d0d360e524
blkid uuid

If you wish to obtain mode detailed information you can use the -p and -o udev option to have it display in a nice format like this:

# blkid -po udev /dev/sda1
blkid -po

Sometimes the device list might not be updated, if you think this is the case you can use the -g option that will perform a garbage collection pass on the blkid cache to remove devices which no longer exist.

# blkid -g

Conclusion

In this tutorial, we learned blkid command and how to use it to list block device details. Blkid is mainly used to list disk/partitions UUID.

Leave a Comment