4

I have few Linux (RHEL 5.x / Centos 5.x) boxes running on KVMs, on which I used to attach and detach disks on the fly. Now the problem with EL5 versions are, when we add a disk, initially it will be marked as /dev/sdb. When I remove it and re-attach the disk again it is pointing to /dev/sdc instead of /dev/sdb again, if I repeat the process the disks will be /dev/sdd.. /dev/sde.. so on.

I want the disk always to attach to the /dev/sdb. How to I achieve this ?

I googled a lot and it took me no where :(.

Any help on this will be appreciated !

  • http://www.tuxradar.com/answers/500 – quanta Jun 06 '12 at 07:50
  • Have a look at: http://docs.redhat.com/docs/en-US/Red_Hat_Enterprise_Linux/5/html/Online_Storage_Reconfiguration_Guide/persistent_naming.html – gm3dmo Jun 06 '12 at 08:14
  • The Docs in redhat is not helping getting this setup done, I have given a try but it wasn't helping. I am checking the first reply"http://www.tuxradar.com/answers/500", and will update here. Thank you ! Looking forward for more info about this case – Kiranjith Tg Jun 06 '12 at 08:21

3 Answers3

1

Do you need to refer the disks by device? If you just need to e.g. mount them, you can get away by referring to their partitions by label or even UUID. If that's not what you are after, you may want to look in the udev machinery, that allows you to write your own device naming rules.

Cheers, Alf

Alien Life Form
  • 2,309
  • 2
  • 21
  • 32
1

Use an alternate identifier for the block device instead of /dev/sdb. The two common methods are labels and UUID numbers. Examples for both entries in /etc/fstab are below:

LABEL=restore /restore ext3 defaults,noauto 0 0

UUID=7bbbc4ba-029a-4f5c-95e9-1efc74e55b68 /restore ext3 defaults,noauto 0 0

The command blkid displays the label and/or UUID for all block devices. Hope that helps.

GregL
  • 9,370
  • 2
  • 25
  • 36
0

If you want to refer to a device as the same name then udev is the answer. It adds a name to a device. So even if the device identity changes the label to refer to the device remains the same. Like for example if /dev/sda is assigned the udev name BOOT then even if sda becomes sdb the name BOOT refers to the same device. I haven't used udev myself. So can't give you the exact udev rule to follow. But google should ample hits to solve it yourself, it should be pretty simple.

bagavadhar
  • 538
  • 4
  • 14