Linux RAID1 (mirroring) is great!
However when the boot disk of your MD mirror fails, your system is broken.
This HOWTO describes the steps you need to get your system
up and running again.
Warning and Disclaimer!
Don't use this HOWTO if you are not an experienced system administrator!!!
Neither the author nor Integrated Services accept any reponsability for
using this HOWTO.
If as a result your system ends up completely broken,
it's all up to you! Be warned!!
Skills needed:
Tools used:
Back up all your data.
If your system cannot boot because the boot disk failed completely,
first carry out step 2 “Make Disk B bootable”.
Boot up your system from the Debian Live CD/DVD. Choose: “Live 686”. 1)
Get root permissions: 2)
$ sudo su -
Bring up the mirror of the Root filesystem.
E.g. if RootFS is on partition 2:
# mdadm --assemble /dev/md2 /dev/sda2 /dev/sdb2 mdadm: /dev/md2 has been started with 1 drive (out of 2).
Check mirror status:
# cat /proc/mdstat Personalities : [raid1] md2 : active raid1 sdb2[1] 8191936 blocks [2/1] [_U] unused devices: <none>
# mkdir /md2 # mount /dev/md2 /md2
Chroot to the RootFS. 3)
# mount -t proc proc /md2/proc # chroot /md2 /bin/bash
Note: The following commands are for Grub version 1.
Make the necessary devicefiles: 4)
# cd /dev # MAKEDEV sda sdb
Install Grub bootloader on disk B:
# grub --no-floppy grub> device (hd0) /dev/sdb grub> root (hd0,1) grub> setup (hd0) grub> quit
More information on Grub:
http://www.kkoncepts.net/node/198
Leave the RootFS:
# exit
Reboot:
# reboot
Remove the CD/DVD and boot the system from disk B using the BIOS Boot menu: 5) 6)
BIOS Boot menu |
---|
CD/DVD |
Disk 0 |
< Disk 1 > |
Select Boot device and press Return to boot. |
Each component partition must be flagged as “failed” before they can
be removed from their mirror.
We can easily fail all component partitions in one step.
E.g. to flag mirrors md2, md3, md5, md6, md7, md8 as failed:
# for i in 2 3 5 6 7 8 do mdadm --fail /dev/md$i /dev/sda$i done
# for i in 2 3 5 6 7 8 do mdadm --remove /dev/md$i /dev/sda$i done
Verify the result:
# cat /proc/mdstat Personalities : [raid1] md8 : active raid1 sdb8[1] 10240192 blocks [2/1] [_U] md7 : active raid1 sdb7[1] 10240192 blocks [2/1] [_U] md6 : active raid1 sdb6[1] 2048128 blocks [2/1] [_U] md5 : active raid1 sdb5[1] 2048128 blocks [2/1] [_U] md3 : active raid1 sdb3[1] 20479936 blocks [2/1] [_U] md2 : active raid1 sdb2[1] 8191936 blocks [2/1] [_U] unused devices: <none>
# /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
Shutdown the system:
# shutdown -h now
Now physically replace disk A with the new disk and boot up the system.
In order to create an identical partition structure on the new disk A we need to copy the partition structure of disk B to the new disk A: 7)
# sfdisk -d /dev/sdb | sfdisk /dev/sda
If disk A was previously used in a Linux MD array all superblocks should be erased before adding the disk A partitions to their mirrors:
# for i in 2 3 5 6 7 8 do mdadm --zero-superblock /dev/sda$i done
# for i in 2 3 5 6 7 8 do mdadm --add /dev/md$i /dev/sda$i sleep 2 done
Verify the result:
Personalities : [raid1] md8 : active (auto-read-only) raid1 sda8[0] sdb8[1] 10240192 blocks [2/2] [UU] md7 : active raid1 sda7[0] sdb7[1] 10240192 blocks [2/2] [UU] md6 : active raid1 sda6[0] sdb6[1] 2048128 blocks [2/2] [UU] md5 : active (auto-read-only) raid1 sda5[0] sdb5[1] 2048128 blocks [2/2] [UU] md3 : active (auto-read-only) raid1 sda3[0] sdb3[1] 20479936 blocks [2/2] [UU] md2 : active raid1 sda2[0] sdb2[1] 8191936 blocks [2/2] [UU] unused devices: <none>
# /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf
Note: The following commands are for Grub version 1.
Verify the Grub device map:
# more /boot/grub/devive.map (hd0) /dev/sda (hd1) /dev/sdb
Install Grub bootloader on disk A:
# grub --no-floppy grub> root (hd0,1) grub> setup (hd0) grub> quit
Normally reboot your system.
Everything should be just fine!
Copyright © 2013 Integrated Services; Tux4u.nl
Author: Marjan Waldorp; mdadm-replace-bootdisk 2013-06-28; 2013-07-19