Examples of blkid command in Linux

blkid has two main forms of operation: either searching for a device with a specific NAME=value pair, or displaying NAME=value pairs for one or more specified devices.

Display information of all block devices on your system using blkid command.

To display a list of all the block devices in your system enter the following command in the terminal.

blkid

If all block devices are not listed try re-executing the command in sudo mode.

sudo blkid

You will see a list of names of all block devices along with their information printed in the terminal.

list of all block devices with their types

Display information of a single block device using blkid command.

To display information about a single block device add its name after the command.

blkid /dev/nvme0n1p1

This commands prints the attributes of the block device mentioned. (Note: The name of the block device you entered should be present on your system.)

attributes of a single block device

Formatting command output using blkid command.

blkid command comes with multiple options to alter the behaviour of the command ouput. You can use the -o option along with some predefined value to modify the output of the command.

Print list of all block device names on your system

blkid -o device

list of block devices names

Print all devices with their attributes in a tabular format.

blkid -o list

Print a list of file available file system type using blkid command.

Enter the following command to print all the available filesystem types on your system.

blkid -k

list of all file_system types

Search devices with matching attribute names using blkid command.

You can also search for block device by matching attributes such as TYPE, LABEL or UUID using the -t (–match-token) option.

Find all block devices of TYPE ext4 using the following command:

blkid -t TYPE=ext4

list of block devices of type ext4

Print the list of block devices having LABEL value as SYSTEM

blkid -t LABEL=SYSTEM

list of block devices having label SYSTEM

Print block device having UUID value BADE8EBBDE8E6F85. Since UUID is unique only one block device will be listed in the output.

blkid -t UUID=BADE8EBBDE8E6F85

block device with UUID value BADE8EBBDE8E6F85

blkid Command Examples in Linux

blkid is a command to locate or print block device attributes. A block device can be a hard drive, solid-state drive (SSD), or removable storage device, such as a USB drive. It can determine the type of content (e.g., filesystem or swap) that a block device holds, and also the attributes (tokens, NAME=value pairs) from the content metadata (e.g., LABEL or UUID fields). The blkid command is part of the util-linux package. You need a Linux terminal to use this command.

Similar Reads

Syntax of `blkid` Command in Linux

blkid [OPTIONS] [DEVICE_NAME]...

Options available in `blkid` Command in Linux

Here is a list of some common options for the blkid command:...

Examples of blkid command in Linux

blkid has two main forms of operation: either searching for a device with a specific NAME=value pair, or displaying NAME=value pairs for one or more specified devices....

Conclusion

In this article we discussed the blkid command in Linux which is a crucial tool for identifying and displaying attributes of block devices, including hard drives and USBs. With options like listing filesystems, formatting output, and searching devices based on attributes, blkid provides a versatile solution for users managing storage devices from the Linux terminal. Its flexibility and functionality make it an essential resource for efficiently obtaining information about block devices on a system....

Contact Us