(Last Updated On: January 10, 2018)

This will show you how to extend Any operating system’s Virtual Hard Disk running on VirtualBox ; both vdi and VMDK virtual hard drive formats. When i was working on a vagrant box i downloaded from the internet, it had only 10GB allocated. After filling up the space, i had to extend it so that i could install more packages.

Below are steps i followed to accomplish that. This guide assumes you’re using Linux Guest OS, but i will let you know how to go about it on Windows Guest and Windows Host. My host operating system is Fedora 23 and you can check my article on Top things to do after Fresh Installation of Fedora 23.

If you’re new to Vagrant and want to add a new box from your existing Virtualbox environment, then look at Step by step guide on using existing virtual machines with Vagrant
So lets get started. Follow steps below.

Step 1: Prerequisites
  • Installed Guest operating system on Virtualbox that you want to extend its hard disk
  • VirtualBox installed
  • Virtual Machine to be modified must be powered off
  • Gparted live bootable ISO
Step 2:

Download Gparted live iso image

wget http://downloads.sourceforge.net/gparted/gparted-live-0.25.0-1-i686.iso
step 3:

Change to directory containing Virtual Machine to modify. If you’re using vagrant first run

vagrant halt

Then change to VirtualBox VMs folder. For my case it’s /home/josepy/ VirtualBox VMs/, cd to Virtual machine’s directory

cd /home/josepy/VirtualBox VMs/
cd  centos-asterisk/

If using VMDK, you’ll have to clone it first to vdi. If your virtual hard disk is in vdi format, you can directly resize it.The name of my vmdk file was box-disk1.vmdk

 VBoxManage clonehd box-disk1.vmdk centos-asterisk.vdi --format vdi
 VBoxManage modifyhd centos-asterisk.vdi --resize 50000

The commands above cloned box-disk1.vmdk to centos-asterisk.vdi so that we can resize it. VirtualBox doesn’t support resizing of .vmdk disk type.

In case you would like to convert new resized vdi to vmdk, you’ll have to clone it again, e.g.

VBoxManage clonehd centos-asterisk.vdi box-new-disk1.vmdk --format vmdk
Step 4:

Open VirtualBox GUI and click on your VM.Then Settings > Storage >IDE Controller > Add optical drive ( round like icon on the right) > Point to Gparted iso you downloaded and add it.
Again click on IDE Controller > Adds hard disk and point to your newly resized vdi or vmdk. Mine is centos-asterisk.vdi. See below screenshots for clarification.

 

 

 

 

 

 

After that, on same Virtual Machine GUI, go to settings > System > Motherboard > Boot order. Then, uncheck Hard disk, and select Optical and click on OK button at the bottom to save changes.

Step 5
Boot the VM by clicking on start button, and select Gparted Live on gparted boot menu that will appear. Use default settings by hitting Enter key until you reach the gparted partion Menu.

 

 

 

 

Step 6.

 This is the point we’re doing partioning to make extended drive functional.
Click on Already partitioned drive > ( Resize/Move). Now press and hold CTRL key and drag the dark arrow to the end.
Or add Free space following + New size and put the sum on New Size area.Click on resize the apply changes, then exit.

 

 

 

 

After shutting down the Virtual Machine.Go back to settings and untick on Optical under boot order and select hard disk. Also remove the iso you added under IDE Controller menu option.

FOR WINDOWS GUEST OPERATING SYSTEM
If you resized Hard disk for Windows Guest Operating system, open DISK PARTITION MANAGER and extend your Windows partion.
That’s all. Your hard disk should be extended by now. To check run lsblk command on your Linux Guest OS.

lsblk

Tags
How to resize VirtualBox’s virtual Hard drive on Windows
How to resize VirtualBox’s virtual Hard drive on Linux
Resizing Guest OS virtual Hard drive on Windows
Resizing Guest OS virtual Hard drive on Linux

You a can check another tutorial on how to Add VirtualBox Guest Additions to Guest OS under

Step by step guide on using existing virtual machines with Vagrant