A UUID (Universally Unique Identifier) is a 128-bit value assigned to partitions or block devices in Linux systems. It ensures a stable method of identifying partitions, which remains consistent even if the system's hardware configuration changes. This is more reliable than traditional device names like /dev/sda1, which may vary depending on device order or boot sequences.
UUIDs are symbolic links that point to actual block devices within the /dev directory. These links are stored in the /dev/disk/by-uuid directory and can be accessed using various Linux commands. Administrators rely on UUIDs for tasks like mounting file systems via the /etc/fstab file, where they can specify the UUID instead of device names.
To find the UUID of a disk or partition, Linux offers several built-in utilities. These commands allow users to list all available UUIDs and retrieve details about specific devices. This process is crucial for managing storage devices effectively and ensuring that systems mount file systems correctly.
Steps to find disk and partition UUIDs:
- Open the terminal.
- List the available UUIDs by accessing the /dev/disk/by-uuid directory.
$ 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
The output will show symbolic links pointing to device files such as /dev/sda3.
- Get the UUID for all available devices using the blkid command.
$ 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"
This command provides the UUID, file system type, and other information about the devices.
blkid is installed by default in most Linux distributions.
- Retrieve the UUID of a specific partition by specifying the partition device file.
$ blkid /dev/sda3 /dev/sda3: UUID="a7d71686-0a65-4402-b6e6-b58430ef8351" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0ea90c96-1b56-4c51-b07a-02e09285f291"
Replace /dev/sda3 with the correct device name. The output will include the UUID and other partition details.
More options for blkid:
$ 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).
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.