Resizing Logical Volume (LVM) on ext3
I’ve recieved a few emails from people asking “How can I resize an LVM (proper term would be resizing a Logical Volume) on their system”.
In this posting i’ll touch on only ext3 since that’s the default fs. Later, I’ll touch others if it’s requested.
There are a few steps you have to take to resize a partition. First, you have to resize the filesystem (be sure to do this before you reduce the lv, as that could cause data loss).
In this instance i’ll be resizing a mount location at /app. If you want to shrink the /home partition make sure you go into runlvl 3 (sudo init 3) and get out of the /home directory (cd /).
To resize the filesystem lets unmount it by running:
sudo umount /apps
First run a check on the file system:
sudo fs2chk -f /dev/volumegroup/logicalvolume
note: you can find the volume group name, or logical volume name you can use vgscan and lvscan (both are located in /sbin/)
Now lets resize the ext3 partition:
sudo resize2fs /dev/volumegroup/logicalvolume 10G
note: 10G is the NEW size that you want it to be
Once those are completed, you can finally resize the Logical Volume (isn’t this what we wanted in the first place?), to do this do:
sudo lvreduce -L 10G /dev/volumegroup/logicalvolume
note: Use the same output you defined in the resize2fs command.
Lets remount our partition and jump for joy:
sudo mount /dev/volumegroup/logicalvolume /app
note: If this mount point is defined in /etc/fstab, you can remount via sudo mount -a (this will mount everything in /etc/fstab).
Bonus:
If you wanted this space for an existing logical volume, you can run lvextend -L XXG /dev/volumegroup/logicalvolume.
Note: XX is the space you took away from the other reduced partition.
What others are saying