Hardwiring IDE devices
*BSD, Open Source March 18th, 2006A few days ago I started using RAIDframe on one of my NetBSD i386 systems. I now have my CVS and subversion repositories and my various BSD source trees housed on a software RAID1 array.
One thing that concerned me a little was the possibility of the disks in the array being renamed if I added additional storage to the machine. The two disks that make up the array are the master drives attached to the two channels on a Promise PCI IDE controller. If I used the default approach of dynamically naming the IDE disks, the two disks would be named wd0 and wd1. If I added a slave on the first channel, it would become wd1 and the old wd1 would become wd2. As you can imagine, this isn’t a good thing, particularly as my array is not set up to autoconfigure (it’s brought online by /etc/rc.d/raidframe, which uses a configuration file in /etc).
To prevent any potential disk-renaming problems, I decided to I decided to hard-wire the IDE devices to ensure that if I install additional disks, the drives don’t get new device names. It’s quite simple – the kernel just needs to be told to name devices based on their positions on the IDE bus instead of allocating names dynamically.
I used the following in my configuration file:
pdcide0 at pci? dev ? function ?
pdcide1 at pci? dev ? function ?
atabus0 at pdcide0 channel 0
atabus1 at pdcide0 channel 1
wd0 at atabus0 drive 0 flags 0x0000
wd1 at atabus0 drive 1 flags 0x0000
wd2 at atabus1 drive 0 flags 0x0000
wd3 at atabus1 drive 1 flags 0x0000
The two IDE disks in the machine are now wd0 and wd2 and adding or removing disks doesn’t affect the device names (I’ve tested this!). The same principle applies to SCSI disks (and any device, in fact). In the case of SCSI, it’s possible to wire a specific disk device name to a specific SCSI ID, rather than having the disks named in the order in which the kernel identifies them.

Recent Comments