Blog

Online Capacity Expansion (OCE) with mdadm
Posted by Matt S. in Hardware on 06.11.07

The software RAID management utility in Linux, mdadm, continues to exceed my expectations when it comes to powerful features. This weekend I discovered that in addition to creating arrays it can grow them (OCE) and even migrate to different RAID levels (RLM) under some circumstances.

We use enterprise-grade hardware in the server room at Category 4, but at home I’m motivated to come up with solutions that cost as little money as possible. Seeing how far you can go on a tight (or nonexistent) budget is quite fun. That’s why I love software RAID. Good hardware RAID controllers can cost more than everything else in the server combined.

Neil Brown, the author of mdadm, recently added the ability to add new discs to RAID5 and RAID6 arrays. Before you’d have to destroy the array and re-create it, which required copying all your data elsewhere and then copying it all back - always a pain in the ass, often impossible due to availability of extra storage. Now it’s possible to extend an existing array without disturbing the data already on it.

Let’s say you have a RAID5 array at /dev/md0 which has 3 discs, sda, sdb, and sdc. You’ve filled it up and you want to add a 4th disc, sdd, to the array.

First, add your new disk as a spare to /dev/md0

sudo mdadm --add /dev/md0 /dev/sdd

Next, issue the grow command:

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

mdadm will now begin the process of rewriting the array to include the new disk. You can even grow the array while it’s mounted and active!

You can use /proc/mdstat to track the progress of the grow process. You’ll see the status of all mdadm’s active arrays, progress meters for arrays being grown or regenerated, and a time estimate for completion.

cat /proc/mdstat

Once the array has been grown you’ll have to extend the file system on the array to make the new space available. Each file system has its own tools for this. If you’re using ext2 or ext3, then the following command will get the job done:

sudo resize2fs /dev/md0

Now check your space available with df -h and check out your new free space!

Comments

Good hardware RAID controllers can cost more than everything else in the server combined.

china news on 08-31-08 at 10:30 pm
Trackbacks


Leave a Reply