9

I have a 4 disk RAID5 array, one of which is starting to fail according to smartd. However, since I'm using less than half the space on /dev/md0, I'd like to rebuild the array without the failing disk.

The closest scenario I've been able to find online has been this post, however it contains bits that don't apply to me (LVM volumes) and also doesn't explain how I go about resizing the partition after I'm done.

Please note I have backups of important data, but I'd like to avoid rebuilding the array from scratch if possible.

Update: Failing disk has since been kicked out the array, can I still do this?

drjeep
  • 193
  • 1
  • 5

2 Answers2

10

According to the power of Google, which brought me to this article, it's possible to resize RAID5 arrays under Linux since mdadm version 3.1.something.

  1. First shrink the filesystem (using resize2fs -M).
  2. Use mdadm ... --grow --array-size= to resize the array down so that it's the correct size for three physical volumes.
  3. Use mdadm ... --grow --raid-devices=3 --backup-file=/tmp/backup to change the number of devices in the array.

I have never tested this myself, and until now I didn't even realize this operation was supported. So, I've learned something. Good luck!

larsks
  • 43,623
  • 14
  • 121
  • 180
  • Thanks, @larsks. Failing disk has since been kicked out of the array, so it's now or never! Will report back if it works. – drjeep Aug 02 '13 at 15:52
  • @drjeep Did it work? – J Collins Nov 21 '14 at 15:45
  • We'll never know ... – Johan Boulé Jun 21 '15 at 21:00
  • 2
    According to [this mdadm manual page](https://linux.die.net/man/8/mdadm), the grow option explicitly says it also handles shrink. Thus it should work by design. But be sure to shrink the file system first, before `mdadm`! – Robin Hsu Apr 23 '18 at 07:43
  • Can confirm it works, reduced from 10 drives to 5 for raid5 array (one of the drives failed). With additional step of disabling write-intent map, according to https://raid.wiki.kernel.org/index.php/Growing – kevin Jul 04 '19 at 14:33
  • 1
    Tested with mdadm v3.4 and kernel 4.9.0-11-amd64 and can confirm that this works as advertised. – cgogolin Dec 10 '19 at 08:32
-3

There is no stable way to shrink RAID5 array. I tried larsks's answer. Rebuilding did not work. (Stalled at 0% of progress) And I lost my RAID array.