LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Persistent naming of /dev/sd[a-z] devices. How could I achieve this? (http://www.linuxquestions.org/questions/linux-server-73/persistent-naming-of-dev-sd%5Ba-z%5D-devices-how-could-i-achieve-this-920646/)

Devyn 12-26-2011 10:05 PM

Persistent naming of /dev/sd[a-z] devices. How could I achieve this?
 
Hello All,

I notice UDEV already creates a number of links to point to standard device names like sda, sdb, sdc etc. for hard disks:

6318 lrwxrwxrwx. 1 root root 9 Dec 26 22:21 scsi-SATA_ST31000520AS_9VX0X994 -> ../../sda
6315 lrwxrwxrwx. 1 root root 9 Dec 26 22:21 ata-ST31000520AS_9VX0X994 -> ../../sda
6324 lrwxrwxrwx. 1 root root 9 Dec 26 22:21 wwn-0x5000c50026cddb36 -> ../../sda

However, I notice these are not persistent across reboots or when new hardware is added.

For example, udev might assign ata-ST31000520AS_9VX0X994 to sda but when another drive is added, ata-ST31000520AS_9VX0X994 now magically points to sdb while sda get's the serial number of the newly installed device.

When viewing through files such as the following:

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

# USB devices use their own serial number
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{program}="usb_id --export %p"
# ATA devices with their own "ata" kernel subsystem
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="ata", IMPORT{program}="ata_id --export $tempnode"
# ATA devices using the "scsi" subsystem
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $tempnode"
# scsi devices
KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $tempnode", ENV{ID_BUS}="scsi"

The above looks to me upon further reading the kernel might have something to do with associating the sd[a-z] devices with the physical device and serial numbers etc including their ordering upon which udev creates the links.

How could I ensure that udev or the kernel links point consistently to the same physical device and device name across reboots or new hardware being added? Also how could I define the associations manually and ensure they are presistent?

I'm using an RHEL 6.1 clone: Scientific Linux 6.1.

Thanks,
Devyn

sinuhe 12-26-2011 10:24 PM

/dev/disk/
 
I'm not sure, but with labels and UUID persistence can be achieved, if that is the goal.

273 12-26-2011 10:27 PM

It's not exactly what you're asking but I changed to using UUIDs in my fstab so that I could mount my drives in this kind of situation.

syg00 12-26-2011 10:37 PM

In point of fact for (complete) persistence you should use by-id. Both UUID and LABEL are subject to change.

273 12-26-2011 10:47 PM

Quote:

Originally Posted by syg00 (Post 4559009)
In point of fact for (complete) persistence you should use by-id. Both UUID and LABEL are subject to change.

How likely are UUIDs to change? I'm OK for now but would be good to future proof if necessary.

syg00 12-26-2011 10:55 PM

mkfs and mkswap both alter the UUID. Then there is uuidgen.

Another thing to consider if you ever use dd to backup a partition - both will have the same UUID. So much for unique ...


All times are GMT -5. The time now is 01:48 AM.