Today When I was importing large database I was getting error that there is not enough space after half of the database was imported. When I checked space it was showing 100% used. Even though I had dynamic space allocated, it was not increasing beyond 37GB. After going through few forums I managed to combine all tips & tricks and apply them to increase my oracle virtualbox ubuntu main partition.
As I may encounter same issue in future, I have noted them down here for future refrence.
Steps to increase Virtual size and Actual size:
- On your ubuntu command line run this command to turn off swap partition: sudo /sbin/swapoff -a
- Shutdown your virtualbox
- cd "C:\Program Files\Oracle\VirtualBox"
- VBoxManage modifyhd "C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi" --resize <New_Size_In_MB>
- Download gparted iso from http://gparted.sourceforge.net/download.php
- On your virtualbox "setting > storage > IDE Controller" add this iso and start your VM.
- Press enter to select default settings when gparted starts.
- Extend partition "Extended" (the wrapper for swap partition) so it takes all unallocated space.
- Move the swap partition to the end of the space by dragging without changing swap size.
- Shrink "Extended" from the beginning to the size of swap partition.
- Now you can extend your main partition to fill new space between your main partition and swap partition.
- Apply changes and shutdown gparted.
- Detach gparted ISO that was previously added and restart your VM.
- Now you can turn swap partition back on by running this command once your VM is ready. "sudo /sbin/swapon -a"
- Check your disk space "df -h" you should see more available space now depending on how much you defined when resized.
- Enjoy!!!
For detailed information with screenshots you may refer these links.
- http://askubuntu.com/a/300193/107635
- http://askubuntu.com/a/545902/107635
- http://www.howtogeek.com/124622/how-to-enlarge-a-virtual-machines-disk-in-virtualbox-or-vmware/