I've been using VirtualBox pretty happily for the past couple of months on my commodity Windows laptop, but recently made a pretty unpleasant discovery. The install wizard had some poor wording in regards to setting up hard drives. They encourage a very small drive (8gb on my machine), and the installer says that it's dynamic. Unfortunately this doesn't mean that the drive grows as needed. It got to where I couldn't pull from the git repo I was working on.

After much frustration, I managed to increase the size of my guest Ubuntu VBox drive. This is what I did. (If you have saved snapshots of your partition see this before continuing!)

On the Windows host system, find the VBoxManage.exe file and the .vdi file that is your virtual linux HD. Run VBoxManage with the following params: modifyhd (path_to_your.vdi) --resize (size in MB).

This is what my command looked like:

c:\Program Files\Oracle\VirtualBox>VBoxManage.exe modifyhd "C:\Users\LMason\VirtualBox VMs\ubuntu\ubuntu.vdi" --resize 32768

After this, I could see from looking at the VirtualBox window, the HD was properly set to 32GB:

To the best of my knowledge, Ubuntu lacks a built in tool to resize its partitions. For this, I downloaded the latest ISO of GParted, then shut down my Ubuntu machine went into its Vbox Settings->Storage, added an IDE controller and loaded it with the gparted-live.iso, and checked the live CD/DVD box.

Then I restarted the Ubuntu box and it booted to GParted. I saw a display with my main partition on the left, my swap partition next to it, and a huge unpartitioned block to the right. At first, it still wasn't clear how to increase the size of either partition. When I selected a partition and clicked resize, the increase arrows were grayed out and I could only decrease the size of the partitions. After a while, I discovered that in GParted, a light blue border around a partition means that it can't be moved and that no other partition next to it may grow in its direction.

The key is to delete the swap partition first. After that, I was able to move it's container to the far right end of the unpartitioned area, set the size I wanted for it and then create a swap partition inside it. Then with nothing next to the main partition, it was able to grow to take up the full space available.

Leave a Reply

Your email address will not be published. Required fields are marked *

9 replies
  • Tim says:

    Hey, wanted to say thanks for the article.

    Three things to point out.
    1. The size you defined, of course, equals 64GB, not 32GB in case anyone gets confused.

    2. Gparted is also on the Ubuntu Live disks, in case anyone has those and doesn’t want to download gparted.iso.

    3. This one bit me hard for a while, it seems that gparted will not see the new space allocated with this method if you happen to have any snapshots prior to the resize process. DO NOT follow this process if you have snapshots that you don’t want to loose, and even more, DO NOT try to then delete your snapshots after expanding, rather revert to the most current snapshot from before the resize command.

    Find another tutorial online that walks through backing up the contents of the vdi with clonezilla or something else, and moving it to a fresh vdi, then you have your archival snapshots in the old one just in case.


  • admin says:

    Thanks for the comments, Tim! I was waffling a bit on whether I wanted 32GB or 64GB and must have taken the screenshot before making up my mind for good. I edited the post to allocate 32GB so as not to be confusing.

    I had no idea about the issue with snapshots. Thanks for the heads up.

  • Hi, Neat ρost. Тherе’s an issue along with your web site in internet explorer, may test this? IE still is the marketplace chief and a big portion of folks will leave out your excellent writing due to this problem.

  • John says:

    Thanks for your help,
    Have been looking around for a solution but this one finally did the trick.

  • Danny says:

    Thanks. It worked for me. @tim, thanks for the tip on running gparted from the ubuntu iso.

  • Sandeep says:

    Unfortunately, this is not working for me, may be I am doing something wrong or I might be missing some steps here. Basically when I boot using GParted iso and my vdi file as the SATA controller, I get some boot options from GParted and once I chose GParted Live (Default), it just hangs there with a BLACK BLANK screen. Please help as I badly need to resize my partition.

  • Cameron says:

    Thanks, this was the only thing I could find with clear enough instructions to help me finally get the Ubuntu disk size to what I needed it to be.

  • Bjorn says:

    Thanks for a good tutorial.
    It’s very straight forward if you dont have any snapshots saved.

    worked perfect for me =)