Linux list all uuid

How to Get the UUID of devices on Linux, Ubuntu, Debian

UUID is the «universally unique identifier» that is assigned to devices on a linux system for the purpose of identification.

For example if your hard disk has 3 partitions then each partition is a device and has a uuid. Similarly cd/dvd, usb drives etc all are assigned a uuid.

On a ubuntu system for example you might find that a partition is mounted at a location like this

/media/fc474ef9-60b7-4cf8-b42a-7feb63eeb64c/

Now the part after media/ is the uuid and used as the directory name where a certain device has been mounted. To find the uuid of devices connected to a system use the following commands

$ ls -l /dev/disk/by-uuid/ total 0 lrwxrwxrwx 1 root root 10 Mar 3 09:45 14348F74348F581E -> ../../sda9 lrwxrwxrwx 1 root root 10 Mar 3 09:45 2A64794864791831 -> ../../sda1 lrwxrwxrwx 1 root root 10 Mar 3 09:45 2edfb41d-54f4-478e-8cc0-0fe9864596a8 -> ../../sda8 lrwxrwxrwx 1 root root 10 Mar 3 09:45 31a6807b-3b3e-4f9d-95c2-ead64d0c7009 -> ../../sda6 lrwxrwxrwx 1 root root 10 Mar 3 09:45 9de0aab4-e64c-49c8-af55-cc7375a97dd6 -> ../../sda5 lrwxrwxrwx 1 root root 10 Mar 3 09:45 eba07f1f-b287-456a-b3d6-1c40d7b28a60 -> ../../sda7 lrwxrwxrwx 1 root root 10 Mar 3 12:20 fc474ef9-60b7-4cf8-b42a-7feb63eeb64c -> ../../sdb1

The ls command has been used to get a list of all devices along with the uuids. The big uuids are ext4 or swap type partitions. Whereas the short uuid are ntfs type partitions.

1. blkid

Another command that can be used to perform the same task is blkid. Here are some quick examples on using it.

$ sudo blkid /dev/sda1: UUID="2A64794864791831" TYPE="ntfs" /dev/sda5: UUID="9de0aab4-e64c-49c8-af55-cc7375a97dd6" TYPE="ext4" /dev/sda6: UUID="31a6807b-3b3e-4f9d-95c2-ead64d0c7009" TYPE="swap" /dev/sda7: UUID="eba07f1f-b287-456a-b3d6-1c40d7b28a60" TYPE="ext4" /dev/sda8: UUID="2edfb41d-54f4-478e-8cc0-0fe9864596a8" TYPE="ext4" /dev/sda9: UUID="14348F74348F581E" TYPE="ntfs" /dev/sdb1: UUID="fc474ef9-60b7-4cf8-b42a-7feb63eeb64c" TYPE="ext4"

The output of blkid clearly shows the device, its uuid and the format type. Useful information. To get the uuid of a specific device, simply put the device name next to blkid like this

$ sudo blkid /dev/sda1 /dev/sda1: UUID="2A64794864791831" TYPE="ntfs"

2. lsblk

The lsblk command is another very useful and powerful command to check details about storage devices on a system.
Here is a quick example:

The lsblk command shows a lot of details about storage devices like mount point, device name, uuid, model name. The device name and UUID are needed when you need to mount a device to access its contents.

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .

3 Comments

Источник

How to find disk partition UUIDs in Linux

A Universally Unique IDentifier (UUID) is a randomly generated 128-bit value assigned to partitions or block devices in Linux systems. UUIDs provide a more stable and reliable method of identifying partitions than traditional device names, such as /dev/sda1. UUIDs can be used for mounting filesystems via /etc/fstab by specifying the UUID value in a special block device (the first field).

Читайте также:  Deleting directory with files in linux

UUIDs are typically symbolic links to the actual device names within the /dev directory. To retrieve a partition’s UUID, you can browse the /dev/disk/by-uuid/ directory or use various command-line utilities available in Linux.

Steps to get disk partition UUID in Linux:

$ 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
$ 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"
$ blkid /dev/sda3 /dev/sda3: UUID="a7d71686-0a65-4402-b6e6-b58430ef8351" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="0ea90c96-1b56-4c51-b07a-02e09285f291"
$ blkid --help Usage: blkid --label | --uuid blkid [--cache-file ] [-ghlLv] [--output ] [--match-tag ] [--match-token ] [ . ] blkid -p [--match-tag ] [--offset ] [--size ] [--output ] . blkid -i [--match-tag ] [--output ] . Options: -c, --cache-file read from 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 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 show specified tag(s) (default show all tags) -t, --match-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 convert LABEL to device name -U, --uuid convert UUID to device name 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 overwrite device size -O, --offset probe at the given offset -u, --usages filter by "usage" (e.g. -u filesystem,raid) -n, --match-types filter by filesystem type (e.g. -n vfat,ext3) -h, --help display this help -V, --version display version For more details see blkid(8).

Источник

How to View all UUIDs for all Available Disks on System?

UUID (Universally Unique Identifier) is utilized for the unique identification of partition disks in the operating system. The UUID is mainly considered in scenarios when the user has a bunch of hard drives installed and wants to extend, mount or delete any particular disk partition.

This post will cover the different methods to view all UUIDs of the disks in the Linux operating system.

  • Method 1: Through the blkid Command
  • Method 2: Through the lsblk Command
  • Method 3: Through the ls Command
  • Method 4: Through the hwinfo Command
  • Method 5: Through udevadm Command | Name Specific
  • Method 6: Through the tune2fs Command | Name Specific
  • Method 7: Through the dumpe2fs Command | Name Specific

Method 1: Through the blkid Command

The user can consider the blkid command in order to view the UUID of all the disk partitions. The blkid is a utility used for listing the available block devices with information such as filesystem type, name, UUID, block size, etc. To view all UUIDs for all available devices, run the blkid command in the terminal:

Читайте также:  Во время распаковки файлов произошла ошибка linux

The /dev/sda3 has the unique UUID=“9264bdd7-252d-4e9f-be1c-f8511eef789c”, /dev/sr0 has UUID=”2023-02-25-17-53-58-00” while the /dev/sda2 has UUID= “63A5-7890”.

If the user wants to only display the UUID-related information, match the grep pattern of UUID as shown:

The UUID pattern is matched and UUID for all available disks is listed.

Method 2: Through the lsblk Command

The lsblk is the utility that also lists the information of all the available block devices with name, type, mount point, UUID, etc. The following lsblk command displays the only “name”, “mount point”, size, and UUID column:

$ lsblk -o name,mountpoint,size,uuid

The UUID for /dev/sda2 is “63A5-7890”, /dev/sda3 is “9264bdd7-252d-4e9f-be1c-f8511eef789c”. /dev/sr0 is “2023-02-25-17-53-58-00” and /dev/sr1 is “2022-04-19-10-23-19-00”.

Method 3: Through the ls Command

In Linux, all devices, as well as storage devices, are treated as files that are symbolically linked. So their partitions and UUIDs are also treated as files. The user can list them Through the ls command to view the UUIDs of all available disks. To do so, run the below-given command:

The user can clearly see the UUID for the partition “sr1” is “2022-04-19-10-23-19-00”, “sr0” is “2023-02-25-17-53-58-00”, “sda2” is “63A5-7890” and “sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.

Method 4: Through the hwinfo Command

The “hwinfo” is the command considered for getting the hardware information of the system. To install it in the operating system, run the given command based on the Linux distribution:

$ sudo apt install hwinfo #Debian/Ubuntu $ sudo yum install hwinfo #RHEL/CentOS $ sudo dnf install hwinfo #Fedora $ sudo pacman -s hwinfo #Manjora/Arch

To display the UUID for all available disks, run the “hwinfo” command with “block” flag for the block devices and grep command to match the pattern “by-uuid”:

$ hwinfo --block | grep by-uuid

The UUIDs for all the disk partitions are listed as highlighted in the above image.

Method 5: Through udevadm Command | Name Specific

The “udevadm” is run as a daemon of Linux that listens to the user events that the Kernel sends out when the new device is initialized or removed. For this, use the “udevadm” command to obtain the UUID of the particular disk partition “/dev/sda2” as below:

$ udevadm info -q all -n /dev/sda2 | grep -i by-uuid | head -1

The above command has displayed the UUID for the device “/dev/sda2” which is “63A5-7890”.

Likewise, in order to obtain the UUID for the partitions “/dev/sda3”, the following command is carried out:

$ udevadm info -q all -n /dev/sda3 | grep -i by-uuid | head -1

The UUID for the partition “/dev/sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.

Method 6: Through the tune2fs Command | Name Specific

The “tune2fs” is the Linux command used for changing the file system parameters (ext2, ext3, and ext4 only) of the disk partitions. The UUID for the particular partition can be obtained by defining the partition name as “/dev/sda3” with the “l” flag and grep command to match the pattern:

$ sudo tune2fs -l /dev/sda3 | grep UUID

The UUID for the partition /dev/sda3 is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.

Читайте также:  Ivideon server для linux

Method 7: Through the dumpe2fs Command | Name Specific

The last method that the user can consider to view UUIDs for all available disks is to use the “dumpe2fs” command. It is utilized for displaying the superblock and group information of the file system available on the device. Run the “dumpe2fs” command with sudo permission and specify the name of the disk partition as defined below:

$ sudo dumpe2fs /dev/sda3 | grep UUID

The UUID for disk partition “/dev/sda3” is “9264bdd7-252d-4e9f-be1c-f8511eef789c”.

Conclusion

To view all UUIDs for all available disks on the Linux operating system, use the “blkid”, “lsblk”, “ls”, “hwinfo”, “udevadm”, “tune2fs”, “dumpe2fs” commands. The “hwinfo” command can be installed manually while “udevadm”, “tune2fs”, and “dumpe2fs” are built-in commands of Linux.

This write-up has illuminated all the possible methods to view UUIDs of the partition disk available in the Linux operating system.

Источник

How to Find UUID in Linux

UUID (Universally Unique identifier) is a 128-bit unique number standardized by the Open Software Foundation. UUID helps to identify partitions in Linux systems. It is generated by using the libuuid library (used by e2fsprogs) which is part of util-linux available by default in Linux from kernel version 2.15.1.

UUIDs are unique among all UUIDs created on the local system, and among UUIDs created on other systems.

The benefit of UUID comes If your system uses many data storage such as SAN, ISCSI, etc. Each time you move storage you don’t have to worry about updating /etc/fstab.

In this tutorial, we will learn how to find UUIDs of storage drives in the Linux system.

Format of UUID

UUID is displayed in five groups separated by hyphens, in the form 8-4-4-4-12 for a total of 36 characters.

9c79364e-99e1-42a8-ada1-86c31ad1fa76

How to find UUIDs

You can find the UUID of all the disk partitions of the Linux system using the command blkid.

To find UUIDs of your disk partitions connected to your system, run the following command.

Listing UUIDs of connected device partitions.

Using lsblk command

You can find UUIDs of device partitions using lsblk command. To list out the UUID of device partitions run the following lsblk command.

sudo lsblk -o PATH,SIZE,RO,TYPE,MOUNTPOINT,UUID,MODEL

Listing UUID using lsblk command

Using ls command

Linux system represents all the devices including storage devices as files. So, the partitions with the UUID set are also stored as the file.

You can list all the UUIDs of partitions using the ls command, type:

Listing UUID using ls command

Using dumpe2fs

Dumpe2fs display the super block and blocks group information for the filesystem.

To print UUID of a specific disk, run:

dumpe2fs /dev/sda | grep UUID
Output dumpe2fs 1.45.5 (07-Jan-2020) Filesystem UUID: b77fc34c-88c5-4ffc-94da-ee56195ee00f

Conclusion

Remember UUID won’t be much helpful on laptops or home desktops where normally won’t use high-end storage devices.

In this tutorial, I have covered a basic explanation of UUID in Linux system. You have learned about how to find UUID of connected device partitions in Linux system. Any feedback and response will be highly appreciated.

If this resource helped you, let us know your care by a Thanks Tweet. Tweet a thanks

Источник

Оцените статью
Adblock
detector