My Blog

Resizing a VirtualBox 5.1.4 HDD vdi file

by Chris Carlsen-Jones on 10th February 2017 10 comments

Here is how you can resize a VirtualBox Hard Disk (vdi) file. I found a couple of blogs about this but they didn’t quite work for me so here is the process I followed. You will need to download and use a third party Partition Editor, I used the GParted GNOME Partition Editor. If you don’t want to go down this route you could just add another hard disk, a blog on how to do that is here.

I am using VirtualBox 5.1.4 running Linux R7U2, there are also blogs about installing VirtualBox and creating a Linux 7 VM.

Before you start this process ensure your VM is closed down (not suspended), and close the VirtualBoxManager.


Open a Command Prompt window, on your host system and set the path to your VirtualBox installation.


Then use the command below to resize the vdi file:             (the size is in MB)

VBoxManage modifyhd <absolute path including the name and extension> –resize 20480

e.g. VBoxManage modifyhd C:\oracle\VirtualBox\VMs\ora12c\ora12c.vdi –resize 163480


Next we need to resize the Linux partition to use the space of the larger vdi file.

To do this we need the GNOME Partition Editor.

This can be downloaded from


Click on the link to to ‘Install GParted Live on CD’., and then on the link below

Stable directory (.iso/.zip)
(for i686, i686-pae and amd64 architectures)

Then click on the link below.


Then download the gparted-live-0.26.1-4-i686-pae.iso file.

Start the VirtualBox Manager and create a new Linux VM.


Enter a name and a version of Linux, then press Next.


Set the memory, then press Next.


Then pick the option not to add a disk, and press Create.

Press Continue at the warning about creating a VM without a disk.


Next, click on settings / storage / IDE controller, then press the Add Optical Disk icon,


Press the Choose Disk option.


Then browse to your GParted file and press Open.

If you have second empty drive, remove it.


Go back to settings / storage, then select the SATA controller and press the add Add Hard Disk icon.


Then press Choose Existing Disk.

Browse to the vdi file you are resizing and press Open.


Now, start the GParted vm.


Select the GParted Live (default settings) option and press Enter.

Select any default settings, then choose your language.

Then select 0 to run GParted automatically.

We then have the VM running.


Select the partition you want to resize, e.g. /dev/sda2, then press Resize/Move.


A Resize dialogue opens.


Enter the new size, select the Free Space opton: MiB, then press Resize.


Then press Apply to action the change.

Then press Apply again to confirm.


Then press Close.


We have now allocated the free space.

You can now shutdown the DParted VM.

Now start your original VM, the vdi file is still associated with.

Login as root, open a terminal window and use the fdisk -l command.


(The linux fdisk utility shows 1kB blocks so /dev/sda2 is about 160GB)

We added 100GB so we’ll try and use 99GB, some space will be reserved by the OS.

Next grow the logical volume:

lvextend /dev/mapper/ol-root -L+99G


Use the lvdisplay command and we can see the size is now 137GB.


Then you need to extend the file system on the logical volume:

fsadm resize /dev/mapper/ol-root

(If you don’t specify a size the file system will use all the available space.)


Now check the situation with the df -h command.


We have another 100GB of free space.

Shut down the VM.

In the VirtualBox Manager you can right-click on the DParted VM and remove it, and select the option to “delete all files”. (Our vdi file was in our original VM folder, not in the new DParted VM folder, so we only deleted the files created for the DParted VM.)


Chris Carlsen-JonesResizing a VirtualBox 5.1.4 HDD vdi file

Related Posts

Take a look at these posts


Join the conversation
  • Gary - 13th June 2017 reply

    Just wanted to say that your method worked perfectly for me after a few other methods did not. Thanks for the tutorial! -gary

  • Leo - 16th September 2017 reply

    Thanks for your post. I had to take some intermediate steps but in the end it worked.
    The first problem i faced was that I had snapshots. You have to get rid of these before resizing the drive.
    Second I had the problem that my swap partition was between my main partition an the unallocated space.
    To move the swap partition to the end of the drive I had to use partition logic. After moving the swap partition I was able to resize my main partition using gparted as described.
    As I had no logical volume I was able to skip the last step.

    Chris Carlsen-Jones - 18th September 2017 reply

    Leo, Thanks for the comment, I’m sure this will help others trying to complete this task.

    silverweb - 9th November 2017 reply

    hi! When swap is in your way to resize, just create a new one at end of the unallocated space and remove the old one. Then do the rest. 🙂

  • silverweb - 9th November 2017 reply

    hi! Thanks for your tutorial. It works. 🙂
    I just didn’t have to lvexted the drive – i don’t even have the command. System swallowed the new size it itself. Great! 🙂
    I use the VM for my local linux server for PostgreSQL+Apache2 tests. And I went out of space on my root drive… :\

    Thank you. 🙂

  • Jani - 26th January 2018 reply

    This did not work for me. Oracle’s own tool could not handle the .VDI. Little searching and I found in the VirtualBox forums. Not only did that manage the task in a user friendly GUI, but it also took care of the guest OS partition resizing. Furthermore, it automatically clones your VM (unless you specify otherwise) so you don’t even need to make copies. Why isn’t Oracle giving us tools like that?

  • Ping - 27th February 2018 reply

    I tried to follow the instruction and got stuck on gparted. When the Resize dialogue opened, the maximum size stays the same as the original size. The new unallocated size was not added to the maximum size. Has anybody seen that and how can I get beyond that? Thanks!

  • Greg - 27th February 2018 reply

    Thanks for this. It worked for me – CentOS 6.5 guest

  • Mike - 14th March 2018 reply

    Thanks for taking the time to write up this guide. Worked perfectly! Cheers!

  • Anjul Sahu - 3rd April 2018 reply

    This is working as expected. There are other links on the web but those are half baked. Thank you.

Join the conversation