6 UNIX / Linux blkid Command Examples for Block Device Attributes

Using blkid command you can view attributes of block devices that are on your system.

This is a quick way to find the type of the block devices on your system.

This uses the libblkid library to get the values.

1. Basic usage

The following is an example of basic blkid command usage.

In this example, it will display all the block devices that are on your system.

In this output, it displays 5 partitions. 3 of them are ext2 partitions, one if ext4 partition, and another one is swap partition.

# blkid
/dev/sdb1: UUID="6e0acfe3-81ed-4f9f-8ab5-0d65ba1f0ef2" TYPE="ext2"
/dev/sdc1: UUID="aa82d7bb-ab2b-4739-935f-fd8a5c9a6cb0" TYPE="ext2"
/dev/sda1: UUID="187171ab-c9b8-43ec-b0bb-77c736ca22e0" TYPE="ext4" LABEL="/home"
/dev/sda2: UUID="1a225baa-7027-4619-aaa5-900e24c1fdff" TYPE="swap"
/dev/sdb3: UUID="2a294b33-eb61-40a3-b3fc-ad6eaf7f156f" TYPE="ext2"

2. View I/O Limits

Use the -i option as shown below to display the I/O limits on a particular block device.

You can either pass the partition as an argument, or the whole device.

The following output displays the minimum IO size, physical and logical sector size of /dev/sdb1 device.

# blkid -i /dev/sdb1

3. Display Additional Information

The -p option will display additional information, as it will not use the cache, and directly use the information from the superblock

The following displays information about /dev/sdc. Please note that for this option, you should pass a device name as an argument.

# blkid -p /dev/sdc
/dev/sdc: UUID="GUfYPj-C6q8-Ubsb-76Ha-FDFK-vaJm-B5wWgQ" VERSION="LVM2 001" TYPE="LVM2_member" USAGE="raid"

You can also combine -p and -i option to get additional information about the device as shown below.

# blkid -pi /dev/sdc

4. Search for Parameters

You can use -l option to look up the devices that matches a specific search criteria.

When you specify -l option, you should also specify the -t option and indicate what kind of parameter and value are you are searching for.

In the following example, we are searching for the LABEL parameter that has the value “/home”.

# blkid -l -t LABEL=/home
/dev/sda1: UUID="187171ab-c9b8-43ec-b0bb-77c736ca22e0" TYPE="ext4" LABEL="/home"

In the following example, we are searching for TYPE parameter that ahs the value “ext2”.

# blkid -t TYPE=ext2
/dev/sdb1: UUID="6e0acfe3-81ed-4f9f-8ab5-0d65ba1f0ef2" TYPE="ext2"
/dev/sdc1: UUID="aa82d7bb-ab2b-4739-935f-fd8a5c9a6cb0" TYPE="ext2"
/dev/sdb3: UUID="2a294b33-eb61-40a3-b3fc-ad6eaf7f156f" TYPE="ext2"

5. Use -L and -U for additional Search

Please note that the label search can also be directly done using -L option (instead of combining -l and -t option)

# blkid -L /home

You can also search based on UUID as shown below.

# blkid -U 6e0acfe3-81ed-4f9f-8ab5-0d65ba1f0ef2

6. Format the blkid Output

Use -o option to format the output of the blkid command. By default -o uses “full” format. So, both of the following command will display the same output format.

# blkid

# blkid -o full

I’ve found the “list” format option is very helpful. This will also display the “mount point” column which is very helpful.

# blkid -o list
device     fs_type label  mount point    UUID
/dev/sdb1  ext2           (not mounted)  6e0acfe3-81ed-4f9f-8ab5-0d65ba1f0ef2
/dev/sdc1  ext2           (not mounted)  aa82d7bb-ab2b-4739-935f-fd8a5c9a6cb0
/dev/sda1  ext4    /home  /              187171ab-c9b8-43ec-b0bb-77c736ca22e0
/dev/sda2  swap           <swap>         1a225baa-7027-4619-aaa5-900e24c1fdff
/dev/sdb3  ext2           (not mounted)  2a294b33-eb61-40a3-b3fc-ad6eaf7f156f

The following are other output format options:

# blkid -o value

# blkid -o device

# blkid -o udev

# blkid -o export

Comments on this entry are closed.