If your hard drive fails on your linux server it can always be stressful, but that is why you should always have some kind of raid setup and backups available. If you do not have a hardware raid card in your server you can use software based raid. I always set my servers up with RAID 1 (mirrored disk) and backups to an external server. Remember RAID is not a backup solution since deleting a file on your mirror will remove it from both disks. Below are the basic steps for replacing a mirrored disk in software raid using mdadm.

Remove all raid partitions on the failed disk

Then you can physically remove the bad disk

Once the disk is replaced you need to repartition it.
You can use sfdisk to copy the partitions from the good disk.

Then you can add the partitions back into the raid to have it rebuilt

You can run the following to see the rebuild process

Or use the “watch” command to continually see the progress of the RAID rebuild.

If the good drive happens to fail during the rebuild you can reinstall the operating system
on to two new disks and restore you files from backups. If you do not have backups you can try
to run a utility like “ddrescue” to clone one of the failed drives to a good drive. I will write an article about rescuing a disk using ddrescue in the future.

Date posted: March 10, 2010 | Author: | No Comments »

Categories: Linux

Tags: , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2013, Neil Bittner. All Rights Reserved.