Pages

Saturday, October 5, 2013

Software RAID: Fail and replace


REPLACE DRIVE IN SOFTWARE RAID
================================

[~]# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb2[1] sda2[0]
      2096120 blocks super 1.1 [2/2] [UU]
      bitmap: 1/1 pages [4KB], 65536KB chunk

md0 : active raid1 sdb3[1] sda3[0]
      102388 blocks super 1.0 [2/2] [UU]
     
md3 : active raid1 sda4[0] sdb4[1]
      481990524 blocks super 1.1 [2/2] [UU]
      bitmap: 4/4 pages [16KB], 65536KB chunk

md1 : active raid1 sda1[0] sdb1[1]
      4193272 blocks super 1.1 [2/2] [UU]
---------------------------------------------

Fail and remove the partition from raid

mdadm --fail /dev/md0 /dev/sda3 // this will fail sda3 in md0
mdadm --remove /dev/md0 /dev/sda3 // will remove the sda3 from md0

mdadm --fail /dev/md1 /dev/sda1
mdadm --remove /dev/md1 /dev/sda1

mdadm --fail /dev/md2 /dev/sda2
mdadm --remove /dev/md2 /dev/sda2

mdadm --fail /dev/md3 /dev/sda4
mdadm --remove /dev/md3 /dev/sda4

---------------------------------------------------------
The mdstat will be similar to the following one

[~]# cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb2[1]
      2096120 blocks super 1.1 [2/1] [_U]
      bitmap: 1/1 pages [4KB], 65536KB chunk

md0 : active raid1 sdb3[1]
      102388 blocks super 1.0 [2/1] [_U]
     
md3 : active raid1 sdb4[1]
      481990524 blocks super 1.1 [2/1] [_U]
      bitmap: 4/4 pages [16KB], 65536KB chunk

md1 : active raid1 sdb1[1]
      4193272 blocks super 1.1 [2/1] [_U]
     
unused devices: <none
---------------------------------------------------------


(2) Replicate partition table to the new drive say 'sda'(if the new disk may be different in real time)

sfdisk -d /dev/sdb | sfdisk /dev/sda



If the partition is GPT Follow the steps below

(!) Install "sgdisk"

#yum install

(!!)use sgdisk to clone the partition table from /dev/sdb(here sda is new) to the other two hard drives
-----------------------------------------
#sgdisk --backup=table /dev/sdb
#sgdisk --load-backup=table /dev/sda
#sgdisk -G /dev/sda
-----------------------------------------

(3) Add new partion to raid accordingly

mdadm --add /dev/md0 /dev/sda3
mdadm --add /dev/md1 /dev/sda1
mdadm --add /dev/md2 /dev/sda2
mdadm --add /dev/md3 /dev/sda4

(4) Raid resync will start automatically. Check status in /proc/mdstat 

To see your Linux kernel speed limits imposed on the RAID reconstruction use:


cat /proc/sys/dev/raid/speed_limit_max
200000
cat /proc/sys/dev/raid/speed_limit_min
1000

To increase the speed:

echo 50000 >/proc/sys/dev/raid/speed_limit_min
echo 50000 >/proc/sys/dev/raid/speed_limit_max


0 comments:

Post a Comment