Mucking with Linux software RAID

2003 August 25
by darkness

Today a friend running Red Hat 9 wanted to move two out of three members of a RAID 1 and RAID 5 array from IDE to SCSI drives. (Really he was just making IDE drives look like SCSI drives because he installed the manufacturer’s drivers. Apparently RH kernels’ Highpoint IDE drivers suck.) This is a bit of a problem because the RAID superblock has a list of (major,minor) pairs that make up the devices in the array.

To fix this, we booted up to the RH9 rescue disk (it was a RH9 system) with the Highpoint drivers installed. So now instead of the old members hde and hdg, we had sda and sdb. Nothing started, no /mnt/sysimage because md0 is /boot and md1 is /. raidstart /dev/md0, which is the RAID 1 array, and it starts in degraded mode. Then we used mdadm to add in the missing members of the RAID 1 array. Something like mdadm /dev/md0 -a /dev/sda1 -a /dev/sda2. (sda2 was originally the spare. The kernel raid drivers made it a spare again when we added it.)

I was a bit more worried about what would happen if we tried to bring up the RAID 5 array one disk at a time. So to be safe I used the command from the examples given in the mdadm(8) manual page. mdadm -Ac partitions -m 1 /dev/md1 means “read /proc/partitions, scan every partition, find me partitions that claim to be part of RAID minor number 1 (a.k.a. md1) and add them the device /dev/md1.” For some reason this felt more atomic and thus safer to me. Surprisingly it worked and md1 was now on-line.

Apparently this is all it takes to re-write the RAID superblocks on all involved partitions. You can examine them with mdadm -E /dev/memberdevice (like mdadm -E /dev/sda1) and see what devices are listed as part of the RAID array in the superblock. Don’t forget to reflect your changes in /etc/raidtab.

In other news, mkinitrd adds SCSI support and SCSI modules based on finding alias scsi_hostadapter lines in /etc/modules.conf. To get mkinitrd to automatically add in scsi_mod, sd_mod, and hpt37x2 (the Highpoint driver in this particular case) we just had to alias scsi_hostadapater hpt37x2 in /etc/modules.conf. Also, mkinitrd won’t add software RAID modules unless /proc is mounted and (presumably) showing RAID devices in use. So if you’re chrooted into /mnt/sysimage in RH rescue mode, go ahead and mount /proc inside the chroot before you run mkinitrd -v.

No Comments

Leave A Comment

Note: You can use basic XHTML in your comments. Your email address will never be published.

Subscribe to this comment feed via RSS