How to extend Vdi and VMDK Hard disks on VirtualBox

Posted on 135 views

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 that I followed to accomplish the task. 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.

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 let’s get started. Follow steps below.

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 extend VDI and VMDK Hard disks on VirtualBox VM. 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 Linux.

Step 1: Setup pre-requisites

  • 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: DownloadGparted live iso

Download Gparted live iso image

# 64-bit
wget https://sourceforge.net/projects/gparted/files/gparted-live-stable/1.3.1-1/gparted-live-1.3.1-1-amd64.iso

# 32-bit
wget https://sourceforge.net/projects/gparted/files/gparted-live-stable/1.3.1-1/gparted-live-1.3.1-1-i686.iso

Step 3: Expand VDI disk

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/$USER/VirtualBox VMs/
cd  vm-name/

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 box-disk1-clone.vdi --format vdi
VBoxManage modifyhd box-disk1-clone.vdi --resize 50000

The commands above cloned box-disk1.vmdk tobox-disk1-clone.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 box-disk1-clone.vdi box-new-disk1.vmdk --format vmdk

Step 4: Modify Disks on VirtualBox

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 (1)

Step 5: Boot VM and use Gparted

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: Resize disk

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 (1)

resize-disk-16 (1)

resize-disk-17 (1)

resize-disk-19 (1)

resize-disk-20 (1)

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 partition.

That’s all. Your hard disk should be extended by now. To check run lsblk command on your Linux Guest OS.

lsblk

We hope this guide was of great help to you.

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.