Codium Logo Codium Logo
  • Services
    • Strategy
      • Technology Partner
      • UI / UX Design
      AI
      • AI Consulting
      • AI Reporting
    • Development
      • Software Development
      • Mobile App Development
      • Software Integration
      • Hardware Integration
      • Microsoft Access Databases
      • Replace Spreadsheets
    • Managed services
      • Software Takeover
      • Software Support (SLA)
      • Managed Hosting
      • Private AI Hosting
      • On-Premise AI
  • Industries
  • Our Work
  • About
  • Blog
Blog

Mdadm - Growing Raid5 Array (Ubuntu)

23 June 2008
Mdadm is used to create, manage, monitor, and maintain raid arrays.

In this simple guide I will be demonstrating the steps used to grow a raid5 array from 3 HDD's to 4.

Prerequisites
  • Mdadm running a raid5 array
  • Linux kernel > 2.6
Steps
  1. Check the current raid array
  2. Partition the new HDD
  3. Add the new HDD to the raid array
  4. Extend the file system onto the free space

Check the current raid array

Examine the current raid5 array to ensure all HDD's are currently active

At the console, type:
$cat /proc/mdstat
The output should be similar to the following:
md0 : active raid5 sdc1[0] sdd1[2] sdb1[1]

1465151808 blocks level 5, 64k chunk, algorithm 2 [3/3] [UUU]
Here we can see that all drives are active and part of the array.

An example of a failed array:
md0 : active raid5 sdc1[0] (f) sdd1[2] sdb1[1]

1465151808 blocks level 5, 64k chunk, algorithm 2 [2/3] [_UU]
In this example we can see sdc1 has failed, this can be determined by the "(f)" after the HDD name and "[_UU]" instead of "[UU]" in the output. The failed drive will need to be replaced before you attempt to grow the array size.

Partition the new HDD

Once you have added the new HDD to the machine, check its assignment:
$cat /proc/diskstats
Output:
8   65 sde1 168430629 1886732648 70507758 564062064
As you can see we have a new drive, referenced as "sde1"

The next step is to partition the new drive for the raid array, using:
$sudo FDISK /dev/sde
Replace "sde" with your new HDD

Now choose the following options:
Type "n" to add a new partition, use the default settings
Press "t" to change the partition type, now press "fd" to set the partition type to Linux raid autodetect
Press "p" to check the partition table
The output of "p" should be similar to:
Device Boot      Start         End      Blocks     Id  System

/dev/sde1 1 60801 488384001 fd Linux raid autodetect
Make sure the System type is set to "Linux raid autodetect". Once you are sure everything is correct press:
"w" to write the changes to the partition table
If the system type wasn't set to "Linux raid autodetect" then make sure you select "fd" in the "t" menu.

Ok, your new drive is now ready to add to the array.

Add the new HDD to the raid array

First off run:
$sudo mdadm –add /dev/md0 /dev/sde1
Replace "/dev/md0" with your current raid array and "sde1" with your new HDD. This informs mdadm of the new HDD

Now run:
$ sudo mdadm –grow /dev/md0 –raid-devices=4
Replace "/dev/md0" with your current raid array.

This will tell mdadm to grow the current array onto our new HDD which was added before with the "mdadm -add" command.

While the array is growing (can take several hours) you can view the current status by running:
$cat /proc/mdstat
To speed up the growing of the array you can run the command:
$echo 25000 > /proc/sys/dev/raid/speed_limit_min
Finally once the array has finished growing check:
$cat /proc/mdstat
It should look similar to the following:
md0 : active raid5 sdc1[0] sde1[3] sdd1[2] sdb1[1]

1465151808 blocks level 5, 64k chunk, algorithm 2 [4/4] [UUUU]
As we can see all drives are active, from "[UUUU]". The number of U's being displayed is equal to the number of drives in your array, so if you grew it to 5 HDD's it will display 5 U's etc.

Extend the file system onto the free space

Now its time to move onto expanding the current file system onto the free room on the array. We will first need to unmount the current raid array using:
$sudo umount  /dev/md0
Replace "/dev/md0" with your raid array.

Now we use the e2fsck command to check the file system (will take around 10 minutes on a 1TB array):
$e2fsck -f /dev/md0
Once again replace "/dev/md0" with your raid array.

Now run:
$sudo resize2fs /dev/md0
This will expand the current file system onto the free space. (took around 15 minutes for 1 TB)

Once the expand is complete you can remount your array:
$sudo mount /dev/md0 /media/raid
Replace "/dev/md0" with your raid array and "/media/raid" with the directory you wish to mount the file system into.

You should now have an expanded raid5 array, Please post any comments or suggestions.
2008
Keep reading

More from the blog

ASD has warned about AI agents going off-script. Here is how we keep ours in line
21 Oct 2026

ASD has warned about AI agents going off-script. Here is how we keep ours in line

On 25 September the Australian Signals Directorate published a High alert about AI agents doing things nobody asked them to do. If...

Has your business outgrown Excel? Seven signs, and what to do about each one
15 Oct 2026

Has your business outgrown Excel? Seven signs, and what to do about each one

Spreadsheets fail slowly, so nobody notices the day they stop being a tool and start being the system. Here are the signs, the fix...

What has changed in custom software development over the last 12 months
2 Sep 2026

What has changed in custom software development over the last 12 months

Software development continues to evolve quickly, but the last 12 months have seen some particularly significant changes in the wa...

All articles

Want to talk about your own project?

Tell us what's slowing your business down. One of our digital strategists will talk it through with you.

Get in touch Call 1300 887 103
Codium Logo
Codium Pty Ltd.
Ground Floor, 207 Greenhill Road
Eastwood, 5063
Adelaide, South Australia
  • 1300 887 103
  • sales@codium.com.au

Development

  • Software Development
  • Mobile Apps
  • Software Integration
  • Hardware Integration
  • Microsoft Access
  • Replace Spreadsheets

Managed Services

  • Software Takeover
  • Software Support (SLA)
  • Managed Hosting
  • Private AI Hosting
  • On-Premise AI

AI

  • AI Consulting
  • AI Reporting

Strategy

  • Technology Partner
  • UI / UX Design
  • Due Diligence (M&A)
  • Why Projects Succeed
  • What Software Costs
  • What AI Consulting Costs

Technologies

  • PHP · Laravel
  • JavaScript · Vue.js
  • AWS

Company

  • About Us
  • Industries
  • Our Work
  • Blog
  • Careers
  • Contact Us
  • Customer Feedback
  • Remote Support

© Codium Pty Ltd. All Rights Reserved.

  • Terms of Business
  • Privacy Policy
  • Quality Policy
  • Security Policy
  • Customer Experience Charter
Back Top
Codium
Services
All services Strategy
  • Technology Partner
  • UI / UX Design
  • Technology Due Diligence
  • Why Projects Succeed
  • What Software Costs
  • What AI Consulting Costs
Development
  • Software Development
  • Mobile App Development
  • Software Integration
  • Hardware Integration
  • Microsoft Access Databases
  • Replace Spreadsheets
Managed services
  • Software Takeover
  • Software Support (SLA)
  • Managed Hosting
  • Private AI Hosting
  • On-Premise AI
AI
  • AI Consulting
  • AI Reporting
Industries
All industries
  • Construction
  • Finance
  • Government
  • Health
  • Insurance
  • Manufacturing
  • Mining
  • Retail & E-commerce
  • Transport & Logistics
Our Work About Blog
Get in touch Call 1300 887 103