Resizing an LVM Partition on a Live Server
I recently ran out of space in an lvm partition on a server I manage. I needed to grow the partition with minimal interruption. Here's what I did.
First, I used the lvextend command to grow the logical volume.
lvextend -L +4G /dev/vgname/lvname /dev/hda4
That assigns 4 gigs of space from the physical volume hda4 into the lvname logical volume.
After this step, that extra space is still not usable because the filesystem has not been resized. Resizing the filesystem is done with the following steps.
Note: These steps are specific to ext2/ext3 filesystems. These steps are dangerous. At the time this procedure was done, the volume was completlely full, and problems were already occuring in applications using the volume. This solution represents a brute-force, as fast-as-possible solution to the issue. The good news is that it worked for me, and only minimal data was lost.
# Kill all processes running on the volume (this is dangerous and can cause data loss..)
sudo fuser -mk /dev/vgname/lvname
sudo umount /dev/vgname/lvname
sudo e2fsck -f /dev/vgname/lvname
sudo resize2fs /dev/vgname/lvname
sudo mount /dev/vgname/lvname

Post new comment