Jul 3, 2014

Recovering a RAID 5 array

Recently had a RAID 5 array fail on me. These are the steps I took to recover the data.

NOTE! The order of the disks in /dev/sdX follows the numbering of the ports on the motherboard. So if a disk is plugged into port 0, it will show up as /dev/sda. Keep this in mind as if you remove a failed disk, it might mess up the references in the array!.
  1. Boot up from a Live CD
  2. Install the software RAID management software
    sudo apt-get install mdadm
  3. Make sure RAID and LVM are unmounted
    sudo vgchange -a n [name of your volume group]  sudo mdadm -S /dev/md0
  4. Copy the failed disk to the new disk (in case the disk was the boot disk, you need to copy that flag across so that your system boots)
    sudo sfdisk -d /dev/sdx | sudo sfdisk /dev/sdy
  5. Check that the disks are the same
    sudo fdisk -l
  6. Mount the RAID array, and remove the failed disk
    sudo mdadm --assemble --scan  sudo mdadm --manage --remove /dev/sdx
  7. Add the new disk
    sudo mdadm --manage --add /dev/sdy
  8. Watch the progress as mdadm rebuilds your RAID array
    sudo cat /proc/mdstat

No comments:

Post a Comment

Thanks for contributing!! Try to keep on topic and please avoid flame wars!!