Skip to content

What is blkid Linux command?

The Linux blkid command is used to locate or print block device attributes such as label, UUID, or file system type. It helps in identifying storage devices connected to the system.

blkid Syntax:

Terminal window
blkid [options] [device|label|UUID]

blkid Options:

OptionDescription
-c Read cache from the specified file
-o Output in the specified format
-s Comma-separated list of items to display
-gUse the e2fsprogs ext2/ext3 UUID
-p Look in the specified directory for devices
-tProbe for filesystems only
-u Comma-separated list of items to update in the cache
-lList known filesystems

Parameters:

ParameterDescription
[device]Specify the device to query for
[label]Search for devices by label
[UUID]Search for devices by UUID

blkid Command Usage Examples:

Display Information of a Specific Device

Terminal window
blkid /dev/sda1

This command displays the information of a specific block device (/dev/sda1).

Display All Block Device Information

Terminal window
blkid

Executing this command will display information about all block devices on the system.

Show UUID of a Specific Device

Terminal window
blkid -s UUID /dev/sda1

Displays only the UUID of the specified block device (/dev/sda1).

Display only Filesystem Type of Devices

Terminal window
blkid -s TYPE

This will list the filesystem types of all block devices on the system.

Display Information in JSON Format

Terminal window
blkid --output=json

Formats the output of blkid command in JSON format for easy parsing and integration with other tools.

How do I use blkid in Linux?

To use the blkid command in bash, execute the following command:

Terminal window
blkid

How to list only specific device information with blkid?

To list specific device information like UUIDs and labels, use the following command:

Terminal window
blkid /dev/sda1

How can I display only UUIDs of block devices using blkid?

To display only the UUIDs of block devices using blkid, run the following command:

Terminal window
blkid -o value -s UUID

How do I force blkid to read devices even if they are in use?

To force blkid to read devices even if they are in use, use the following command:

Terminal window
blkid -p

How to display information about filesystems with blkid?

To display detailed information about filesystems, use the following blkid command:

Terminal window
blkid -s TYPE

How can I show empty partitions with blkid?

To display information about empty partitions using blkid, run the following command:

Terminal window
blkid -p -u unmounted

How to ignore specific devices using blkid?

To ignore specific devices like CD-ROMs and loop devices when running blkid, use the following command:

Terminal window
blkid -t TYPE=TYPE_TO_IGNORE

How do I save blkid output to a file?

To save blkid output to a file, use the following command:

Terminal window
blkid > blkid_output.txt

Applications of the blkid Command

  • Retrieving information about block devices
  • Displaying UUIDs and file system types
  • Finding information about partitions and storage devices
  • Identifying device attributes
  • Automating tasks in shell scripts