This is a tutorial for increasing the maximum size of a dynamically allocated virtual hard disk in VirtualBox. There are two steps:

  1. resizing on the host machine and
  2. resizing on the guest (virtual) machine.

Before you begin, consider backing up your virtual machine by copying its entire directory somewhere safe. I’ve found the existing tutorials either lacking or destructive. I prefer working in the command-line, but there seem to be some easy ways to corrupt things that way in this process, so I stick to GUIs here.

I believe the first part applies to all host operating systems, but I used macOS. The second part is definitely for Ubuntu.

Resizing on the host machine

  1. Open VirtualBox. Make sure the virtual machine (vm) in question is shut down (no saved states either).
  2. Navigate to File > Virtual Media Manager .... It should open under the Hard disks tab.
  3. Select your vm’s .vdi file and (if it’s not already displayed), select the Properties icon at the top.
  4. You should see a slider bar, as pictured below. Increase the size by dragging to the right. (Btw, you can’t use this process to decrease the size, apparently.) vm-resize-01
  5. Apply and close.

Resizing on the guest (virtual) machine Ubuntu

The resizing above added another partition to the virtual hard disk, but your guest (virtual) machine Ubuntu doesn’t know how to use it yet.

  1. Launch your vm.
  2. From the Ubuntu Software Center, install the app GParted.
  3. Launch GParted.
  4. Select your main partition. vm-resize-02
  5. Click the button Resize/Move the selected partition vm-resize-03
  6. Drag the slider all the way to the right and click Resize. vm-resize-04
  7. Click the check mark to Apply All Operations. vm-resize-05

You’re done! Check that the size has increased in the file browser.