Как посмотреть uuid диска в linux
Перейти к содержимому

Как посмотреть uuid диска в linux

  • автор:

Find UUID of Storage Devices in Linux

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:

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.

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

Click to enlarge

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

Click to enlarge

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.

How to find disk partition UUIDs in Linux

Ezoic

report this ad

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:

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

blkid is installed by default in most Linux distributions.

Как узнать UUID диска в Linux

UUID или Universal Unique Identifier — это универсальный уникальный идентификатор, который может использоваться для однозначной идентификации определенного устройства компьютера. В операционных системах Linux UUID очень часто используется для идентификации разделов дисков в загрузчике Grub или в файле /etc/fstab. Это очень удобно, поскольку если вы извлечете диск или подключите его к другому разъему SATA, то его имя в системе изменится, а UUID останется прежнем.

Но у этого метода есть и недостаток. UUID рассчитывается на основе метаданных раздела или диска, поэтому если вы измените его размер, UUID тоже изменится, что приведет к поломке системы и вы не сможете загрузится. Исправить ситуацию можно только указав правильный UUID.

Как узнать UUID диска в Linux

Давайте разберем как узнать UUID диска в Linux. Все диски и разделы перечислены в виртуальном каталоге /dev/. Здесь есть подкаталог /dev/disk/by-uuid/ в котором вы можете посмотреть UUID идентификаторы всех подключенных к системе дисков. Для этого выполните:

ls -la /dev/disk/by-uuid/

Строки состоящие из большого количества цифр и букв, подсвеченные бирюзовым цветом и есть UUID.

2. blkid

Ещё для просмотра UUID можно использовать утилиту blkid. Её необходимо запускать от имени суперпользователя, но она показывает информацию только по нужному вам разделу. Например, чтобы посмотреть UUID раздела /dev/sda6 выполните:

sudo blkid /dev/sda6

Здесь UUID выводится в таком формате:

Эту строчку уже можно целиком вставлять в /etc/fstab или настройки загрузчика grub. Утилита позволяет посмотреть информацию для нескольких устройств:

sudo blkid /dev/sd*

3. lsblk

Ещё один вариант — эту утилита lsblk, которая тоже может показывать UUID:

lsblk -o +uuid,name

4. Графический интерфейс

Если вы не хотите использовать терминал, то всегда можете посмотреть UUID в графическом интерфейсе. Для этого используйте утилиту Gnome Disks. Её можно найти в главном меню операционной системы:

Для просмотра UUID просто выберите нужный жесткий диск и кликните по разделу, для которого нужно посмотреть информацию:

Выводы

UUID довольно часто используется при работе с разделами в Linux несмотря на то, что обычные имена разделов намного удобнее и проще запоминаются. Надеюсь, эта информация была полезной для вас.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *