Adding space to ext3/LVM partitions without losing data

I've recently ran out of space on a server and decided to write a tutorial about this. There are some resources out there but this is a more complete guide of doing this. Mostly I wrote it for me to have a procedure in the future.
Let's assume we add a new disk on the system and we want to increase the space on the existing partitions without having to delete and recreate them. This would be a nighmare when you have partitions streching on 2-3 1TB disks - lost time and also you need to have the space on some other disk to copy the files.
First of all, add the new disk on the machine. Best would be to boot a live CD (e.g. Knoppix) so that we can make the lvm operations "offline". Create a new partition on the disk using fdisk of type "8e" - Linux LVM.
Next, create the physical volume within the new partition. We'll take as example partition /dev/sde1:

# pvcreate /dev/sde1

Extend the existing volume with the newly created physical volume:

# vgextend VolGroup00 /dev/sde1

Next, extend the logical volume to use the space made available by extending the volume group:

# lvextend -L 1000G /dev/VolGroup00/LogVol00

The final step is to enlarge the ext3 partition to fill up the free space. First you'll have to run a check on the filesyste. These operations will take some time, proportional with the size of the partition:

# e2fsck -f /dev/VolGroup00/LogVol00
# resize2fs /dev/VolGroup00/LogVol00

Follow by Email

Sponsored Links