This will show you how to extend the virtual hard disk of any operating system running on VirtualBox; both vdi with virtual machine Virtual hard drive format. When I worked on a boring box downloaded from the internet, it only allocated 10GB. After filling up the space, I had to expand it so that more packages could be installed.
Here are the steps I need to complete. This guide assumes you are using Linux Guest OS, but I will let you know how to do it on Windows Guest and Windows Host. My host operating system is Fedora 23, and you can check out articles about important things after a fresh installation of Fedora 23.
If you are new to Vagrant and want to add a new box from an existing Virtualbox environment, check out this step-by-step guide on using existing virtual machines with Vagrant
So let’s get started. Please follow the steps below.
Step 1: Prerequisites
- A guest operating system installed on Virtualbox whose hard drive you want to expand
- VirtualBox installed
- The virtual machine to be modified must be powered off
- Gparted launches ISO in real time
Download Gparted Live ISO image
Go to the directory containing the virtual machine you want to modify. If you are using a vagrant
Then go to the VirtualBox VMs folder. In my case it was / home / josepy / VirtualBox VMs /, cd to the directory of the virtual machine
cd /home/josepy/VirtualBox VMs/ cd centos-asterisk/
If you use VMDK, you must first clone it to vdi. If your virtual hard disk is in vdi format, you can directly resize it. The name of my vmdk file is box-disk1.vmdk.
VBoxManage clonehd box-disk1.vmdk centos-asterisk.vdi --format vdi VBoxManage modifyhd centos-asterisk.vdi --resize 50000
The above command copies box-disk1.vmdk to centos-asterisk.vdi so that we can resize it. VirtualBox does not support resizing of .vmdk disk types.
If you want to convert the newly resized vdi to vmdk, you must clone it again, e.g.
VBoxManage clonehd centos-asterisk.vdi box-new-disk1.vmdk --format vmdk
Open the VirtualBox GUI and click on your VM, then click Settings> Storage> IDE Controller> Add Optical Drive (round icon on the right)> point to the downloaded Gparted iso and add it.
Click on “IDE Controller”> “Add Hard Drive” again and point to the newly resized vdi or vmdk. Mine is centos-asterisk.vdi. See the screenshot below for clarification.
After that, on the same virtual machine GUI, go to Settings> System> Motherboard> Boot Sequence. Then, uncheck the hard disk, then select Optical, and click the OK button at the bottom to save the changes.
Start the VM by clicking the start button and select Gparted Live on the gparted boot menu that appears. Use the default settings by pressing Enter until you reach the gparted Partion menu.
This is the focus of our work to get the extended drive up and running.
Click Partitioned Drive> (Resize / Move). Now, hold down the CTRL key and drag the black arrow to the end.
Or add free space after + new size, then put the sum on the new size area, click to adjust the size of the applied changes, and exit.
After shutting down the virtual machine, return to the settings and uncheck Optical under the boot order and select the hard disk. Also remove the iso added under the IDE Controller menu option.
For WINDOWS GUEST operating system
If you have adjusted the hard disk size of the Windows Guest OS, open DISK PARTITION MANAGER and expand the Windows partition.
that’s it. Your hard drive should now be expanded. To check the run lsblk command on Linux Guest OS.
How to resize a VirtualBox virtual hard disk on Windows
How to resize VirtualBox virtual hard disk on Linux
Resizing Guest OS virtual hard disk on Windows
Resizing Guest OS virtual hard disk on Linux
You can check out another tutorial on how to add VirtualBox Guest Additions to Guest OS below.