Unfortunately, Virtual Box cannot resize VMDKs, but it can resize VDI images. So, we will convert the disk to a VDI, and then increase its size.
Find the location of the VMDK (e.g. /Users/<user>/VirtualBox VMs/<VM Name>/)
$ cd "~/VirtualBox VMs/<VM Name>/" |
Using VBoxManage to clone the image and resize it.
$ VBoxManage clonehd <VMDK Name>.vmdk clone.vdi --format vdi $ VBoxManage modifyhd clone.vdi --resize 20480 #size in MB (20 GB) |
It is really easy to increase the size of a VMDK in VMWare. First, shut down the VM and open the VM Settings Panel. Click on the Hard Disk icon, and enter the new disk size.
Some may consider the following "dangerous". However, you already have a backup of your virtual disk if you used the VirtualBox method above. If you want to be "safer", find a LiveCD or GParted ISO, and perform the following steps with /dev/sda1 unmounted.
But, without further ado:
Turn off swap
$ sudo swapoff /dev/sda5 $ sudo sed -i 's/\(^.*swap.*$\)/#\1/' /etc/fstab |
Remove the swap partitions (/dev/sda5) and the extended partition (/dev/sda2), then resize (delete and recreate) the root partition (/dev/sda1)
$ sudo fdisk /dev/sda Command: d Partition number: 5 Command: d Partition number: 2 Command: d Command: n Select: p Partition number: 1 First sector: 2048 Last sector: <enter to take default, which is the end of the disk> Command: w |
The changes will not be taken into effect until reboot. We also want to do fsck on reboot.
$ sudo touch /forcefsck $ sudo reboot |
All you need to do is run the following:
$ sudo resize2fs /dev/sda1 |
You can verify your hard work with:
$ df -h |