How to grow a mdadm RAID 5 array

How to grow a mdadm RAID 5 array

Category : How-to

Get Social!

image

mdadm is a software RAID technology for creating local volumes with RAID functionality such as RAID 5. RAID 5 is used to provide redundancy in the even of a disk failure by using the equivalent space of one disk in the volume for parity data.
One advantage of using mdadm is that you can create volumes of disks to a given size and then expand them at a later date. For example, if you have a RAID 5 array with 3 disks you can expand it to four disks.
Before following these steps you should un-mount the file system using umount.
This example assumes your array is called md1 and the new disk is sdf.

mdadm --add /dev/md1 /dev/sdf1

Now we can grow /dev/md1 as follows.

mdadm --grow /dev/md1 --size=max

If this fails, you may need to remove the bitmap index before retrying the above command.

mdadm --grow --bitmap=none /dev/md1

The process will now start which can take a while. An Example, 5 x 2TB WD green disks took 3 days to complete. You can view the progress with:

watch cat /proc/mdstat

Once this completes, we run a file system check and resize the file system.

e2fsck -f /dev/md1
resize2fs /dev/md1
e2fsck -f /dev/md1
You can now re-mount your file system.
mount -a


2 Comments

Jehu

8-Jan-2017 at 2:29 am

I have 6 3TB drive and using raid 6…I want to add another drive to increase drive space.
All the examples I see is for md0 but I have md0 and md1 raid devices…if I try to add md0 it works but when I try to add md1 to the new drive I get an error that the disk is busy.
Please help.
Thanks!

mitchd123

17-Jan-2022 at 4:12 pm

Thanks for your article. The commands listed above will add the new drive as a hot spare, and one will be unable to expand the array using the max command. instead they need to grow the array after adding the drive…adjust for ones individual setup, but in my case to grow from 3 drives to 4 I added the raid devices switch: mdadm –grow /dev/md0 –raid-devices=4

Leave a Reply

Visit our advertisers

Quick Poll

How many Proxmox servers do you work with?

Visit our advertisers