This is a reverse question to tons of questions about how to identify which physical drive matches /dev/sdx
. I want to avoid having to ask that question when a drive fails.
I have bought an adapter capable of serving 8 drives (9211-8i). Both SFF-8087 cables are nicely marked so that I know which physical drive is which.
However, the attached drives are mapped as /dev/sdx
Just for reference, my M.2 boot drive nicely mounts as /dev/nvmxxx
which nicely distinguishes it from the other drives in the system.
So, how can I instruct ubuntu device mapper to map my controller attached drives as something distinct & EXACTLY matching the physical port a drive is attached to, e.g. /dev/scsi[abcdefgh]
? In fact, I'd even prefer numeric port numbers, but I'm not sure it matches unix mapping rules where drives are marked with letters, then followed by partition numbers, e.g. /dev/sda
-> /dev/sda1
Thanks
Have a look at
/dev/disk/by-path/
, which essentially does this. The other way is to reference it by UUID or Label, which is a property of the partition, and not the hardware. If you reference disks by UUID, this will not change, even if you move the drive to a different computer.As you can see, this uniquely identifies the drive depending on path, including bus connection. These files are a symlink to the actual device:
To identify a drive, the utility
lsblk
is useful:To see the UUID of a disk, you can run
sudo lsblk -f
. This will show the UUID, which you will find in/dev/disk/by-uuid/
as well:This can also be used in fstab. For instance:
will mount the partition with that UUID on /boot.