This is a quite common problem for the VirtualBox user: after some time, you find the original image disk size is not enough and want to make it larger. How to make it?
Use the VirtualBox utility tool “VBoxManage” to resize the image file(from here). You can find the “VBoxManage” tool inside the VirtualBox installation directory. Run the following commands:
# 1. If you image file is "vmdk" format, you need to run the following command to convert it
In some posts, such as this one, they implies we can use the resized image file to overwrite the existing image file for an existing VM, then the VM works. But after I tried this, VirtualBox reports error when starting the VM. It seems VirtualBox has some verification on the image file. In our case after we modify the image file VirtualBox refuses to run on it.
So what I did is to create a new VM in VirtualBox by indicating the resized image file as the storage disk. It just works.
Go to VirtualBox “Machine -> New”, then in the wizard, remember at the “Hard drive” step, select the “Use an existing virtual hard drive file” option and use the resized image file in the last step.
Now you bigger size “hard drive” is ready, but your “hard drive” partition information is not changed which means the added space cannot be used. So we need to use the “gparted” tool to update the partition info.
First you need an ISO file that have the “gparted” utility. This post said using the official “gparted” iso file, but it cannot boot the WM with it in my VirtualBox. So I refer another post to use the official Ubuntu ISO file.
Add the ISO file into the CD drive in the VirtualBox storage setting and make sure the boot sequence is using CD drive before hard drive. Start the VM, select “Try Ubuntu”, start the “gparted” tool. It’s very straightforward to change the partition info to add the new space into your existing partication. After that, restart the VM and you should see the added disk space.