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/
disk resize

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.

resize disk 1

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.

resize disk 2

 

resize disk 3

 

resize disk 4

 

resize disk 5

 

resize disk 6

 

resize disk 7

 

resize disk 8

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.

resize disk 9

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.

resize disk 10

 

resize disk 14

 

resize disk 13

 

resize disk 12

 

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.

resize disk 15

 

resize disk 16

 

resize disk 17

 

resize disk 19

 

resize disk 20

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

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!


As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

LEAVE A REPLY

Please enter your comment!
Please enter your name here