Recently I started using VirtualBox in order to install and run multiple operating systems on my laptop for testing purposes.
What is VirtualBox:
Oracle VM VirtualBox is a cross-platform virtualization application. What does that mean? For one thing, it installs on your existing Intel or AMD-based computers, whether they are running Windows, Mac OS X, Linux, or Oracle Solaris operating systems (OSes). Secondly, it extends the capabilities of your existing computer so that it can run multiple OSes, inside multiple virtual machines, at the same time. (source)
When you first install VirtualBox, it creates a virtual disk for your new operating systems to use. Sometimes the disk is not big enough and you’ll find yourself trying to resize the disk.
How to Resize VDI Disk
The process contains 2 parts:
A. Resize the VDI file
B. Resize the partition
A. Resize the VDI file
- Shutdown VirtualBox.
- Open Command Line (CMD) with administrator privileges.
- CD to the location of the VDI file (in my case it’s C:\Users\Shay\VirtualBox VMs\Windows7)
- VirtualBox contains a command line tool called “VBoxManage.exe”. Locate it (in my case C:\Program Files\Oracle\VirtualBox\VBoxManage.exe) and copy the full path to it.
- While in the folder where the VDI file is, type the following:
- “C:\Program Files\Oracle\VirtualBox\VBoxManage.exe” modifyhd yourvdifilename.vdi –resize 25000
- 25000 represents 25GB. Use 50000 for 50GB etc.
- The result should look like this: 0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
B. Resize the partition
Now that we resized the VDI file, we need to resize the partition. Otherwise the extra space would simply be “unused space” or “unallocated space”.
- In order to resize the partition, we need to work with a partition editor / manager. We will use Gparted live. GParted is a free partition manager that enables you to resize, copy, and move partitions without data loss.
- Download GParted Live here: https://gparted.org/download.php
- While downloading, go back to VirtualBox, and create a new virtual machine.
- Call the new machine “Gparted Live”, and choose the type “Linux 2.6 / 3.x / 4.x”.
- Do not add hard drive to this machine.
- Now we need to attach the Gparted Live Iso file we downloaded in step 2.
- Go to the settings of the newly created Gparted Live machine. On the left sidebar, go to storage.
- Under “Controller: IDE” add a new optical drive. Choose the Gparted Live iso you downloaded in step 2.
- The next step is to add the disk that you want to resize under the “Controller: SATA” section.
- Hit ok and start the Gparted Live machine.
- Screen: choose “Gparted Live (Default Settings).
- Screen: choose “Don’t touch keymap”.
- Screen: hit enter to choose English (number 33).
- Screen: choose “(0) – continue to start X to use Gparted automatically”.
- Now choose the partition you’d like to resize, choose the size you’d like to allocated and hit apply.
- MAKE SURE YOU CHOOSE THE RIGHT PARTITION!
Watch this video to get some more info: