Constantly changing drive letter for /dev/sdX

I’m setting up a Rocky 9 server that has three drives in it - a mirrored drive for the OS, and 2 RAID 5 drives - one for home drives and one for shared data.
I’ve tried mounting the drives in /etc/fstab both by the /dev/sdx reference and by UUID #. Yet every time the server reboots the /dev/sdx reference changes, I assume depending on the order in which the BIOS recognizes each device.
How do I get these drives references to stay permanent and not change every reboot?
Thanks,
Paul

In /etc/fstab, you should be using UUID to get around the device name changes. Using /dev/sdX should be a no-go as it has never been a stable identifier. UUID will never change, unless you make a change to a file system/partition in some way.

If you insist on the sdX names to stay the same, you would need to use udev. Get the info you need from udevadm info --name /dev/sdX and then create your rules in for example /etc/udev/rules.d/example.rules.

See:

/lib/udev/rules.d/60-persistent-storage.rules

https://www.freedesktop.org/software/systemd/man/latest/udev.html

If I do a “blkid” I see the home drive partition and data partition listed as the following

/dev/sdc1:UUID"-long string-" TYPE-“LVM2_member” PARTLABEL=“Linux filesystem” PARTUUID= “-long string-”
/dev/sda1:UUID"-long string-" TYPE-“LVM2_member” PARTLABEL=“Linux filesystem” PARTUUID= “-long string-”

Does that full string go in /etc/fstab?

Just to add some relevant into - just in case I might have done something wrong when creating the drive partitions

created paritions using gdisk; one partition on each disk utilizing entire disk, set type as 8e00
ran “pvcreate dev/sda1” and “pvcreate /dev/sdc1”

ran “vgcreate fileshare /dev/sdc1” and “vgcreate home-drives /dev/sda1”

ran “lvcreate -l 100%VG -n fileshare fileshare” and “vgcreate -l 100%VG home-drives home-drives”

I tried to run “mkfs.xfs” on both but keep getting “can not open /dev/sdx1: device or resource busy” errors

Something like:

UUID=-long-string-  /where/you/want/it  xfs  defaults  0  0

You did create LV. Do you see /dev/mapper/fileshare-fileshare or something similar?
That is the device where you want the filesystem. Not the /dev/sdc1.

Thank you jlehtone and nazunalika - between the 2 of you, that finally got me through this hurdle.

I used the /dev/mapper/fileshare-fileshare (etc) in /etc/fstab to mount the partitions - they do appear to persist across reboots.

So far, all seems well. Fingers crossed.

Thanks again.

The system only let me give credit for the solution to 1 person, but both of you should get credit for this.

Thanks again

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.