I had a Ubuntu VM with disk size of 12GB running in an Hyper-V environment on the physical server with limited disk space. I discovered that the VHDX disk space was not enough to run the applications I was installing on it.
In order to resolve this challenge, I had to increase the disk size of the VHDX disk and then increase the disk partition within the VM.
- To increase the virtual disk size, I use the powershell command:
Resize-VHD -Path "VHDX disk location" -SizeBytes 60GB
2. Then I proceed to log into to Ubuntu VM
3. Open a bash shell
4. To view the partition to increase, run the command as a root:
sudo fdisk -l
if the command is not installed, you need to run the following command first:
sudo apt install cloud-guest-utils
5. When the partition is identified, use it in the next command to expand partition into free space:
sudo growpart /dev/sda 1
Note: space between the partition and id
6. Then this command will resize the partition:
sudo resize2fs /dev/sda1
Note: no space between partition and id
7. Dont forget the final step to reboot the ubuntu VM for the command to take effects. This is critical because it did not work until I did this step.
I hope this helps someone who support linux.