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.
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.)
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
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
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
Print the list of block devices having LABEL value as SYSTEM
blkid -t 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
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.
Contact Us