Today, I ran into an interesting problem when I “just wanted to create some bash scripts”. As usual, something “simple” had to turn into a big ordeal, so today I was confronted with the hard disk of my Ubuntu VM being full. This VM was made in Hyper-V with the Quick Create option, which is very useful. The default disk size? Not so useful, as I found out.
I tried to expand the disk using the “disks” utility but I got a weird error, which told me that the size I was trying to expand it to was smaller than the minimum. That was very much not the case, so as one does I tried it a few more times, to no avail.
However, after some Googling I found the solution to my problem on the Ubuntu Forums.
Steps to follow
- In Hyper-V, first stop your virtual machine.
- Next, delete any save points you might have created for the VM.
- Once your virtual machine is stopped, select the virtual machine and go to “Settings”.
- Select your hard disk under the “Hardware” section.
- Under the path of the “Virtual hard disk”, click “edit”
- Follow the wizard, and choose to expand the hard disk. Choose your new disk size (assuming you have enough room on your host!)
- Complete the wizard
Once these steps are followed, start your Ubuntu VM, log in and open your terminal. From there, it’s just a matter of following the instructions.
sudo apt install cloud-guest-utils sudo parted /dev/sda (parted) > resizepart 1 When prompted for the disk end, type: -0 When parted is done, type "quit" to exit