static disk device naming

Nicholas Leippe nick at leippe.com
Thu Oct 25 09:10:44 MDT 2007


So I caused a problem the other day. In the past, when a scsi drive went bad, 
I could safely do:

echo "1" > /sys/class/scsi_disk/H:B:T:L/device/delete

then remove it, add the replacement, and do:

echo "- - -" > /sys/class/scsi_host/hostH/scan

and it would allocate the next available letter to the device, leaving the 
remaining, active drives alone.  So, for example, if sdc went bad, sda, sdb, 
and sdd would stay, and it would allocate sde as the replacement.
I could then add the new drive into the md raid array, and be good to go.

On reboot, it would again be sdc, so the kernel parameters for defining the md 
device wouldn't need any changing.

Apparently, this is not the case for sata and/or sas.

We have a 12-drive sas bay, on a dedicated sas controller. 4 drives are sas, 8 
are sata.  I went to change out three of the sata drives, and using the same 
procedure (above) that I have always used, instead of what I expected, it 
renumber _all_ of the drives, including the existing ones--shuffling them 
around to other existing device names--thus absolutely confusing the md layer 
and ultimately crashing the kernel.

So, my questions:
1) is there a definitive, proper procedure for doing this task that will not 
move existing drive's device names around on me (allowing for hotswap with an 
active md layer on top)
2) is there a definitive way to get fixed device naming for drives?

I ask #2 because when I created the md devices, I used the /dev/disk/by-id/* 
nodes to specify the drives by serial #, and it dereferenced them to their 
shorter sdx node names--which I knew might not stay fixed. Also most of the 
guides concerning fixed disk device naming are geared toward usb--which 
always gets allocated at the end of the available list of scsi device names, 
and don't ever expect an active md device to be on top.

At least with scsi, it is predictable. They will be allocated abcd... and if 
id 2 is not populated, you at least know how things will be moved around when 
you do populate it and reboot. (c and d get shifted to d and e, respectively)
This is because the device naming is done in the same order as the bus 
topology, which SAS and SATA don't have...

3) So, are there any guarantees with SAS/SATA?

4) Is there any difference between using /sys/class/scsi_* vs /sys/class/sas_* 
for the same devices?









More information about the PLUG mailing list