Assign a device filename by UUID?

1

I have a system with multiple drives installed. I can see a list of all drives along with their UUIDs and labels using the blkid command (omitting some lines for conciseness):

root@ubuntu:~/avl# blkid
/dev/sdy1: UUID="F00D-78FA" TYPE="vfat" PARTLABEL="EFI system" PARTUUID="23fc9408-58b2-4905-983e-be0a4dc4adee"
/dev/sdy2: UUID="0c58da23-7ef5-4177-807c-d9164174c092" TYPE="ext4" PARTLABEL="Linux filesystem" PARTUUID="81c156e7-1113-46b4-9365-ed3a262fc475"
/dev/sdd1: UUID="ff1954fe-e8c1-4253-abbc-24d3d6c6a6c5" TYPE="ext4" PARTUUID="dae0a716-01"
/dev/sdb1: UUID="b26fadc6-cd26-4f2a-8a41-91238737ae4b" TYPE="ext4" PARTUUID="48b181eb-01"
/dev/sdu1: UUID="b9fb58ab-474c-4113-9789-c3a02ed49ddf" TYPE="ext4" PARTUUID="51d5e885-01"
/dev/sda1: UUID="08e865f9-0b47-407d-b103-b93836479de4" TYPE="ext4" PARTUUID="9bc2dad1-01"

You can see that my boot drive is assigned to /dev/sdy. However, I'd like for this drive to be assigned to /dev/sda instead.

My question is: Is there any way to force Linux to assign a drive with a given UUID to a given device filename?

Paul M

Posted 2018-04-11T17:25:07.133

Reputation: 11

3XY problem? Why should /dev/sda be better than /dev/sdy? If you need to reliably identify a certain disk/partition/filesystem then use /dev/disk/by-id/ or /dev/disk/by-uuid/ (read this). – Kamil Maciorowski – 2018-04-11T17:49:11.277

@KamilMaciorowski I wasn't aware of the /dev/disk directory -- thank you for bringing this magical directory to my attention! After thinking through my question more, what I am looking for is indeed a way to reliably refer to a drive (as in a real, physical drive that is plugged into my chassis) – Paul M – 2018-04-11T19:12:51.917

Answers

0

Unless I am mistaken, the "sd?" is assigned in the order in which they were detected by the OS. This is usually in the order the BIOS puts them... and/or RAID controller... and/or device LUN... etc.

Without defining some udev rules to name them manually... you're going to have to change the order in which they were detected.

TheCompWiz

Posted 2018-04-11T17:25:07.133

Reputation: 9 161