How to increase virtualbox hard disk partition size

Posted by Damodar Bashyal on March 16, 2015

 

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.

Oracle VM VirtualBox Manager

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:

  1. On your ubuntu command line run this command to turn off swap partition: sudo /sbin/swapoff -a
  2. Shutdown your virtualbox
  3. cd "C:\Program Files\Oracle\VirtualBox"
  4. VBoxManage modifyhd "C:\Users\Chris\VirtualBox VMs\Windows 7\Windows 7.vdi" --resize <New_Size_In_MB>
  5. Download gparted iso from http://gparted.sourceforge.net/download.php
  6. On your virtualbox "setting > storage > IDE Controller" add this iso and start your VM.
  7. Press enter to select default settings when gparted starts.
  8. Extend partition "Extended" (the wrapper for swap partition) so it takes all unallocated space.
  9. Move the swap partition to the end of the space by dragging without changing swap size.
  10. Shrink "Extended" from the beginning to the size of swap partition.
  11. Now you can extend your main partition to fill new space between your main partition and swap partition.
  12. Apply changes and shutdown gparted.
  13. Detach gparted ISO that was previously added and restart your VM.
  14. Now you can turn swap partition back on by running this command once your VM is ready. "sudo /sbin/swapon -a"
  15. Check your disk space "df -h" you should see more available space now depending on how much you defined when resized.
  16. 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/
 
not published on website


QR Code: How to increase virtualbox hard disk partition size