HowTo: Resize an EXT4-formatted Linux LVM Volume in a virtual machine
# reboot 5. Create a physical volume:
# pvcreate /dev/sda6
Physical volume "/dev/sda6" successfully created 6. Use lvdisplay to look up the name of the volume group currently in use:
# lvdisplay
--- Logical volume ---
LV Name /dev/mongo1/root
VG Name mongo1
LV UUID wi9dRo-fS0C-xSCd-fbei-el9R-vpVi-0QEiIR
LV Write Access read/write
LV Status available
# open 1
LV Size 9,29 GiB
Current LE 2379
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 251:0
7. Add the physical volume to the volume group found in the field 'VG Name':
# vgextend mongo1 /dev/sda6
Volume group "mongo1" successfully extended
8. Now you can try to extend the existing logical volume (as named in field 'LV Name' above). If the given size increase (20GB in this example) is more than is available in the disk group, the error message will indicate the number of blocks available:
# lvextend -L +20G /dev/mapper/mongo1-root
Extending logical volume root to 29,29 GiB
Insufficient free space: 5120 extents needed, but only 5119 available Retry with the number of blocks taken from this error message:
# lvextend -l +5119 /dev/mapper/mongo1-root
Extending logical volume root to 29,00 GiB
Logical volume root successfully resized
9. Resize the filesystem (sorry for the german output -- this is the only command that used the locale setting...):
# resize2fs /dev/mapper/mongo1-root
resize2fs 1.41.11 (14-Mar-2010)
Das Dateisystem auf /dev/mapper/mongo1-root ist auf / eingehängt; Online-Grössenveränderung nötig
old desc_blocks = 1, new_desc_blocks = 2
Führe eine Online-Grössenänderung von /dev/mapper/mongo1-root auf 5241856 (4k) Blöcke durch.
Das Dateisystem auf /dev/mapper/mongo1-root ist nun 5241856 Blöcke gross.