At one time my personal files were split between several hard drives. As most nerds do, as I needed more space I added extra drives. The cost of this method is the inevitable drive failure leaving oneself with the loss of irrecoverable precious media. Hard drives are physically unreliable and so over a year ago, I decided to build a RAID 5 array.

The most economical solution at the time utilized six 320GB drives. The total total space with redundancy factored in was approximately 1.5 TB. Using the software RAID support built into the Linux kernel, the array worked perfectly for well over a year. A few weeks ago one of the hard drives had several errors and the operating system marked it as bad and removed it from the array. The array still worked and there was no loss of data, however I needed to replace the bad disk as a RAID 5 array can only lose one drive before permanent data loss occurs.

I ordered a new drive as I didn’t want to wait for the warranty on the current one to be processed, and within a week I had a new drive which was the exact same size and had the same number of logical blocks as the old one. I removed the old drive, placed the new one in and used the Linux mdadm tool to rebuild my array.

After using fdisk to create a RAID partition on the new hard drive, I used the following command to rebuild the array: mdadm -a /dev/md0 /dev/sdb where md0 was my raid device and sdb the hard drive that had failed.

By reading the contests of /proc/mdstat I could actually watch the hard drive slowly being rebuilt.

Personalities : [raid5] [raid4] 
md0 : active raid5 sdb1[6] sdg1[5] sdf1[4] sde1[3] sdd1[2] sda1[1]
      1562842880 blocks level 5, 256k chunk, algorithm 2 [6/5] [_UUUUU]
      [==========>..........]  recovery = 53.0% (165942648/312568576) finish=145
.3min speed=16814K/sec
unused devices: <none>

The FexEx delivery van pulled up with the new hard drive as I was about to leave for work. I decided to be a few minutes late so I could go ahead and install the new drive. It took less than twenty minutes and when I got home at the end of the day, the array was fully restored.