I have an Ubuntu VM running on my iMac at work. My code directory on my mac is accessible from my Linux VM server via NFS. Everything seem fine until when I needed to import a large database from our production server and got an error indicating that I had run out of space. I did a df -ah and saw that my sda1 partition was 100% full!
After googling a bit I ended up doing the following. I hope it helps someone out there who may encounter same problem.
The first thing I did was to power down my VM.
Next, I took advantage of Virtualbox’s VBoxManage command. In Windows you will have to execute VBoxManage.exe. The following command did the first part of the trick
VBoxManage modifyhd UbuntuVMBAse-disk1.vdi –resize 32768
When I ran Virtual box (without starting the VM) I checked the settings and sure enough the following was displayed;
Ubuntu VMBase-disk1.vdi (Normal 32.00GB)
Next, I needed to add the new space created to the partition I needed to expand. Enter Gparted.
I downloaded http://gparted.sourceforge.net/ ISO image.
I went to the settings of my VM and added the Gparted ISO to the storage settings (Make sure it is the first one in the list) I then ran the VM and it booted into Gparted live CD.
One difficulty you may encounter is that if you have a swap partition coming after the partition you want to expand, you most likely would see a light blue boundary surrounding it in the drives preview. What I did was to delete the swap partition first, and then I was able to expand the drive. I then added back the swap drive.
Finally I saved and then quit GParted. Removed itg from my storage settings and booted my VM. Voila! I now had my needed space.
Word of caution, Ensure that you have backed up relevant data before you do this. I did not need to because I had all my important data in a mapped drive. The worst would have been reinstalling my server apps and re-establishing my NFS shares.
Hope this helps someone!