Resizing VirtualBox disk using Vagrant

Recently, the box that I was using to try out Ansible ran out of memory. Resizing the disk turned out to be a bit of a pain.

First problem, we were using VMDK format for the virtual hard disk. This format cannot be resized. You would have to convert it into an expandable VDI format. But since root file system was on this drive, we could not take the risk of running resizing the file system on the drive. Hence we created a new virtual hard disk in the VDI format and attached it to the VM.

Once that was done, we had to just expand the logical volume on which / was mounted. On a high level, we had to

  1. Run fdisk on the drive and create a primary volume with an LVM label
  2. pvcreate 
  3. Add the newly created physical volume to the Volume group
  4. lvextend the root partition
  5. resize2fs

Once this was done, we repackaged the box and normal services were returned.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s