0

if I remove the physical disk associated with /dev/sdb and add a new disk in the same slot, it will be assigned /dev/sdc (or whatever the next available letter is). Is there any way powered on that I can reassign that new disk to /dev/sdb?

Running CentOS 5.4. thanks!

carillonator
  • 815
  • 3
  • 12
  • 22

2 Answers2

1

udev rules would be your friend here, look at http://www.rootninja.com/persistent-naming-of-a-block-device-in-linux/

smintz
  • 282
  • 3
  • 9
  • You can also just mount using UUID paths instead of /dev/sdx. – Jason Antman May 03 '11 at 23:22
  • does this mean there is a udev rule in place that associates the old disk's UUID with sdb that I need to remove? or do I need to add a rule for the new disk's UUID that will assign sdb to it, which will override whatever still remembers the old disk? – carillonator May 03 '11 at 23:47
  • this is a rule you will have to create, if you will read the guide carefully, you will see that the rule is actually creating an alias for the block device. – smintz May 04 '11 at 04:14
0

I wouldn't even count on device names being the same all the time. I think an easier way to handle the device (than udev rules) is just use LVM. It uses physical volume uuid's to manage the devices, so you don't worry about what physical device it ends up as. You just reference the vg or lv it is associated with.

You could look at /sys/devices (possibly subdir pci*) to find out what it ends up being to the system, pci bus number or something, but that is a hassle too. If you don't need to explicitly deal with the device, just use it for filesystem access.

If you are sure a device no longer exists (like a hot swap drive that was removed) you can do something like this:

echo "1" > /sys/devices/pci0000:00/0000:00:12.0/host3/subsystem/devices/0:0:0:0/delete

(the above is on a fedora 13 system, Centos 5.5 is much easier)

You would use lsscsi to match scsi id to device name.

Then you could add the new drive, and rescan the bus if you want.

It would be much easier not to worry about it and use lvm.

lsd
  • 1,673
  • 10
  • 10
  • I am working on systems already set up, so LVM is not an option. I do use the method above to remove the device before physically pulling it `echo 1 > /sys/class/scsi_device//device/delete`, but the drive letter is apparently not cleared – carillonator May 03 '11 at 23:42