Growing the devices in a Software RAID array

Growing the devices in a Software RAID array

As hard disk space is ever increasing, you may get replacement drives that are significantly larger than the original devices that they replace, so this tip will show how to increase the size of a RAID array using larger partitions to replace smaller partitions in the original RAID array.

We will assume that you have a RAID 5 array using three partitions (/dev/sdb1, /dev/sdc1, and /dev/sdd1) on /dev/md0. These partitions are 1 GiB each, giving you about 2 GiB of usable space. You add new disks and create three partitions (/dev/sde1, /dev/sdf1, and /dev/sdg1) of 5 GiB in size. By the end, you should have about 10 GiB of usable space.

After you have created the partitions and set the partitions type to 0xfd, you can add these devices to the array. They will become hot spares:


mdadm /dev/md0 -a /dev/sde1 /dev/sdf1 /dev/sdg1

Fail the original devices one at a time, ensuring that the array rebuilds after each failed device. DO NOT fail more that one of the original devices without verifying that the array has finished rebuilding. If you fail two devices in a RAID 5 array, you may destroy data!

First, fail and remove the first device, and verify that the array has finished rebuilding:

mdadm /dev/md0 -f /dev/sdb1 -r /dev/sdb1
watch cat /proc/mdstat

Once it has finished rebuilding, fail the second device:

mdadm /dev/md0 -f /dev/sdc1 -r /dev/sdc1
watch cat /proc/mdstat


Once it has finished rebuilding, fail the third device:

mdadm /dev/md0 -f /dev/sdd1 -r /dev/sdd1
watch cat /proc/mdstat


After it has finished rebuilding, you have replaced all of the 1 GiB original devices with the new 5 GiB devices. However, we are not finished yet. We have two problems: the RAID array is still only using 1 GiB of my 5 GiB devices, and the filesystem is still 2 GiB.

First, grow the RAID array. mdadm can grow the RAID array to a certain size, using the -G and -z options. The -z option can take a currently undocumented argument of max, which will resize the array to the maximum available space:

mdadm -G /dev/md0 -z max

`cat /proc/mdstat` and `mdadm -D /dev/md0` should show that the array is now using a 5 GiB device size.

Second, we need to enlarge the filesystem to match. Assuming that you have an ext3 filesystem on /dev/md0, and that you have mounted it, you can increase the size of the filesystem by using ext2online:

ext2online /dev/md0

After that command completes, you should see about 10 GiB of usable space.

Comments

Popular posts from this blog

configure Netbackup email notification on Unix