Can Linux rebuild a broken RAID mirror?
Q I've been reading a book on RAID under Linux and have set up a RAID 1 system with two drives. However, if drive 1 fails and I have to replace, I'm unsure of whether I'll need to partition it first or if it will automatically do that during the reconstruction process.
A You might not have to repartition the disk, but this depends on the disk configuration with RAID. If there are individual partitions, such as hda1, hdc3, etc which are used to create the md devices, the new disk will have to be repartitioned, as the kernel is unable to do this itself. The new partitions must be at least large enough to store the RAID image, which can be particularly difficult when two disks that are apparently the same size have a different number of cylinders. Using identical disks helps - however, as we all know to our cost, manufacturers usually have batches of disks that just fail, so using disks from the same manufacturer isn't encouraged.
If you want an easy solution where you can just slap in a new disk and have it build the RAID image on it automatically, take a look at LVM, which is a high-level partition system. One can create logical volumes (which are similar to partitions out of the md device) which means they are not involved in the RAID array itself. All md0 will consist of is /dev/hda and /dev/hdc, and rebuilding is easy assuming the disks are the same. It's also worth remembering that most hardware RAID systems ignore partitions entirely and use the whole disk that is put into the system, but one can partition this device up into smaller partitions which are distributed across the array. Software RAID devices can be either whole disks or partitions, and the structure needs to be built on any devices added to the array.
Follow us on Identi.ca or Twitter