Resizing a VirtualBox .VDI virtual hard-drive file

In my last post, I created a Ubuntu VM in VirtualBox, but only used the default size of 8Gb for the size of the virtual hdd.  For some small applications, this may be ok, but it can be a large handicap when working on larger projects or with multimedia.  If I wanted to have a bigger hard-drive, I’d have two options: either create a new .VDI file, or resize the existing one.  Creating a new file would require reinstalling Ubuntu to it, along with all my programs and files, so we are going to opt for resizing our existing file instead.  In order to do this, we need access to Terminal and a Ubuntu(or other Linux distro) Live CD image.


The first thing we need to do is physically resize the file.  VirtualBox comes with a nifty command for doing this called “vboxmanage” that allows you to modify many aspects of your VM.  Enter the command below, substituting in the Absolute Path to your .VDI file  and the size in Mb of how large you want your .VDI to be.

vboxmanage modifyhd [AbsoluteFilePath] –resize [SizeInMb]

Once your file is modified, open up VirtualBox, and startup your VM.  Select “Devices > CD/DVD Devices > Ubuntu.iso” from your host OS’s menu bar, which will tell your VM to boot from the live CD instead of the .VDI on its next reset.  Press “R” to reset the system, and reboot the pc.

Once it boots you should again be faced with “Try Ubuntu” and “Install Ubuntu”.  This time, we are going to choose “Try Ubuntu”.  When your desktop loads, go to the Dashboard, and search for GParted.  Run it, and you should be faced with a  screen allowing you to modify your hard drive partitions.  Modify your partitions following the instructions in the video, and apply the changes.  Shutdown your VM, and on the next boot up, you should have access to all of your new space!

Installing Ubuntu with VirtualBox

In this guide, we will be creating a virtual machine, using the VirtualBox software, and running the Linux distro Ubuntu inside of our host operating system.


To start, head on over to the VirtualBox website, and download the latest version of the VirtualBox software for your Operating System.  It should be a fairly straightforward install process.

Next, head to the Ubuntu download page, and download a Ubuntu .iso file.  You can select either the 64 bit version, or the 32 bit version.  I would recommend the 64 bit, because it is a more modern architecture built for better computers.


With both of these items fully downloaded to your computer, open up VirtualBox.  Hit “New” at the top-left, and name your Virtual Machine.  If the name you choose includes the word “Ubuntu”, then it should automatically fill in the two boxes below.  Otherwise, change “Type” to “Linux” and “Version” to “Ubuntu”.  Hit “Continue”.

Here, it will ask you to allocate RAM to your VM.  This can be any amount, but whatever number you choose will affect your VM’s speed.  I chose 2 Gb, to shorten my build times in later videos.

In the next screen, it will ask how you want it to do the Hard-Drives.  Opt to create a Virtual Hard Drive.  In the prompt that follows, choose to create a .VDI file, and choose an allocation type.  The two types have their own advantages/disadvantages, some of which I detail below:

Dynamically Allocated:

  • Pros: Takes up less space on your HDD if your Virtual Drive is not completely full.  Also takes less time to generate initially.
  • Cons: Slower IO times when running your VM, because VirtualBox has to allocate more space as you use it.

Fixed Size:

  • Pros: Faster IO times inside VirtualBox, because the file is already created, and you are just overwriting the data.
  • Cons: Full-Size file is created from the start, so it takes up more HDD space from the beginning.

It should then prompt you for a size.  Pick something large enough to store all you need to, but not large enough to be cumbersome to your host OS.  It is possible to resize a .VDI file later, as seen in this post, but this process is best to be avoided.


At this point, you should have completely set up your VM.  Go ahead and select your VM from the list on the left, and hit “Start“.  You will soon see a prompt asking you to locate your CD Image.  Navigate to your Ubuntu ISO, and select it.  VirtualBox will boot into the Live CD version of Ubuntu.  You should quickly see a prompt asking if you want to Try Ubuntu, or Install Ubuntu.  Choose to Install it, and follow the prompts.  It should be pretty straight forward from here, up until your desktop gets fully booted up.

Once you finally get to the Ubuntu desktop, there is one final step.  In order to ensure full compatibility with VirtualBox, Oracle has created a small software package for you to install to ensure the best experience.  Go to “Devices” in the Menu Bar of your host OS, and hit “Install Guest Additions“.  Let the process run its course, and you should be good to go.  Let me know in the video comments if any part of this was unclear!