Linux blkid Command: Find Block-Device UUIDs and Filesystem Types

`blkid` queries identification information such as the file system type, UUID, and label recorded on a block device. It is used to check mount settings or device identifiers.

UUID is a value that identifies the file system and is less sensitive to changes in the connection order than the device path. `TYPE` refers to the type of the file system, and `LABEL` refers to the assigned name. Some devices may not be displayed depending on permissions or cache status, and cloned file systems can have duplicate UUIDs.

Basic syntax

blkid [options] [device]

The installed implementation and options may vary depending on the distribution. Check the description for the current system with `man blkid`.

Examples

Query recognizable devices

Displays identification information for devices that can be queried.

sudo blkid

Query a specific partition

Replace the device name with the actual path checked using lsblk.

sudo blkid /dev/sdb1

Extract only UUID values

Check the values to be used in the configuration file in a single line.

sudo blkid -s UUID -o value /dev/sdb1

Checking UUID and Filesystem Type

blkid queries the UUID, filesystem type, label, and other information of block devices. Depending on permissions or cache status, some information may not be visible to regular users.

sudo blkid /dev/sda2

Example output (identifiers are for illustration purposes):

/dev/sda2: UUID="11111111-2222-3333-4444-555555555555" TYPE="ext4"

UUID is useful for referring to the same filesystem even if the device name is rearranged, so it is often used in /etc/fstab. However, creating a new filesystem or cloning it may result in a different or duplicate UUID. Before copying settings, check the actual target device's UUID along with the mount relationship.

Main Options and Format

Options/Format Description
-s tag Select only specific tags like UUID/TYPE.
-o format Specify the output format. 'value' outputs only the value.
-L label Find devices that match the label.
-U UUID Find devices that match the UUID.
-p Perform a low-level check.

Precautions when using

Right after cloning a device, the UUID may be duplicated, so do not rely solely on the UUID when performing write operations. Even if the output under regular user permissions is empty, it does not necessarily mean that the device or file system is absent. Before actual formatting or mounting, double-check the device size and mount status.

Frequently Asked Questions

Are the UUID and PARTUUID from blkid the same?

No. The UUID is mainly a file system identifier, while the PARTUUID is a partition identifier assigned in the partition table.

Official Documentation

The exact behavior of the options and implementation differences can be checked in the official blkid documentation.