How to increase the size of your VirtualBox HDD WITHOUT losing any Data

Has it ever happened that you are working on a dev Virtual Machine and suddenly you realised that you have run out of hard disk space ? And then, you had to do the tedious job of manually transferring all your changes, repos, config files, etc. to a new VM ? Well, in this post, I am going to tell you how to increase the size of your Virtual HDD, whether the HDD is in the native VDI format or a different format like VMDK, without losing ANY data and continue your work.

Virtualbox Logo

The steps mentioned in this post are for *NIX OSes like Linux and Mac OS. I have personally performed this on the Mac OS X 10.9 (Mavericks), but the exact same steps are applicable for Linux. I guess, there should not be any different for Windows either.

A quick background : The reason I wanted to increase my Virtual HDD size is because I ran out of space trying to download the Android source code. That’s right, I am trying to build Android from scratch and after downloading 17GB  of source code from the Cyanogenmod github repos, over a period of 5 days, I suddenly ran out of disk space. The Android story is for another day, another post.

As mentioned earlier, I have performed this on a Mac OS X Host machine with Ubuntu 12.04.3 (32-bit) as my Guest OS. The VM had a mere 20GB HDD and that too I had configured as a VMDK disk as opposed to the native VDI (Don’t ask!!)

So, without further ado, here’s how the magic happens :

Step 1a) : Backup your disk

Can’t stress this enough. Always, …. Always backup your disk. If I had to download 17GBs again, I would have to kill someone first to justify the action.

Now, you can’t just “cp” your virtual HDD file and hope it will work with your VM. There’s a whole lot of UUID issues with VirtualBox. To cut a long story short, don’t “cp”. Execute the following command instead :

$ VBoxManage clonehd <path to>old_ubuntu_hdd.vdi <path_to>backup_ubuntu_hdd.vdi

With this, VirtualBox assigns a different UUID to the backed up vdi and you can use this HDD as if it were your old one.

Now, if I were you, I would do just that. To be on the safe side, Release your current HDD from the Virtual Media Manager GUI tool.

VirtualBox Media Manager


Then go to your VM’s settings and add the newly backed-up VDI as the HDD for your VM. Then boot into it and verify that everything looks good.

Ok, We’re done backing-up. Unless, you are like me and had configured your virtual HDD in Vmware’s VMDK format.In that case, you need to execute Step 1b) below rather than Step 1a) above.

Step 1b) Convert your disk to VDI and backup your disk

Actually, it’s exactly like Step 1a) above ,except that you have an additional parameter to VBoxManage. Execute the following command :

$ VBoxManage clonehd <path to>old_ubuntu_hdd.vmdk <path_to>ubuntu_hdd.vdi --format VDI

Again, as above and especially after the conversion, make sure that you bootup the backed-up HDD and ensure that you can everything is working.

With our HDD safely backed up, lets tread on to more dangerous waters !!

Step 2) Increase the size of your Virtual HDD

This step is actually the easiest step. Just execute the following command :

$ VBoxManage modifyhd <path_to>Ubuntu_Hdd.vdi --resize <size in MB>

For example, in my case , I wanted to increase the size to 100GB, so the command was something like this :

$ VBoxManage modifyhd ./AndroidDev.vdi --resize 102400

That’s it !! We are done increasing the HDD. You can check this my opening the VirtualBox GUI tool , selecting your VM, clicking on Settings, then Storage and checking-out the value of the “Virtual Size:”

In my case it shows 100GB.

Forward march !!!

Step 3) Increase the size of the Linux Guest OS partition

With the above step, if you try to boot, you might either get an error, or see the same disk size from the Guest OS. What we need to do is resize the filesystem of the GuestOS to match the size of the partition or HDD we just increased.

For this, you need another Live Linux CD/DVD/iso like Ubuntu or GParted. Actually, we are going to use the gparted utility to do the resizing. So, as long as you have any OS which has this tool, it’s ok.

Now, add the Live Linux CD/DVD/iso to your VM and boot into.

Fire up Gparted session and resize your filesystem


That’s it !! That’s truly, finally it !!!

You have successfully resized your virtual hard disk keeping intact all your data.

I, have successfully resumed downloading the Android source. 

Related Posts
After my last article on eLearning, I came across yet another resource of free online Linux courses. Brajeshwar , who has started writing a stream of articles on Linux lately, has ...
7 Linux Distros reviewed
I'm a little late in posting this article, since most of the Distros mentioned here are out with newer versions. But since  it was so informative, I thought I'd post it ...
I had written briefly about Virtualisation and the different avtaars currently available. I recently found this article comparing the four leading Virtualisation techniques on Linux. Although I had covered the popular ones ...
eLearning Open Source
OpenVarsity is an initiative for eLearning, or learning with online tutorials, Open Source and Free Software technologies. As soon as I saw the first prototype of it's course I was convinced ...
Linux on Refrigerators using Enlightenment
It is said that NetBSD is one of the most ported Operating Systems in the world. It runs on almost everything, from massive Servers to even a Toaster. Well, Linux isn't ...
Codeweavers boost Linux Migration
Codeweavers, the company which gave us the award-winning software to run MAC OS and Windows software on Linux, is giving it's full support in Lindependence '08. Lindependence '08 is a community ...
Ubuntu 9.04 Upgrade : The Screenshot tour
I have been upgrading my work Laptop (a Dell D630) since Ubuntu 7.04. The first couple of times there were a few glitches, nothing a few Google searches and "sudo apt-get ...
Another Runner in the Race
After RoadRunner , IBM's supercomputer with 6,480 dual-core processors, running Red Hat Enterprise Linux, it is now the FreeRunner. OpenMoko's Neo FreeRunner, running on Linux OS, is being made available to ...
One of my former colleagues and friend, Pranav Peshwe, pointed me out to this company called MPC Data who has developed a solution called swiftBoot. Using swiftBoot, these people have managed ...
I hate to Pray… or worship…. especially non-existent creatures like God. But everytime I don’t attend a Pooja or refuse to enter a place of worship, I see the look ...
Free Linux Online Courses
7 Linux Distros reviewed
More on Virtualisation
eLearning Open Source
Linux on Refrigerators using Enlightenment
Codeweavers boost Linux Migration
Ubuntu 9.04 Upgrade : The Screenshot tour
Another Runner in the Race
Booting Linux in under one second using swiftBoot

Leave a Comment!

Write your comment