Resizing a VirtualBox Disk (vdi)

From GlassTTY
Jump to: navigation, search

With no VirtualBox running, use Terminal to navigate to the VirtualBox app directory:

   cd /Applications/VirtualBox.app/Contents/Resources/VirtualBoxVM.app/Contents/MacOS/

Clone the Disk

First clone the disk using the command below. The resize process only works on dynamically allocated disks. Cloning the disk will create a dynamic disk clone which can then be resized. Naturally, if the disk you wish to resize is already dynamically allocated then the clone is an optional, but recommended, step.

   VBoxManage clonehd [current disk] [new disk]

For example to clone a disk the command could be...

   VBoxManage clonehd "/Users/johnnewcombe/VirtualBox VMs/Arch Linux/Arch Linux.vdi" "/Users/johnnewcombe/VirtualBox VMs/Arch Linux/Arch Linux Dynamic.vdi"

Increase The Disk Size

Run the VBoxManage application to modify the disk

   VBoxManage modifyhd --resize [new size in MB] [/path/to/vdi]

For example to increase a disk from 32Gb to 64Gb...

   VBoxManage modifyhd --resize 64000 "/Users/johnnewcombe/VirtualBox VMs/Arch Linux/Arch Linux Dynamic.vdi"

The showhdinfo command can be used to verify the change.

   VBoxManage showhdinfo "/Users/johnnewcombe/VirtualBox VMs/Arch Linux/Arch Linux Dynamic.vdi"

Relaunch VirtualBox and boot to test the disk.

Note that it is not possible to rename the disks after the cloning, otherwise a registry error will occur.

Expand the OS Partition

Shutdown the VM and, using the VM settings, attach the GParted Live (iso) disk image to the CD controller. The image can be downloaded from https://gparted.org/download.php.

Use the GParted Move/Resize option to expand the existing partition to use the new space.

Reboot and enjoy!