When you use VirtualBox to manage virtual machine, you may encounter virtual disk space not enough issue, so you have to create a new virtual machine with a bigger virtual disk or you can increase current virtual machine disk space size to make more disk space to use. This article will tell you how to increase the virtual machine disk size in VirtualBox. This example will use VirtualBox MacOS version and the virtual machine is ubuntu Linux.
1. Increase Virtual Machine Disk Virtual Size.
- Open VirtualBox and click Global Tools —> Virtual Media Manager menu item. Then you can select the virtual disk file(Ubuntu.vdi) and change the file size use the bottom slider bar. You can only increase the disk file size, can not decrease the file size. Do not forget click Apply button.
- You can also run VBoxManage command in terminal to resize the virtual disk file size as below.
192:Ubuntu$ VBoxManage modifymedium "/Users/jerry/VirtualBox VMs/Ubuntu/Ubuntu.vdi" --resize 30000 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
- Now right click the ubuntu virtual machine in VirtualBox, click Settings menu item, then click Storage and select the virtual disk file ( Ubuntu.vdi ) in left, you can see it’s detail information in right panel. From below picture, we can see that the new Virtual Size is 30 GB, but the Actual Size is 5.71 GB. Now the virtual disk file virtual size has been increased, we need to allocate the newly added space in the virtual machine os.
2. Convert Virtual Machine Disk File Storage Allocation Mode From Dynamic To Fixed.
Before you can allocate additional space size in virtual machine os, you should make sure that your virtual machine storage allocation mode is Fixed size storage. If the storage allocation mode is Dynamic, you should first convert the dynamic mode to fixed size storage mode. Otherwise you can not find the place to allocate newly added disk space in virtual machine os.
From above picture, we can find our virtual disk file storage allocation mode is Dynamically allocated storage in right panel Details line. So we need first to clone the virtual disk to another one and then set the storage allocate mode to Fixed size.
- Clone virtual disk file to convert storage allocation mode from Standard( dynamic) to Fixed size. Open a terminal and run below command.
$ VBoxManage clonemedium disk "/Users/jerry/VirtualBox VMs/Ubuntu/Ubuntu.vdi" "/Users/jerry/VirtualBox VMs/Ubuntu/Ubuntu-clone.vdi" -variant Fixed
- In above command line we use VBoxManage command to clone the Ubuntu.vdi to Ubuntu-clone.vdi, and pass -variant Fixed argument to make the new virtual machine disk file Fixed storage allocation mode.
- Open virtual machine Settings window, click Storage tab at top then click the Adds hard disk icon(the last icon in Controller: SATA item), and choose the newly cloned virtual machine disk file ( Ubuntu-clone.vdi ). Click the vdi file, you can find the Virtual Size and Actual Size is same 30.00 GB. Right click the old Ubuntu.vdi file, click Remove Attachment menu item to remove the old virtual machine disk file.
3. Allocate Additional Space Size In Virtual Machine OS.
3.1 Use Ubuntu Disks Utility Tool.
- Start and login ubuntu os.
- Then search keyword disk in Show Applications area ( Click the bottom left icon in ubuntu desktop to show applications).
- Click the Disks utility tool to open it. Click the VBOX hard disk in left, then you can find the unallocated disk space ( Free Space ) in right.
- Click the Additional partition options icon ( the third icon ) at Volumes bottom. Then click Resize… menu item to open the Resize Volume popup dialog. You can change the disk volume space size in it.
3.2 Use Third Party Tool Gparted.
- Gparted is an open source free disk volume management tool. You can download the gparted iso file from it’s official website.
- Then install the iso file in the VirtualBox virtual machine Settings —>Storage —> Controller: IDE as the dvd disk.
- Open virtual machine Settings dialog, click System icon, then move the Optical device to the first order in the Boot Order to load the os from the gparted iso.
- Now restart the ubuntu virtual machine, it will load the gparted iso file, follow the steps in the prompt dialog, click enter key for three times, then you can see below gparted GUI.
- Select the /dev/sda1 partition, then click Resize/Move menu icon at top menu, then you can assign additional disk space to /dev/sda1 partition.
3.3 Install Gparted Tool After Start Ubuntu.
Besides load the gparted at ubuntu start time, you can also install gparted after ubuntu os start.
- Login ubuntu os.
- Open a terminal and run below command to install gparted in ubuntu.
$ sudo apt-get install gparted
- After install gparted successfully, run gparted command in terminal to open the GUI dialog to increase the partition size.