MacOS – How to Enlarge Disk Image in VirtualBox

installmacosvirtualbox

I have VirtualBox 5 in OS X El Capitan 10.11.3.
There is an option in Windows's VirtualBox to enlarge the image here described.
However, I cannot find a similar way for OS X.

My storage looks like this

enter image description here

Clicking the 8.00 GB you get

enter image description here

Choose disk image and you get

enter image description here

so no similar view as in Windows.

DavidAnderson. The user manual's page 150 is here.
It just describes about the command VBoxManage modifyhd but not how you can get it in your commandline.

Terminal approach

In VirtualBox 4, there was VBoxManage command to enlarge the image size, as described here about How To Resize A VirtualBox Disk (Window and Mac)

VBoxManage modifyhd “<vdi_file_full_path_and_name>” –resize 40000

I solved the PATH problem by not changing the PATH but uninstalling Macports as described here by the recursive forceful deletes, so I can now call the function without explicitly having /usr/local/bin/VBoxManage in the start of the command.

klanomath. I run successfully

/usr/local/bin/VBoxManage modifyhd "/Users/masi/VirtualBox VMs/Ubuntu 14.04 64bit/Ubuntu 14.04 64bit.vdi" --resize 10000 
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

I login successfully to the encrypted system. I login successfully to my Ubuntu's user account but the session only stays in the view

enter image description here

where the Ubuntu on the host stays stacked infinite time. The encryption of the virtual disk should not be a problem because I managed to get the login view of the OS. I have not been able to login to different TTYs of Ubuntu inside the virtual machine, to debug the case further.

I login successfully as Guest and I get

enter image description here

which indicates that the size of my disk for the OS is too small.
I increase successfully the space to 20 GB by the following command but I still receive the complain about no disk space in the Guest login

VBoxManage modifyhd "/Users/masi/VirtualBox VMs/Ubuntu 14.04 64bit/Ubuntu 14.04 64bit.vdi" --resize 20000

The space looks ok inside and there should be enough space

enter image description here

The storage looks now like this where the actual space increases dynamically

enter image description here

Login to my User account still stays stucked forever, like one of the screenshots indicates.

Thread in Oracle's VirtualBox Forum

I opened a thread about the issue in Oracle's VB forum here.
I got this answer

https://forums.virtualbox.org/viewtopic.php?f=24&t=50661
Pay close attention to step 2

Also if you selected to use LVM when you installed you would need to use LVM to extend the primary partition. Seek assistance from Ubuntu on how to do that.

where I do not understand the thing about LVM and not content provided in the link.

The last point was solved by completely removing the existing disk and doing reinstallation of Ubuntu with 50 GB dynamic disk size.
For long term stability, this method is the safest. I had backups of the files in the disk.


How can you enlarge disk image in VirtualBox?

Best Answer

Your vdi path is wrong:

VBoxManage: error: Could not find file for the medium

In your resize command either use the uuid of the vdi or a proper path (no backslashes!) :

VBoxManage modifyhd "/Users/masi/VirtualBox VMs/Ubuntu 14.04 64bit/Ubuntu 14.04 64bit.vdi" --resize 10000

or (with backslashes but no quotation marks)

VBoxManage modifyhd /Users/masi/VirtualBox\ VMs/Ubuntu\ 14.04\ 64bit/Ubuntu\ 14.04\ 64bit.vdi --resize 10000

or after entering VBoxManage list hdds:

#replace UUID and size below by the appropriate UUID and the required size
VBoxManage modifyhd UUID --resize size

If your PATH doesn't work properly you may have to prepend /usr/local/bin/