1. An existing mdadm RAID1 array with <=2 drives. If you have >2 drives in the array, read below.
2. New drives with at least the same capacity as the existing drives.
In the commands below, substitute
<ARRAY> with your existing mdadm array (e.g.,
Removing excess drives from the array
In order to move to a RAID5, you must have at most 2 drives in the existing RAID1. You can check how many drives are in the array using the following command.
mdadm --detail <ARRAY>
In order to remove the excess drives, you will need to fail and then remove them from the array.
mdadm --fail <ARRAY> <drive> mdadm --remove <ARRAY> <drive>
They can be considered "new drives" and re-added after the array is changed to a RAID5.
1. Change your existing array from RAID1 to RAID5.
mdadm --grow <ARRAY> --level 5
2. Add each new drive to the existing array.
<disk> is the RAID partition on the new disk (e.g.,
/dev/sdc1). If you are using the entire device, use the device itself instead (e.g.,
mdadm --add <ARRAY> <disk>
3. Grow the array to use the newly added drives.
<drive count> is the new total number of drives in the array (e.g., if you had 3 drives and added 2 new drives,
<drive count> would be 5).
mdadm --grow <ARRAY> --raid-devices <drive count>
4. The array should begin resyncing now with the newly added drives. After the resync is done, you can increase and maximize the array size if necessary.
mdadm --grow <ARRAY> --size max
Afterwards, you can increase the array partition size with something like
fdisk and then resize the filesystem using
5. Make sure to update any other configurations as needed afterwards, such as:
- Adding the new drives to mdadm.conf (e.g., to the
devices=arg of the array if used)
- Updating your ramdisk to use the updated mdadm.conf (e.g. on Arch,
mkinitcpio -p linux)