mdadm: Swapping out small hard drives for bigger ones in a RAID5, How to partition?

Eventually you will need to have the "raid partition" to have the maximum size of the disk; it doesn't matter if you do that upon rebuild or if you repartition once your array is renewed.

I've recently done something similar, it's fairly fast. Note that you can set the raid rebuild speed (/proc/sys/dev/raid/speed_limit_min/max), by default it's limited for background rebuilds.

Note there is one step missing in your plan: you will need to instruct the thing on top of your md-layer to grow as well (filesystem, or lvm pv, or ...)

However, if you can do it (can keep the system down for longer, invest more time and have enough disk slots) it's probably safer to copy everything onto a backup disk. The data remains in plain sight at all times, which I find comforting.


Current versions of md tools support replacing a device while keeping the RAID (and so, the redundancy) working.

You need ability to add at least one more device the the computer but after that, you won't need to keep the array in degraded state for hours (or days, in case of current multi-TB HDDs) while it rebuilds.

First you need to add a disk as a spare to the array (assuming 4 drives in RAID):

mdadm /dev/md0 --add /dev/sde1

Then, you tell Linux to start moving the data to the new drive:

mdadm /dev/md0 --replace /dev/sda1 --with /dev/sde1

After replacement is finished, the device is marked as faulty, so you need to remove it from array:

mdadm /dev/md0 --remove /dev/sda1

Repeat for other drives in the array.

If you have ability to connect multiple additional drives, you can do that even for all drives at the same time, all while keeping the array online and with full redundancy. So following is a valid set of commands:

mdadm /dev/md0 --add /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1
mdadm /dev/md0 --replace /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 --with /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1

Wait until finish, remove old drives:

mdadm /dev/md0 --remove /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1

The simplest/safest way to end up with an array made up of larger disks would be to

  • copy all the data to an external drive
  • remove all the small disks and replace them with large ones
  • create the new array on the larger disks
  • copy the data back

This would also give you two copies of the data: one on the external drive, and one still on the collection of smaller drives you'd removed. (Keep careful track of which disk is which!)

I don't think you can grow RAID-5 arrays by adding a disk into it. You would be creating a 3-disk RAID-5 array, and the best you could do after copying data to the new array would be to mark the fourth disk as a hot-spare... which isn't exactly the same thing as a 4-disk RAID-5 array.