First, resizing does not work if the guest has snapshots (prior to version 4.3.*) nor will it work on Fixed drives, nor on drives which are already larger than the selected size.
Secondly when doing anything that could prove as destructive as this should you make a mistake, backup the *.vdi file before you start.
Increasing the drive does not increase the primary partition so this is a two step process.
Step 1: Increase the size of the drive.
- For VirtualBox 6.0.x and later
Go to Virtual Media Manager:
- 6.1 & earlier: File menu > Virtual Media Manager
- 7.0 & later: File menu > Tools > Virtual Media Manager
Be doubly careful before pressing the "Apply" button, because you can only increase the VDI size, you cannot decrease it. But that wouldn't be a real problem because you made a backup of your data before trying this stuff, right?
- For VirtualBox before 6.0.x
Note: if the path has spaces in it you will need to wrap the path in quotes.
Use the following command to increase the size of the drive:Example: I have a 10GB drive that I want to be 20GB the command would be.
Code: Select all
VBoxManage modifyhd <absolute path to file> --resize <size in MB>
Code: Select all
VBoxManage modifyhd <absolute path including the name and extension> --resize 20480
Step 2: Extend the primary partition to include the new drive space.
- Download the GParted Live CD or whatever partition manager program you wish and mount it to the guests virtual CD and boot the guest. You can download the GParted Live CD from HERE. From here you can expand the primary partition to use the new space.
- Windows Vista and newer Windows guests can use the built in "Disk Management" tool to expand the primary partition.
Note 2: You can not shrink a guest drive with VirtualBox due to the inherent danger of losing data or making the guest non-bootable.
Note 3: In 4.3.0 the devs fixed a bug which had previously made it impossible to resize a snapshot. Since then it is possible, but not recommended for non-experts.