Virtual Box - Disk

About

there are two options of how to create a disk image:

  • fixed-size
  • or dynamically allocated.

Type

Fixed Size

An image file will be created on your host system which has roughly the same size as the virtual disk's capacity. So, for a 10G disk, you will have a 10G file.

Dynamic

  • Initially very small
  • Grow every time a disk sector is written to for the first time, until the drive reaches the maximum capacity

Management

With two tools:

  • or the virtual manager gui (<note tip>Don't forget to open it again after modification at the command line with VBoxManage</note>)

List

VBoxManage.exe list hdds
.............................
UUID:           75f8ad10-ea21-4428-8963-3e8b039c0843
Parent UUID:    base
State:          inaccessible
Type:           normal (base)
Location:       D:\tmp\resized.vmdk
Storage format: vmdk
Capacity:       40960 MBytes
Encryption:     disabled
...................

Delete

VBoxManage.exe closemedium disk <uuid> --delete

Resize

The modifyhd works only with VHI and VHD format for vmdk, you need to clone it first.

  • Clone to vdi
VBoxManage clonehd "source.vmdk" "cloned.vdi" --format vdi
# VBoxManage.exe clonemedium /home/Users/gerard/.docker/machine/machines/default/disk.vmdk disk.vdi --format vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vdi'. UUID: 7daa25c4-4297-4b72-bf61-11077fbfc2bf
  • Modify Logical Volume Size
VBoxManage.exe modifyhd cloned.vdi --resize 40960 # 40Gb
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
  • Back to vmdk
VBoxManage clonehd "cloned.vdi" "resized.vmdk" --format vmdk
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'vmdk'. UUID: 75f8ad10-ea21-4428-8963-3e8b039c0843

Documentation / Reference


Powered by ComboStrap