blkid: command not found

The blkid command offers similar functionality to lsblk, but it simply prints each block device in a flat format and includes some additional information like device/ partition UUID and file system type. However, it is preferable to use lsblk -f if you want this additional information.

Syntax

The syntax of the blkid command is:

# blkid [options] [device name]

You can easily list the UUIDs of your volumes with the blkid command:

# blkid

The output will show you the UUID of each device attached to your system, and you can use this command any time you add new volumes to your server to list your UUIDs. This is also the first step in adding a new volume to your /etc/fstab file. While I did say that using UUIDs is not required, it’s definitely recommended and can save you from trouble later on.

If you encounter below error while running the blkid command:

blkid: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install util-linux
Debian apt-get install fdisk
Ubuntu apt-get install fdisk
Alpine apk add util-linux
Arch Linux pacman -S util-linux
Kali Linux apt-get install fdisk
CentOS yum install util-linux
Fedora dnf install util-linux
Raspbian apt-get install util-linux

You can also use the blkid utility to check the filesystem type, as shown in this snipped example from an Ubuntu system:

$ sudo blkid
/dev/sda1: [...] TYPE="ext4"
/dev/sda5: [...] TYPE="swap"
/dev/sdb1: [...] TYPE="ext4"
$

This output also shows that the filesystem on /dev/sdb1 is an ext4 filesystem.

blkid Command Examples

1. List all partitions:

$ sudo blkid

2. List all partitions in a table, including current mountpoints:

$ sudo blkid -o list

Conclusion

A UUID is a unique identification number assigned when the partition or volume is formatted using mkfs. You can determine a filesystem’s UUID using either the blkid or the lsblk -f command. Filesystems can be mounted either persistently in the /etc/fstab file using their UUID or temporarily using the -U uuid option on the mount command.

Related Post