Photo by 铮 夏 on Unsplash

How to increase the disk/storage size of VirturalBox VM on MacOS

Rocky Chen
4 min readFeb 23, 2021

VirtualBox is a free and open-source hosted hypervisor for x86 virtualization, developed by Oracle Corporation. I used it for running a VM of Windows on my MacOS. But Windows kept eating disk spaces and 50GB becomes inadequate recently.

Therefore I have to enlarge the disk size of my VM but it is not straightforward since the size is not configurable in the setting of VirtualBox.

Here are my steps to enlarge the storage size of this VirtualBox VM.

My VirtualBox VM version: 6.0.24 r139119

My MacOS version: macOS Catalina 10.15.7

Backup the VM files — Important!

First, backup the VM files before any changes. It’s easy to backup by duplicating the folder of the VM files.

Note, the VM should be shutdown first before the folder being duplicated.

Retrieve the virtual disk location

Here is the file location of the virtual disk which is used in the next step:

Run VBoxManage command to increase the size

Now, open a terminal window and check the current disk info:

$ VBoxManage showhdinfo "/Users/rocky.chen/VirtualBox VMs/Windows10/Windows10.vhd"UUID:           xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Parent UUID: base
State: created
Type: normal (base)
Location: /Users/rocky.chen/VirtualBox VMs/Windows10/Windows10.vhd
Storage format: VHD
Format variant: dynamic default
Capacity: 51200 MBytes
Size on disk: 44444 MBytes
Encryption: disabled
In use by VMs: Windows10 (UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

Then, resize the disk with command below:

$ VBoxManage modifyhd --resize 81920 "/Users/rocky.chen/VirtualBox VMs/Windows10/Windows10.vhd"0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

After resize, let’s check again about the disk info:

$ VBoxManage showhdinfo "/Users/rocky.chen/VirtualBox VMs/Windows10/Windows10.vhd"UUID:           xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Parent UUID: base
State: created
Type: normal (base)
Location: /Users/rocky.chen/VirtualBox VMs/Windows10/Windows10.vhd
Storage format: VHD
Format variant: dynamic default
Capacity: 81920 MBytes
Size on disk: 44446 MBytes
Encryption: disabled
In use by VMs: Windows10 (UUID: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

It looks good.

Launch VirtualBox

After launching VirtualBox, let’s check the size of disk again:

The size got updated with the new value.

However, another step is needed to re-allocate disk partition with GParted.

Re-Allocate Disk Partition with GParted

GParted (GNOME Partition Editor) is a tool for creating, reorganizing, and deleting disk partitions. It could be downloaded here.

Attach GParted ISO file to the VM

After downloading the GParted ISO file, attach it to the VirtualBox VM:

Launch the VM with GParted ISO

Launch the VM with the GParted ISO and select the default settings:

Keep the keymap untouched if unnecessary.

Then, it enters the main UI of GParted:

It shows 3 existing partitions with the new allocated 30GB disk space.

/dev/sda2 is the disk I want to resize, but there is a /dev/sda3 between /dev/sda2 and unallocated space. Therefore, I need to move the unallocated space ahead of /dev/sda3.

Resize the disk

Right click the /dev/sda3 and select Resize/Move option.

In the Resize/Move window, swap the value of Free space preceding and Free space following.

Here is what it should like:

Then, resize the /dev/sda2 to include the unallocated space:

There should be 2 pending operations after resizing /dev/sda2.

Finally apply the changed by clicking the check mark on the top toolbar.

Close the box and shutdown the VM after the applying completed.

Launch the VM

Before launching the VM, just remove the ISO file from the VM settings.

After logging into the Windows, the disk gets the new space value now!

--

--

Rocky Chen

SRE | Cloud Engineer | AWS Certified Solutions Architect – Professional