Setting Persistent names using udev rules

I have 2 drives that need to consistently boot as sda1 & sdb1.

While editing /etc/fstab can tell system which drives to mount to specific locations, I want to be able to set the order of the drives by UUID.

I can see here that its possible but how exactly do I set the rules?

https://wiki.archlinux.org/index.php/Persistent_block_device_naming

To be able to mount using UUID’s you don’t need to setup any udev rules at all…
All you need is find out what the UUID is of the partition(s) you need…

I know how to mount drives with UUID to specific points ie. /mnt/usb but not how to specify something like UUID=XXX /dev/sda1

Then it would be very helpful to know why you need them to be named like /dev/sda1 to begin with…
Because those names are normally given by the kernel (or bios) for devices it finds in a certain sequence…

my setup looks for sda1 for main drive to store data (which needs to mount on boot) & uses sdb1 as location for manual backup - so the drives need to be consistent so that drive at sda1 doesn’t get set as sdb1

Then you should change your setup to use /dev/disk/by-uuid/xxxx instead of /dev/sda1 etc…
You could also use vulume labels using /dev/disk/by-label/xxxx to make it even more pirsistent to your partitions in use without needing a persistent UUID.
(Eg. use different hard-disks with same volume names)

Keep in mind that names like /dev/sda1 are not meant to be persistent, whereas those using UUID’s or LABEL’s are…

1 Like

It uses /dev/sda1 so that’s what I’m sticking with. Do you know how to set them with udev rules?

No sorry, and even if you would find a way i’m sure it would interfere with the default udev rules used to (re)name all partitions…

My advice:

Because your intended use is to use the same hardisk partitions in your setup in a persistent way:
You should use the already provided persistent names of the partitions by the current configuration of the Linux OS in general.
That is why they invented those persistant names to start with…