How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

June 18, 2018
How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

“How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System” covers the entire process of resizing a Windows 10 virtual machine VDI on an Ubuntu 18.04 LTS host operating system. In this example, I have a Windows 10 virtual machine configured to use a 50GB virtual disk image. Recently, an enormous update was pushed to the machine and the 50GB of space that was initially allocated to the virtual machine is no longer reasonable. We will resize the VDI to a reasonable size of 100GB and configure our virtual machine to use the entire 100GB of allocated space. Ensure that your virtual machine is powered of before continuing with this tutorial.

1. Launch VirtualBox and highlight the virtual machine that you will be editing in the pane on the left side of the application window.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

2. Click the Settings button in the ribbon at the top of the application window.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

3. In the dialog box that appears, navigate to Storage on the left, then click on your VDI to view its properties.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

4. As you can see from the image above, this VDI is dynamically allocated. This is what we need. Now that we have verified that our VDI is dynamically allocated, we need to back up our VDI in case the resizing fails and destroys our data. In the dialog box that appeared in step 3, navigate to the VDI information section that we opened and right-click on the Location line. This will offer the option to copy the path, which we need to do.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

5. With the path to our VDI copied to our clipboard, we can proceed. We need to detach the VDI from the virtual machine now, so click on the minus button beneath the storage device list in the dialog box.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

6. The VDI for your virtual machine should disappear from the storage device list as mine has in the image below.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

7. Next we need to open a terminal on our Ubuntu 18.04 LTS host machine. With the terminal open, enter the following command, replacing by pasting the path to your VDI that you copied in step 4. This command will make a copy of the VDI and place it in your Home directory.

cp <my-vdi-location> ~
How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

8. The process will take awhile since we are copying a large amount of data. The prompt will return to the terminal when the process has completed. When the prompt returns, we can enlarge our VDI by entering the following command. Make sure to replace <my-vdi-location> by pasting the path to your VDI that you copied in step 4 and replace <new-vdi-size> with the new, desired size, specified in megabytes.

vboxmanage modifyhd <my-vdi-location> --resize <new-vdi-size>
How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

9. When complete, the output of the previous command looks like this:

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

10. Next, we need to return to the VirtualBox Manager application. With Storage selected in Settings, click on Controller: SATA in the storage device list to highlight it, then click the plus button beneath the storage device list to add your resized VDI. In the dropdown menu, choose Add Hard Disk.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

11. A new dialog box will appear. We want to choose an existing disk, so select that option in the dialog box, then select you new, resized VDI.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

12. When re-attached, the VDI will show in the storage device list like the image below.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

13. We have successfully resized our VDI and reattached it to our virtual machine, but the guest operating system still will not be able to use the newly allocated space. We will need to boot our virtual machine from a live Linux distribution containing GParted so that we can resize the file system. To do this, click on the button with the CD and green plus button next to Controller: SATA. This will allow us to add another optical drive with our live Linux distribution. For this tutorial, I will use Ubuntu 18.04 LTS as the live Linux distribution because it contains GParted preinstalled.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

14. After clicking the add disk button, a new dialog appears. Select Choose disk and select your live Linux distribution containing GParted.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

15. Highlight the newly added optical disk and select the Live CD/DVD on the right.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

16. Next, select System from the pane on the left and ensure that Optical is first in the boot order. The boot order should look similar to this:

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

17. Finally, click OK to exit the Settings dialog.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

18. Now we can boot our virtual machine into our live Linux distribution by highlighting our virtual machine and clicking Start on the ribbon at the top of the application.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

19. If you are using Ubuntu 18.04 LTS as your live distribution, select Try Ubuntu when this view loads:

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

20. After Ubuntu 18.04 LTS live has loaded, open GParted.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

21. Notice the new, unallocated space in the grey portion in the image above. We will now configure the virtual machine to use that space in addition to the currently occupied space. Right click on the occupied space in white in GParted at the top of the application. From the dropdown menu that appears choose Resize/Move.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

22. A new dialog box appears showing both occupied and unallocated space. Move the slider all the way to the right to use all of the space, then click the Resize/Move button on the bottom of the dialog box.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

23. To apply our changes to the filesystem, click the green check mark in the ribbon at the top of the GParted application.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

24. Click Apply in the confirmation dialog box that appears.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

25. After a moment the operation completes and returns a success message. Close the message, close GParted, and then poweroff the live Linux distribution. We are now finished with resizing.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

26. Now we need to open Settings and navigate to Storage again. Highlight your virtual machine and click the Settings button on the top of the VirtualBox Manager application.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

27. Navigate to Storage in the left pane of the Settings dialog. Click on the optical device containing the live Linux distribution iso to highlight it, then click the minus button below the storage devices list to remove the optical device.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

28. Select Remove from the confirmation dialog box that appears.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

29. Click the OK button at the bottom of the Settings dialog to save the changes and close the dialog.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System

30. Finally, reboot your machine and verify that the new, additional space has been added. As you can see from the image below, after booting my Windows 10 virtual machine and opening the disk management console, I now have all of the additional storage I allocated available to my virtual machine.

How to Resize a Virtual Disk Image (VDI) in VirtualBox on an Ubuntu 18.04 LTS Host Operating System