Find Disk Partition Uuid on Linux
The disk partition UUID is used to address hard disk partitions on linux in various places like the fstab
file. But how do you find them in the first place?
Using the list command
This is the quickest and easiest way as the ls
command is always found on every linux system by default.
ls -l /dev/disk/by-uuid/
Example:
$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 9 Feb 27 06:29 2020-10-22-14-30-30-00 -> ../../sr0
lrwxrwxrwx 1 root root 10 Feb 27 06:23 9B8B-2022 -> ../../sda2
lrwxrwxrwx 1 root root 10 Feb 27 06:23 a7d71686-0a65-4402-b6e6-b58430ef8351 -> ../../sda3
Using blkid
blkid
is installed by default in most Linux distributions. Use the following command to find the UUIDs of all the partitions on a system:
blkid
Example:
$ blkid
/dev/sda3: UUID="a7d71686-0a65-4402-b6e6-b58430ef8351" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0ea90c96-1b56-4c51-b07a-02e09285f291"
/dev/sr0: BLOCK_SIZE="2048" UUID="2020-10-22-14-30-30-00" LABEL="Ubuntu 20.10 amd64" TYPE="iso9660" PTTYPE="PMBR"
Use the following to find the UUID of a specific partition:
blkid <partition>
Example:
$ blkid /dev/sda3
/dev/sda3: UUID="a7d71686-0a65-4402-b6e6-b58430ef8351" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0ea90c96-1b56-4c51-b07a-02e09285f291"