Linux uuid of device

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.

Читайте также:  Mds to iso linux

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).

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).

Источник

Читайте также:  Rtnetlink answers file exists linux

Find UUID of Storage Devices in Linux

UUID is a unique identifier used in partitions to uniquely identify partitions in Linux operating systems. UUID is a property of the disk partition itself. So, if you install the hard drive containing the partitions on another Linux computer, the partitions will have the same UUID as before. So, that’s a good thing.

The UUID of a partition is required mainly for mounting the partitions correctly in a computer system where hundreds of hard drives are installed. If you mount the hard drives or SSDs using UUIDs, there is almost zero changes of the wrong hard drive getting mounted and causing serious data loss.

Our usual computers and laptops where mostly 1 or 2 hard drives are installed and we need limited number of partitions won’t benefit much from UUIDs.

In this article, I will show you how to find the UUID of storage devices such as hard drive or SSD partitions in Linux. So, let’s get started.

Finding UUID with blkid:

You can find the UUID of all the disk partitions on your Linux system with the blkid command. The blkid command is available by default on most modern Linux distributions.

To find the UUIDs of your disk partitions, run the following command:

As you can see, the filesystems that has UUID are displayed. A lot of loop devices are also listed.

In the earlier output, you have seen a lot of unnecessary loop devices. If you want to only list the filesystems that has UUID set, you may filter the output of the blkid command as follows:

You should be able to get a clean filtered output. Only the filesystems that has UUID set are listed.

Finding UUID with ls:

In Linux, all the devices including the storage devices are represented as files. So, the partitions with UUID set are also represented as files. You can list all these files with the ls command.

To list all the partitions and their UUIDs, run the following command:

As you can see, the partition name (i.e. sda1, sda2) and their UUIDs are listed.

Finding UUID with lsblk:

You can also list the UUID of your partitions with the lsblk command:

For example, to list UUID of your partitions with the lsblk command, run lsblk as follows:

As you can see, the UUIDs of the partitions are listed.

You can filter out all the loop devices to make the output cleaner as well. To do that, run the lsblk command as follows:

Читайте также:  What is framebuffer linux

As you can see, only the partitions with UUID are listed. The output is now much cleaner.

Where to Go Next:

Now that you know how to find the UUID of the storage devices in Linux, you can learn how to mount the partitions with UUID. I have written a dedicated article on how to mount partitions with UUID using the /etc/fstab file. You can read it at https://linuxhint.com/mount_partition_uuid_label_linux/

So, that’s how you find the UUID of storage devices in Linux. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.

Источник

How to Get the UUID of a Disk Partition in Linux

UUID is a property of disk partitions used to uniquely identify them. Here are various ways to get the UUID of a disk partition in the Linux command line.

UUID (Universally Unique Identifiers) is a property of disk partitions and is crucial while managing servers with hundreds of drives.

And the easiest way to get UUID is to list the contents of /dev/disk/by-UUID using the ls command:

use ls command to get UUID of partitions in linux

The highlighted text in light blue color is the UUID of the partition highlighted with yellow color.

That’s just one way to know the UUID of a partition. There are couple of more ways as well.

Using the blkid utility to get UUID

The blkid utility is used to get information about data blocks in Linux.

And when used without any options, you get details, including the UUID of every memory block present in the system:

blkid command output

And if you want to get the UUID of a specific block, just specify the block name as shown:

get UUID of a specific block in Linux

Using the lsblk utility to get UUID

The lsblk utility is mainly used to list block devices but when used with the -f option, it can get you additional info, including the UUID of every block:

use lsbk command to get UUID of disk in Linux

And if you are on Ubuntu or your system is loaded with snap packages, they will be listed here too. In that case, you can filter those results using the grep command:

Wrapping Up

Through this tutorial, I explained how you could get the UUID of a disk partition in Linux. And if you have any other questions, feel free to let me know in the comments.

Источник

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