Resize Fedora LVM partitions on VM

Mon 22 April 2013

I am currently keeping Fedora Rawhide as my development environment installed as a VM on my regular usage operating system - OSX. I am using VirtualBox to run the VM and utlizing vagrant's services for saving the box as and when required.

Since I do a lot of build-deps, I get many applications that as time passes, clutter system. The default *.vmdk (VM hard disk file) comes with 8GB space and is hardly enough for my use case. So I set about resizing it.

As it turns out Fedora by default uses LVM partioning and Gparted does not recognize this! So all tutorials out there for resizing a VM hard disk file doesn't really help past the first two commands. After 4 hours of mucking around, I managed to arrive at the right combination of commands for an LVM partition resize.

Here are the steps:

On your host OS:

  1. VBoxManage clonehd box-disk1.vmdk box-disk1.vdi --format vdi

  2. VBoxManage modifyhd box-disk4.vdi --resize

On your running guest OS:

  1. fdisk /dev/sda

  2. Create a parition with 'n', I accept and keep the defaults it provides.

  3. Change label with 't'. Change label for the createed partition to '8e'

  4. Write and Exit with the command w.

  5. mkfs -t ext4 -c /dev/sdaN (address of the newly created parition)

  6. pvcreate /dev/sdaN

  7. vgextend fedora /dev/sdbN

  8. lvextend -L NGB /dev/fedora/root (for extending LogVol to NGB)

Credits for the steps so far: Sujith.

  1. resize2fs /dev/fedora/root

  2. Yay! now df should show new free space :)

Credits for the steps 9 and 10: Michael.

Category: Linux

Comments