In this lesson, you will learn how to change the configuration of an existing RAID array while it is actively mounted and running, a process known as RAID reshaping.
Why Reshape?
When you set up a storage array, your needs might change over time. Perhaps you started with a two-drive RAID 1 (mirror) for safety but realize you now need more space and redundancy, prompting a move to RAID 5 (striping with parity). RAID reshaping allows you to migrate between RAID levels or change the number of disks in an array without losing your data or unmounting the filesystem.
The Mechanism
Reshaping is managed by the mdadm utility. When you trigger a reshape, the kernel performs a background operation to recalculate parity blocks, redistribute data across the existing drives, or integrate a newly added drive into the array structure. Because this happens "online," the array remains accessible, though you may notice a temporary decrease in performance as the CPU and disk I/O are shared between your applications and the reconstruction task.
A Practical Example
Imagine you have a 2-drive RAID 1 array (/dev/md0) and you want to convert it to a 3-drive RAID 5 array to gain more capacity. You would first add the new drive to the array, then command the reshape:
# Add the new device to the array
mdadm --manage /dev/md0 --add /dev/sdc
# Grow the array to 3 devices and change the level to RAID 5
mdadm --grow /dev/md0 --raid-devices=3 --level=raid5
The system will begin the migration process immediately. You can monitor the progress by checking the status in /proc/mdstat:
cat /proc/mdstat
This will show you the percentage of the reshape remaining and the estimated completion time. It is crucial to ensure you have a reliable power source during this time, as interrupting a reshape can put your data at risk. Once complete, you will need to resize your filesystem (e.g., resize2fs for ext4 or xfs_growfs for XFS) to occupy the newly available space.
Key Takeaway: RAID reshaping allows you to non-destructively evolve your array’s capacity and redundancy levels while the system remains online, though it requires patience and stable system conditions to complete successfully.