While setting up virtual machine in VirtualBox, we usually setup with the lowest recommended size for storage space (20GB), so it doesn’t consume much of our HDD. However, on course of the use, we may install more apps and save more data in VM, then we find that 20GB of storage space was hardly enough. We feel the need of more storage space.
For that we need to increase the size of our virtual HDD. To resize the virtual HDD, VirtualBox porvides ‘modifyhd‘ command to modify the options of our virtual HDD
VBoxManage modifyhd path/to/vdi-file --resize X
‘X’ in the command refers to the amount of space (in megabyte) that we want to resize to. i.e. If we want to resize form 20GB to 30GB, the command is:
VBoxManage modifyhd path/to/vdi-file --resize 30000
However, if the virtual HDD is of fixed default format variant (fixed allocated image), the command will not work as resize only works in dynamic default format variant (dynamically allocated image). It will give the following error:
We can check the HDD info with following command:
VBoxManage showhdinfo /path/to/vdi-file
For such case, we will first clone the existing virtual HDD of fixed format variant.
VBoxManage clonehd /path/tp/vdi-file /path/to/cloned-vdi-file
Now check info of the cloned vdi file
VBoxManage showhdinfo /path/to/colned-vdi-file
Check the Format variant section. Clone vdi file is dynamic default format variant (dynamically allocated image).
Now we can resize our cloned virtual HDD as per requirement with modifyhd command and use in our VM.
VBoxManage modifyhd path/to/cloned-vdi-file --resize 30000
We should see the progress bar. The resizing process is completes after it reaches 100%.
Next step is to get the respective OS to recognize the increase in storage space by allocating the unallocated storage space.