blkid Command in Linux to Find Block Devices Details

Last updated: June 21, 2022 | Linuxopsys

The blkid program is a command-line utility that displays information about available block devices. It can determine filesystem types (like ext4 or swap) and display key metadata attributes (tokens) such as UUIDs and LABELs.

The bikid tool is part of the util-linux package, which includes various utilities for managing your system.

Basic Usage

Simply running blkid without any argument it will display information about all available block devices in the system. The information typically includes the device name, its UUID (Universally Unique Identifier), TYPE (filesystem type), and optionally, the LABEL (if set).


blkid without any argument

Here are the principal attributes blkid can obtain:

  • UUID: Universally Unique Identifier.
  • TYPE (Filesystem Type).
  • LABEL: Human-readable label.

Other attributes like PARTUUID, PARTLABEL, UUID_SUB, or BLOCK_SIZE may also be displayed depending on the device and filesystem.


Let's look into some useful examples of blkid command.

1. List Specific Block Device

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

2. Lookup by UUID

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 -U option like this:

blkid -U d3b1dcc2-e3b0-45b0-b703-d6d0d360e524
bilkid UUID

To display only the UUIDs of all block devices:

$ blkid -s UUID
/dev/sdb: UUID="0346c46b-bd50-4f7f-8aef-2cac6d3dec15"
/dev/sda: UUID="8654faf8-c54a-2d86-f082-73098653e58f"

To find device with a specific UUID:

$ blkid -t UUID="0346c46b-bd50-4f7f-8aef-2cac6d3dec15"
/dev/sdb: UUID="0346c46b-bd50-4f7f-8aef-2cac6d3dec15" TYPE="swap"

3. List of all devices and their attributes

$ blkid -o list
device                   fs_type    label       mount point                  UUID
/dev/sdb                 swap                   [SWAP]                       0346c46b-bd50-4f7f-8aef-2cac6d3dec15
/dev/sda                 ext4       linode-root /                            8654faf8-c54a-2d86-f082-73098653e58f
/dev/loop4               squashfs               /snap/snapd/20092
/dev/loop2               squashfs               /snap/core22/864
/dev/loop0               squashfs               /snap/core22/858
/dev/loop3               squashfs               /snap/radare2/2460
/dev/loop6               squashfs               /snap/radare2/2467
/dev/loop5               squashfs               /snap/snapd/20290

4. Output udev-compatible key-value pairs for a particular device:

blkid -po udev /dev/sda1
blkid -po option

This command displays it in the udev key-value pair format directly from the device /dev/sda1. The -p option tells blkid not to check the device in the cache but reads information directly from the device.

Remember: As it reads directly from the device, the blkid command needs root privilege to run.

5. List devices that are of the 'ext4' type

 $ blkid -t TYPE=ext4
/dev/sda: LABEL="linode-root" UUID="8654faf8-c54a-2d86-f082-73098653e58f" BLOCK_SIZE="4096" TYPE="ext4"

6. Clear blkid cache

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 that no longer exist.

blkid -g


Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment