[ I am about to do what others have done before me and blog about it one more time ]
While I do enjoy working with Windows 10, I am still not using WSL (waiting for WSL2) and work with either chocolatey or a vagrant Ubuntu box. It so happens that after pulling a few docker images the default 10G disk if full and you cannot work anymore. So, let’s resize the disk:
The disk on my ubuntu/bionic64 box, is a VMDK one. So before resizing, we need to transform it to a VDI first, which is easier for VirtualBox to handle:
VBoxManage clonehd .\ubuntu-bionic-18.04-cloudimg.vmdk .\ubuntu-bionic-18.04-cloudimg.vdi --format vdi
Now we can resize it, to say 20G:
VBoxManage modifymedium disk .\ubuntu-bionic-18.04-cloudimg.vdi --resize 20000
We’re almost there. We need to tell vagrant to boot from the VDI disk now. To do so open VirtualBox and visit the storage settings of the vagrant VM. Remove the VDMK disk(s) there and add the VDI on SCSI0 port. That’s it. We’re one step closer. Close VirtualBox and
vagrant up now to boot from the VDI.
Now you have a 20G disk, but still a 10G partition. parted to the rescue:
$ sudo parted /dev/sda (parted) resizepart
It will ask you the partition number. You answer
1 (which is the /dev/sda1). It will ask you for the end of the partition. You answer
-1 (which means until the end of disk).
quit and you’re out.
You have changed the partition size, but still the filesystem reports the old size. resize2fs (assuming a compatible filesystem) and:
$ sudo resize2fs /dev/sda1
Now you’re done. You may want to
vagrant reload to check whether everything works fine. Once you’re sure of that you can delete the old VMDK disk.