Thursday, January 23, 2014

Grow a Virtual Hard Disk: Linux Edition

Because I had some trouble finding the information I needed, I am putting it all here to save you the time it takes to sift through the entire internet. Without further ado, here's how you "grow a hard disk."

The Scenario:

You've just created a new Virtual Machine that's running Linux. Everything goes great, you install some software, and then a message pops up saying you're almost out of space.

The Solution:
  1. Turn OFF your virtual machine.
  2. From the host, go to the directory where VirtualBox is installed and run the following command: VBoxManage modifyhd MyVirtualDisk.vdi --resize NEW_SIZE_IN_MB
  3. Now you will need to resize your partitions.
  4. Download a stable release of GParted Live.
  5. Mount the GParted Live iso on your VM and change the System boot order to boot from CD first. Then start your VM.
  6. In GParted you will be able to rearrange the partitions. Move anything that is between /dev/sda1 and your free space to the far right. Then you will be able to expand /dev/sda1 into the free space.
  7. Shutdown the vm, change the boot order to whatever it was before and reboot. You should be good to go!