How to add a new disk to RAID5

Published by Tobias Hofmann on

2 min read

I have a RAID5 consisting of three 10TB HDDs. This RAID5 has a total capacity of 20 TB.

I bought a new 10 TB HDD that I want to use to extend the RAID5: 4 HDDs with a total capacity of 30 TB. The file system on md0 is ext4. Currently, the RAID5 disks are sdc1, sdf1 and sde1. The additional disk is sdd1.

cat /proc/mdstat

The RAID5 is formatted with ext4 and available as md0.



  1. Prepare new disk
  2. Add disk to RAID
  3. Grow RAID
  4. Extend ext4 files system.

Prepare new disk

First start with the preparation of the new disk. The disk is /dev/sdd and needs to have a partition. I use parted for this. First, create a label of type gpt.

parted -s -a optimal /dev/sdd mklabel gpt

Next is to create the partition using parted. This time, I am using the interface.

parted /dev/sdd

Add disk to RAID

The RAID is a software RAID on Linux, therefore mdadm is used to control the raid. To add a new disk, option –add is used and the raid and new disk are passed as parameters.

mdadm --add /dev/md0 /dev/sdd1

The result of the operation can be seen in mdstat.

cat /poc/mdstat

The new disk is added as a spare device. The (S) behind sdd1 means spare device. In case a device would fail, the spare device will take over automatically and a RAID rebuild will be triggered. This gives me less trouble in case a device fails, as I won’t have to do anything, but it won’t give me more space. The RAID5 is still at 20 TB.


To make the RAID5 aware of the new disk and that it should be used for data storage, the RAID must be informed to use the new HDD using the grow command.

mdadm --grow --raid-devices=4 /dev/md0

The command informs the RAID that there are now 4 HDDs to be used, instead of 3. This command will trigger a RAID rebuild, as the information must be distributed to the HDDs.

This process will take some time. To learn how to increase the speed the sync, see my other blog about this topic.

The RAID5 consists now of 4 HDD, all working [UUUU]. The size of the RAID is still 20 TB. This is because the md0 has capacity of 30 TB, but the ext4 filesystem is still configured to make use of 20 TB.

Resize ext4 filesystem

To be able to use the 30TB available on the RAID5, you need to resize the file system. First, run an integrity check.

e2fsck -f /dev/md0

After the e2fsck ended without errors, the file system can be extended. This is done by using the tool resize2fs.

resize2fs /dev/md0

After resize2fs completes (can take a while), the size available is now 30TB:

mount /dev/md0 /mnt/md0/


Let the world know

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.


Terrance · September 30, 2020 at 16:19

Woke up this morning to one of my 5 drives in my RAID 5 offline. I really need to get around to making sure all cables have locks on them and don’t slide out. Well, the drive is fine but for the life of me I was having a slight issue getting it back. I made the mistake of adding /dev/sdg and not /dev/sdg1 back to the array. Your instructions with the parted part is what I was missing. Thank you for great instructions!

waheed · October 27, 2020 at 10:59

by extending the RAID5 drive is the data safe in the main drive

    Tobias Hofmann · October 27, 2020 at 21:44

    When you extend the RAID, the data won’t be lost. The parity information is reallocated, this is a safe operation (as long as a HDD is not failing or power is lost)

Yaniv · December 6, 2020 at 17:21

can i use different drive sizes when creating an array?

    Tobias Hofmann · December 8, 2020 at 20:35

    Hi Yaniv,
    depends on the RAID type. RAID0: yes. For a RAID5 the disks/partitions need to have the same size.

Hikari · January 8, 2021 at 00:25

Nice tutorial, tnx!

I’m planning to build an array and considering buying 4 HDs now and 2 more later. This is what I needed to know.

This is also the 1st tutorial I see teaching how to create raid partitions using parted! All I’ve read use fdisk, which is limited to MBR, which is limited to 2TB!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.