centos -- how to add a new disk into a mdadm raid5 /dev/md0 which lost a /dev/sdc1 disk and revoery at another machine?
fdisk -l mdadm --stop /dev/md0
# to force active the raid by remaind 3 disks. mdadm -A --force /dev/md0 /dev/sdb1 /dev/sde1 /dev/sdd1
# add a new disk into /dev/md0 mdadm --manage /dev/md0 --add /dev/sdc1
------------------------------------------------------------------------------------------------------
we build a /dev/md0 on a Unitek (removeable usb storadge with 4 disks inside) by mdadm software, and mdadm -create /dev/md0 operated on a HUAWEI server, our recovery work was done on my laptop ,and we meet many many problems during recovery.
we miss a disk --/dev/sdc1 from the raid /dev/md0, and now have a new disk -- same compable with the lost /dev/sbc1, on hand.
and then our joury is startiing
- check /dev list
ll /dev/
nothing about /dev/md0 .
- check /dev/md0 state :
cat /proc/mdstat
Personalities :
unused devices: <none>
...nothing( for this is a totally new machine to the /dev/md0 no conf file ,no superblock...)
- we try force mdadm to assembly to force mdadm auto recovery itself:
mdadm --assemble --run --force /dev/md0
mdadm -A --force /dev/md0 /dev/sdb1 /dev/sde1 /dev/sdd1
we get "can't open /dev/md0 array info" or "/dev/sdb1 is busying" and many other error response info;
- then we try add a new disk into
mdadm --manage /dev/md0 --add /dev/sdc1 mdadm: Cannot get array info for /dev/md0
- try get into manage mode, can't get config file
[root@localhost dev]# mdadm --assemble /dev/md0 --scan --force
mdadm: /dev/md0 not identified in config file.
- a key operated is coming, and lead us to a success result.
all the steps above, we NOT stop the /dev/md0 and get many wrong try and get many failed resulte.
mdadm --stop /dev/md0
mdadm: stopped /dev/md0
[root@localhost dev]# mdadm --assemble /dev/md0 --scan --force mdadm: /dev/md0 not identified in config file. [root@localhost dev]# cat /proc/mdstat Personalities : unused devices: <none>
mdadm --force start by remain 3 disks, and add a new disk into /dev/md0, and get into recovery state.
[root@localhost dev]# mdadm -A --force /dev/md0 /dev/sdb1 /dev/sde1 /dev/sdd1 mdadm: /dev/md0 has been started with 3 drives (out of 4). [root@localhost dev]# mdadm --manage /dev/md0 --add /dev/sdc1 mdadm: added /dev/sdc1 [root@localhost dev]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sdc1[5] sdd1[0] sde1[4] sdb1[2] 8790402048 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [U_UU] [>....................] recovery = 0.0% (184776/2930134016) finish=1321.3min speed=36955K/sec bitmap: 0/22 pages [0KB], 65536KB chunk unused devices: <none>
conclusion:
- remember to stop /dev/md0 at first step, then do other operates;
- mdadm create raid5 array, every raid array info were storaged at every physical disk , no matter how their position was changed, madadm can recognize the correct raid array info.
- mdadm is realy a stronger sofeware at protect our data, if use correctly we need not worry about our data's safety --- if only lost ONE disk, we can find them back;
-----other relate info reference
1. http://blog.csdn.net/waityoualife/article/details/5612243