Jimmy's weblog


Growing Hardware RAID-5 with LVM by adding a physical disk

Filed under: — jimmy @ 1:00 am

Sometimes you’re running out of space and all you can do is adding additional disks. Although it’s a simple task in theory, there a some risky steps involved. So you should backup your volumes before. In my case I had a RAID-5 in an IBM x3650 M3 Server with a ServeRAID M5015 Controller. There was one volume with three 146 GB SAS disks and on top LVM. The root filesystem was on this volume, too, which doesn’t make things easier ;-)
First Step: Insert a new 146 GB SAS disk to extend the volume. The first risky step is to rebuild the RAID-5 with four disks instead of three. So you may want to upgrade the firmware of the controller first and make a backup of the LVM volumes. Of course you should not save the backup on the same server ;-)
I configured a partimage server on another machine and ran partimage client on the server with the new disk:

partimage -z2 -domMc -s save /dev/mapper/main-rootfs fileserver.partimg.bz2

(Please lookup the options in the manpage yourself)
The command for the ServeRaid controller was not easy to find but here we go:

/opt/MegaRAID/MegaCli/MegaCli64 -LDRecon -Start -r5 -add -PhysDrv [252:3]  -L0 -a0

252:3 stands for the fourth drive. You can find out more about available drives running:

/opt/MegaRAID/MegaCli/MegaCli64 -PDList -a0

To watch the rebuild status run:

/opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -L0 -a0

As we want to resize the root filesystem we need to reboot the machine so that programs like fdisk see the new size of the array. Afterwards you can resize the partition or simply delete and recreate it. Next step is to resize the LVM physical volume and again a reboot is needed so that pvresize recognizes the new partition size. So these are the next steps where things might get wrong, too:

pvresize -v /dev/sda2
lvresize -l +34871 /dev/main/rootfs
resize2fs /dev/main/rootfs

/dev/sda2 was my LVM partition (sda1 was for /boot) and thanks to the new disk I had 34871 extends available (146 GB). The resize commands work with active volumes and mounted filesystem so you don’t have to stop any services. Only the two or three reboots (if you want to make a final reboot after all changes) interrupt the services but this should be ok.