Increase the size of Oracle Virtualbox VDI Image
Last updated
Last updated
Oracle Virtualbox dynamic disks can be incredibly painful at times when you are trying to build or dynamically manage /tmp directories.
If you are having issues with disk space warnings and associated issues when trying to build apps from source using /tmp or other similar issues you can force resize the virtualbox .vdi disk
The overall process involves the following:
Stop your virtualbox instance
Download the gparted image / .iso
Add the iso as a boot disk in Virtualbox
Make sure under System > Boot Order the CD is at the top
Save and start your VM - it should boot from the CD and launch Gparted GUI
Hit enter when you get this screen
Hit enter again
Select the language you want to use
Hit enter again when it asks you which mode you prefer
Once gparted launches make sure you have selected the disk you want to resize. By default, it usually selects the CD you just booted from, change it to your VDI disk
If you are working with Ubuntu then the one you are going to want to resize is the lvm2 pv ubuntu-vg
Click on that partition > Resize
Resize the partition to whatever takes your fancy (I'd recommend 25GB)
Click Resize
Click Apply All Operations (the green tick)
You can now shutdown the VM
Remove the CD Disk image you added so it doesn't boot from the CD again when you startup (virtualbox may automatically do this for you if you shutdown the VM properly)
Restart the VM
You will now need to do some tweaking in ubuntu
Run lsblk
You can see the /dev/sda3 has the new disk space allocated; however, the below lv is not so you need to expand it
Run df -h to list the paths
/dev/mapper/ubuntu--vg-ubuntu--lv is the path you are after
Run sudo lvm lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv to expand it to 100% available space
Run lsblk again
You should now have the extra space you allocated and are good to go