There are a few ways to get disk partition UUID (Universally Unique Identifier) in Linux, but some requires installation of additional software or packages.

The following 2 method would normally work on any Linux system.

/dev/disk/by-uuid/

UUID information is normally available in the /dev/disk/by-uuid/ directory. The UUID is a symlink to the device itself. The information can be viewed using the ls command.

$ ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Nov 13 12:54 0AFAADB9FAADA185 -> ../../sda1
lrwxrwxrwx 1 root root 10 Nov 13 12:54 860e4946-19a2-40ee-837a-4eca537b0ec1 -> ../../sda4
lrwxrwxrwx 1 root root 10 Nov 13 12:54 a2b17bd1-3d94-48f5-93a2-c5f0f0fffc70 -> ../../sda2
lrwxrwxrwx 1 root root 10 Nov 13 12:54 d85c31d6-8ccc-45e2-add8-6d44330714c3 -> ../../sda3

blkid

The other method is to use the blkid utility, which is normally installed by default in any Linux system. Specify the device name as an argument to view UUID of specific device, or run it without argument to view UUID information of all disk devices.

$ sudo blkid /dev/sda4
/dev/sda4: UUID="860e4946-19a2-40ee-837a-4eca537b0ec1" TYPE="ext4"
$ sudo blkid
/dev/sda4: UUID="860e4946-19a2-40ee-837a-4eca537b0ec1" TYPE="ext4" 
/dev/sda1: UUID="0AFAADB9FAADA185" TYPE="ntfs" 
/dev/sda2: UUID="a2b17bd1-3d94-48f5-93a2-c5f0f0fffc70" TYPE="ext4" 
/dev/sda3: UUID="d85c31d6-8ccc-45e2-add8-6d44330714c3" TYPE="ext4"

You'll need to use sudo or run as the root user to get the information.

$ blkid --help

Usage:
 blkid --label <label> | --uuid <uuid>

 blkid [--cache-file <file>] [-ghlLv] [--output <format>] [--match-tag <tag>]
       [--match-token <token>] [<dev> ...]

 blkid -p [--match-tag <tag>] [--offset <offset>] [--size <size>]
       [--output <format>] <dev> ...

 blkid -i [--match-tag <tag>] [--output <format>] <dev> ...

Options:
 -c, --cache-file <file>    read from <file> instead of reading from the default
                              cache file (-c /dev/null means no cache)
 -d, --no-encoding          don't encode non-printing characters
 -g, --garbage-collect      garbage collect the blkid cache
 -o, --output <format>      output format; can be one of:
                              value, device, export or full; (default: full)
 -k, --list-filesystems     list all known filesystems/RAIDs and exit
 -s, --match-tag <tag>      show specified tag(s) (default show all tags)
 -t, --match-token <token>  find device with a specific token (NAME=value pair)
 -l, --list-one             look up only first device with token specified by -t
 -L, --label <label>        convert LABEL to device name
 -U, --uuid <uuid>          convert UUID to device name
 <dev>                      specify device(s) to probe (default: all devices)

Low-level probing options:
 -p, --probe                low-level superblocks probing (bypass cache)
 -i, --info                 gather information about I/O limits
 -S, --size <size>          overwrite device size
 -O, --offset <offset>      probe at the given offset
 -u, --usages <list>        filter by "usage" (e.g. -u filesystem,raid)
 -n, --match-types <list>   filter by filesystem type (e.g. -n vfat,ext3)

 -h, --help                 display this help
 -V, --version              display version

For more details see blkid(8).
Leave comments and suggestions:
Share!