Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

2 Answers 2

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.

share|improve this answer
    
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/<the_disk>/device/delete, but the drive letter is apparently not cleared –  carillonator May 3 '11 at 23:42

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

share|improve this answer
    
You can also just mount using UUID paths instead of /dev/sdx. –  Jason Antman May 3 '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 3 '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 4 '11 at 4:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.