MDADM Pause Raid Resync To Enable Bitmapping

Halsafar picture Halsafar · Dec 12, 2012 · Viewed 9.3k times · Source

I have a 3x3TB Raid which has decided to start a Resync on the day I planned to grow the raid. This was several days ago and the resync has not yet finished. The reason it has not finished is because for whatever reason the machine hard stalls (completely unresponsive) seemingly random. So since I can't find the cause of the sudden random hangs I'd like to at least give my raid a chance to rebuild. I've read that if I enable bitmapping then it can resume resync on crash instead of starting from 0%.

I've tried:

 checkarray -x /dev/md0

This says a stop request was queue`d on /dev/md0 but it never actually stops.

Next I tried this:

 echo "idle" > /sys/block/md0/md/sync_action

The text in that file is immediately changed back to "resync".

THE PROBLEM:

I need to find a way to issue this command:

 mdadm --grow --bitmap=internal /dev/md0

But the raid can't be in a resync when I issue this command.

Is there a way to enable bitmap on boot? Can I maybe boot a live linux distro and get the raid to resync from there (in case the hard freeze is my Ubuntu install)?

Answer

Fabricio picture Fabricio · Jun 16, 2016

Actually this is possible, you can fail and remove the device doing the resync, add the internal bitmap to the array and then add the device back, just be sure to check that all your devices are healthy before screwing with your array. This is what I've done in one such case:

mdadm --manage --fail /dev/md5 /dev/sdb8
mdadm --manage --remove /dev/md5 /dev/sdb8
mdadm --grow /dev/md5 --bitmap=internal
mdadm --manage --add /dev/md5 /dev/sdb8

And here is the result:

md5 : active raid10 sdb8[0] sdd8[3] sdc8[2] sda8[1]
      1731712000 blocks super 1.1 512K chunks 2 near-copies [4/3] [_UUU]
      [>....................]  recovery =  0.4% (3681152/865856000)     finish=1391.9min speed=10322K/sec
      bitmap: 8/13 pages [32KB], 65536KB chunk

Of course you're better of just waiting for the resync and adding the bitmap latter in case you can't pause it, but if you expect that the resync might fail before it finishes and don't want to wait it resync again from the beginning this is how you can do it.