Universally Unique IDentifier or UUID is a random 128-bit value that's generated and assigned to partitions or block devices. The partitions or block devices could then be identified using UUID instead of the normal device name such as /dev/sda1. This can then be used to mount filesystem via /etc/fstab by specifying UUID value in block special device (the first field).

UUID normally is just symlinks to the actual device name and could be manually found within the /dev directory. You could also use specific program to get UUID for partitions or block devices from the terminal in Linux.

Steps to get disk partition UUID in Linux:

  1. Launch terminal.
  2. List content of /dev/disk/by-uuid/ via ls using long listing format.
    $ ls -l /dev/disk/by-uuid/
    total 0
    lrwxrwxrwx 1 root root  9 Aug 22  2019 2019-04-16-20-20-34-00 -> ../../sr0
    lrwxrwxrwx 1 root root 10 Aug 22  2019 84a42ad4-c261-4ed7-a428-33f648f959df -> ../../sda2

    The absolute path for ../../sda2 is /dev/sda2

  3. Run blkid command.
    $ sudo blkid
    /dev/sr0: UUID="2019-04-16-20-20-34-00" LABEL="Ubuntu-Server 19.04 amd64" TYPE="iso9660" PTUUID="73a9f942" PTTYPE="dos"
    /dev/sda2: UUID="84a42ad4-c261-4ed7-a428-33f648f959df" TYPE="ext4" PARTUUID="c373394c-81af-4e90-985e-1a51805cdf57"

    blkid is installed by default in most Linux distributions.

    More options for blkid:

    $ blkid --help
     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> ...
     -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).
Discuss the article:

Comment anonymously. Login not required.