====== Replace md mirror device ====== ====== Background ====== System is Centos 5.6. \\ Warning in logwatch:- \\ --------------------- Smartd Begin ------------------------ Currently unreadable (pending) sectors detected: /dev/sda - 96 Time(s) 53 unreadable sectors detected Offline uncorrectable sectors detected: /dev/sda - 96 Time(s) 53 offline uncorrectable sectors detected ---------------------- Smartd End ------------------------- Boot device is /dev/sda, /dev/sdb did not have correct boot sector. ===== Fix non bootable /dev/sdb ===== Make /dev/sdb bootable:- \\ [optimax]# grub GNU GRUB version 0.95 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename.] grub> root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done. grub> root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd1)"... 15 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd1) (hd1)1+15 p (hd1,0)/boot/grub/stage2 /boot/grub/grub.conf"... succeeded Done. grub> quit ===== Current md partitions ===== [root@optiplex ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/md1 19G 4.1G 14G 23% / /dev/md3 303G 236G 53G 82% /data /dev/md2 1.9G 827M 1011M 45% /var /dev/md0 99M 37M 58M 39% /boot ===== Remove failed partitions from md arrays ===== Fail partitons:- \\ # mdadm --manage /dev/md0 --fail /dev/sda1 # mdadm --manage /dev/md1 --fail /dev/sda2 Remove from md arrays:-\\ # mdadm --manage /dev/md0 --remove /dev/sdb1 # mdadm --manage /dev/md1 --remove /dev/sdb2 Shutdown system and replace faulty disk. If your disks are hot swap, this step may not be needed.\\ # shutdown -h now Swap over faulty disk for new disk.\\ Copy partiton table from existing good disk to new disk, double check you are copying the right partition table to the right disk. Then check again :-} # sfdisk -d /dev/sdb | sfdisk /dev/sda Add partitons back in to md array:- \\ # mdadm --manage /dev/md0 --add /dev/sda1 mdadm: added /dev/sda1 # mdadm --manage /dev/md1 --add /dev/sda2 mdadm: added /dev/sda2 Watch the resync progress with:-\\ # watch cat /proc/mdstat Install grub loader back on to new disk. grub> find /grub/stage1 (hd0,0) (hd1,0) grub> device (hd0) /dev/sdb (or /dev/hdb for IDE drives) grub> root (hd0,0) grub> setup (hd0) grub>quit