Friday, July 5, 2013

Resize LVM ext4


Reduce
# Unmount the filesystem and check its' LV
umount /mnt/foo
e2fsck -f /dev/mapper/vg0-foo

# Shrink ext4 and then the LV to the desired size
resize2fs -p /dev/mapper/vg0-foo 40G
lvreduce -L 40G /dev/mapper/vg0-foo

# Before continuing, run e2fsck. If it bails because the partition
# is too small, don't panic! The LV can still be extended with
# lvextend until e2fsck succeeds, e.g.:
# lvextend -L +1G /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo

# Resize the filesystem to match the LVs size, check and mount it
resize2fs -p /dev/mapper/vg0-foo
e2fsck -f /dev/mapper/vg0-foo
mount /mnt/foo

Increase

ext4 can performce online growth
$ sudo lvextend -L12G /dev/lvmvolume/lucid64root
$ sudo apt-get install lvm2
$ sudo vgchange -a y
$ sudo resize2fs /dev/lvmvolume/lucid64root


Replace the above command if your file system is xfs
$sudo xfs_growfs /dev/lvmvolume/lucid64root

$ sudo e2fsck -f /dev/lvmvolume/lucid64root
Reboot 

# Example 1: Extend LV (lvvar) from VG (vgroot) to a specific size (50G) root@linux ~ # lvextend -L50G /dev/vgroot/lvvar # Example 2: Extend LV (lvvar) from VG (vgroot) with additional 10G root@linux ~ # lvextend -L+10G /dev/vgroot/lvvar # Example 3: Extend LV (lvvar) from VG (vgroot) with the remaining space of the VG root@linux ~ # lvextend -l+100%FREE /dev/vgroot/lvvar


http://pubmem.wordpress.com/2010/09/16/how-to-resize-lvm-logical-volumes-with-ext4-as-filesystem/
http://againstentropy.blogspot.com/2012/01/resizing-root-ext4-filesystem-on-lvm.html