On my system (Debian), I can see the UUID identifier for all of my disks partitions (i.e. /dev/sda1, dev/sda2, ..)

ls /dev/disk/by-uuid/

However, I don't see the UUID identifier for /dev/sda itself. Is it possible to reference whole disk with UUID?

I need this because I want to reference a particular disk, and I cannot rely it will be called /dev/sda.


The solution suggested by @don_crissti is great. However, I would like the UUID to be the same for all hard disks of the same Model/Manufacturer, not unique by serial number.

Using udevadm, I can see the disk attributes:

udevadm info -n /dev/sda -a
ATTRS{model}=="Samsung SSD 840 "

How can I generate a UUID from these attributes, so that same Model/Manufacturer disk will have the same UUID ?

  • UUIDs are for filesystems, not partitions. There are PARTUUIDs for partitions, but nothing for whole disks. You'll probably have to write an udev rule to give /dev/sda a fixed name instead.
    – muru
    Feb 18, 2015 at 21:18
  • 1
    What's interesting about this is there is now a UUID in the MBR (at least if it was created by Windows) but seemingly no way to use it.
    – Joshua
    Feb 19, 2015 at 2:27

1 Answer 1


The symlinks under /dev/disk/by-uuid/ are created by udev rules based on filesystems UUIDs. If you look at /usr/lib/udev/rules.d/60-persistent-storage.rules you will find entries like:

...... ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"

To reference a disk you could use the disk serial number and the ENV{ID_SERIAL_SHORT} key.
The following udev rule matches the drive with serial no. 0000000013100925DB96 and creates a symlink with the same name under /dev/disk/by-uuid/:

KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL_SHORT}=="0000000013100925DB96", SYMLINK+="disk/by-uuid/$env{ID_SERIAL_SHORT}"

As to your other question... sure, you could always use ENV{ID_MODEL} instead of ENV{ID_SERIAL_SHORT} and use a custom string for your symlink name.
The following rule matches any drive with ID_MODEL = M4-CT128M4SSD2 and creates a symlink M4-SSD-1234567890 under /dev/disk/by-uuid/:

KERNEL=="sd*", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_MODEL}=="M4-CT128M4SSD2", SYMLINK+="disk/by-uuid/M4-SSD-1234567890"

Note that this works fine as long as there's only one drive matching the ID_MODEL. If there are multiple drives of the same model, the rule is applied again for each of them and the symlink will point to the last detected/added drive.

  • actually, I would like the UUID to be the same for all disks of the same Model/Type/Manufacturer. Do you happen to know what rule to use for that? Obviously not the serial number. Feb 19, 2015 at 16:04
  • please see my edit. What I am trying to accomplish: lets say my HDD breaks down, but I have replacement identical disk. I replace it and I would like to have same UUID as before (even though the serial number has changed). I do not intend to use both disk at the same time. Feb 19, 2015 at 16:20
  • @MichaelBoies - you can directly alter the UUID w/ gdisk - but I'm not sure if that's such a good idea. don - directly altering the links is a way better way to do it than actually altering the UUID - the computer would probably stop booting.
    – mikeserv
    Feb 20, 2015 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.