Data Centers

How to resize a VirtualBox VM from the command line

Resizing VirtualBox VMs is easy, when you know the right commands and third-party tools to use. Here's everything you'll need.

Image: Jack Wallen

If you happen to employ VirtualBox as your virtual machine technology, chances are you've come across an instance or two where you've needed to resize the drive you've created for your virtual machine. If that's the case, you've probably checked into the GUI for a setting option that might allow you to take care of that the easy way.

Unfortunately, that particular GUI control doesn't exist. Sure you can attach a new drive to the VM, but growing the size of the main drive is beyond the scope of the GUI. Instead, you are relegated to the command line. Fortunately, the developers of VirtualBox have made this process quite simple. I will warn you, depending upon your guest operating system, you will have to follow through with extra steps (more on that in a bit). But first, let's find out how to grow that original drive.

The VBoxManage command

The command we will be using is VBoxManage. I will be demonstrating on an Elementary OS host with a Ubuntu Server 16.04 guest. With that in mind, open up your terminal window and get ready to type.

I'm going to be resizing a VM named NGINX.vdi from its original 16GB to a 30GB disk. Surprisingly enough, you can manage this task if the virtual machine is either shutdown or in a paused state (however, not when it is running). To do this, the following command will be run (from within the directory housing the .vdi file):

VBoxManage modifyhd NGINX.vdi --resize 30000

Surprisingly enough, that command will complete very quickly. You can then go into the VirtualBox GUI, select the VM in question, click Settings | Storage, and see the size is now at (or very near) 30GB (Figure A).

Figure A

Figure A

Our newly sized virtual machine.

The virtual machine is now capable of a full 30GB. However, if you're using a Linux host, you have to make use of a third-party tool to resize your virtual machine drive to have the full size available.


The tool you need is GParted. Download the .iso file. Once that is downloaded, shut down your VM, go into its settings and then click Storage. Click Controller: IDE in the Storage Tree, click the + button for Add new storage attachment, and then click Add Optical Drive (Figure B).

Figure B

Figure A

Adding GParted as an optical drive.

Click Choose Disk, navigate to where you downloaded the GParted ISO, and select it. Click OK and then start the VM. This should now boot into GParted, where you can then resize the Linux partition to take advantage of the newly created space.

You must first right-click the active partition and select Deactivate. Once you've done that, you can then right click the partition and select Resize/Move and then resize the partition to use the unallocated space. Apply the changes, shut down the machine, remove the GParted ISO from the Storage Tree, and you're good to go.

Very handy

This process will come in very handy, especially when you've miscalculated the space necessary for a virtual machine. With a few quick steps, you'll have your VMs stretching their legs with enough room to grow.

Also see

About Jack Wallen

Jack Wallen is an award-winning writer for TechRepublic and He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website

Editor's Picks

Free Newsletters, In your Inbox