Software RAID 1 Recovery in Linux
I wrote these steps up for a customer and figured it would be useful to people who find this on google. Enjoy.
1. Check the status of the RAID
This command will output the status of all RAID disks on your system.
We can clearly see that one of the disks is lost from the array by
seeing the [U_] for each slice of the disk. A fully functional RAID
system would show [UU] for each slice.
Since you had the second hard drive plugged in, we could proceed
immedietly to step 2.
2. Copy partition table from running drive to the replacment drive
In order to do this we need first to make a copy of the partition table
on the running disk. This is accomplished with the following command:
> # sfdisk -d /dev/sda > partitions.sda
Then we need to copy this partition to the new disk. This is
accomplished with the following command:
> # sfdisk –-force /dev/sdb < partitions.sda
3. Add the newly partitioned disks to the array volume
We now need to add each partition back to the original volume.
4. Wait for the volumes to rebuild.
Now that we have added the new disk back to the volume we should see the
system rebuilding the drives. The two very small partitions /swap and
the boot partition sync very fast(in seconds) the larger partition will
take around 20 minutes to complete. You can check the status with
/proc/mdstat
Once this process is complete you should see a fully functional RAID
array (complete with [UU] on every slice).
5. Add newly built drive to GRUB
Now that the disk is ready to use, we want to make sure that it is
bootable by the system the next time you need to reboot. This is
accomplished by running the following sequence of GRUB commands:
It should be noted that there is grub output from those command that I
have omitted.
I hope that this has cleared up your questions on how we use software
RAID on the Linux.