Replacing A Failed Hard Drive In A Software RAID1 Array
Replacing A Failed Hard Drive In A Software RAID1 ArrayVersion 1.0 This guide shows how to remove a failed hard drive from a Linux RAID1 array (software RAID), and how to add a new hard disk to the RAID1 array without losing data. I do not issue any guarantee that this will work for you!
1 Preliminary NoteIn this example I have two hard drives, /dev/sda and /dev/sdb, with the partitions /dev/sda1 and /dev/sda2 as well as /dev/sdb1 and /dev/sdb2. /dev/sda1 and /dev/sdb1 make up the RAID1 array /dev/md0. /dev/sda2 and /dev/sdb2 make up the RAID1 array /dev/md1. /dev/sda1 + /dev/sdb1 = /dev/md0 /dev/sda2 + /dev/sdb2 = /dev/md1 /dev/sdb has failed, and we want to replace it.
2 How Do I Tell If A Hard Disk Has Failed?If a disk has failed, you will probably find a lot of error messages in the log files, e.g. /var/log/messages or /var/log/syslog. You can also run cat /proc/mdstat and instead of the string [UU] you will see [U_] if you have a degraded RAID1 array.
3 Removing The Failed DiskTo remove /dev/sdb, we will mark /dev/sdb1 and /dev/sdb2 as failed and remove them from their respective RAID arrays (/dev/md0 and /dev/md1). First we mark /dev/sdb1 as failed: mdadm --manage /dev/md0 --fail /dev/sdb1 The output of cat /proc/mdstat should look like this: server1:~# cat /proc/mdstat Then we remove /dev/sdb1 from /dev/md0: mdadm --manage /dev/md0 --remove /dev/sdb1 The output should be like this: server1:~# mdadm --manage /dev/md0 --remove /dev/sdb1 And cat /proc/mdstat should show this: server1:~# cat /proc/mdstat Now we do the same steps again for /dev/sdb2 (which is part of /dev/md1): mdadm --manage /dev/md1 --fail /dev/sdb2 cat /proc/mdstat server1:~# cat /proc/mdstat mdadm --manage /dev/md1 --remove /dev/sdb2 server1:~# mdadm --manage /dev/md1 --remove /dev/sdb2 cat /proc/mdstat server1:~# cat /proc/mdstat Then power down the system: shutdown -h now and replace the old /dev/sdb hard drive with a new one (it must have at least the same size as the old one - if it's only a few MB smaller than the old one then rebuilding the arrays will fail).
4 Adding The New Hard DiskAfter you have changed the hard disk /dev/sdb, boot the system. The first thing we must do now is to create the exact same partitioning as on /dev/sda. We can do this with one simple command: sfdisk -d /dev/sda | sfdisk /dev/sdb You can run fdisk -l to check if both hard drives have the same partitioning now. Next we add /dev/sdb1 to /dev/md0 and /dev/sdb2 to /dev/md1: mdadm --manage /dev/md0 --add /dev/sdb1 server1:~# mdadm --manage /dev/md0 --add /dev/sdb1 mdadm --manage /dev/md1 --add /dev/sdb2 server1:~# mdadm --manage /dev/md1 --add /dev/sdb2 Now both arays (/dev/md0 and /dev/md1) will be synchronized. Run cat /proc/mdstat to see when it's finished. During the synchronization the output will look like this: server1:~# cat /proc/mdstat When the synchronization is finished, the output will look like this: server1:~# cat /proc/mdstat That's it, you have successfully replaced /dev/sdb!
|
www.seamlessenterprise.com
One number. One voicemail. Seize the lead. Sprint Mobile Integration.
www.seamlessenterprise.com
One Number. One Voicemail.
Make it easier for clients to reach you. Turn your desk phone and mobile phone into one with Sprint Mobile Integration.
www.seamlessenterprise.com
One number. One voicemail. Sprint Mobile Integration.
www.seamlessenterprise.com
One number. one voicemail. Seize the lead with Sprint. Learn more
AT&T Synaptic Compute as a Service. Boost your power on demand.
Trial: IBM Cognos Express Reporting, Analysis & Planning
Learn benefits of Simpana software.
View the Gartner Video
Sprint 4G - The Ultimate Mobile Broadband
Click here
SAP-Business Objects Crystal Reports Server
Complete reporting without hidden costs. Free Trial







Recent comments
17 hours 30 min ago
19 hours 28 min ago
19 hours 46 min ago
1 day 9 hours ago
1 day 15 hours ago
2 days 3 hours ago
2 days 4 hours ago
2 days 8 hours ago
2 days 11 hours ago
2 days 12 hours ago