Friday, October 04, 2013

Extend LVM volume

To extend a LVM volume, you need to add a physical volume. If you don't have the partition create, you need to create one using, the partition should be type Linux LVM (8E): cfdisk /dev/sda
After create the partition (you might need to reboot to see it.), create e physical volume
pvcreate /dev/sda3
Now you have to add physical volumes to a volume group:
vgextend VolGroup /dev/sda3
(you can figure out the name of you volume group run vgdisplay)
Now you need to extend your logical Volume to use the new space(you need to know how much will be the total size):
lvextend -L 8.5G /dev/mapper/VolGroup-lv_root
Now finally you can extend the filesystem, simply run:
resize2fs /dev/VolGroup/lv_root