Resize Ubuntu Partitions in Hyper-V to Use Full Disk
When creating a new virtual machine in Hyper-V with Ubuntu Server with all the default settings, the partition will have 60GB of space instead of 127GB (default size of the virtual hard disk). Maybe there is a setting somewhere that I missed during the setup, but I couldn't find it. The solution is to resize the partition after the installation. This can be done with the following commands:
First, check the partition table to see the current size of the partition:
Shell
sudo fdisk -l
Identify the logical volume you want to extend. Then, extend the logical volume to use all the free space:
Shell
sudo lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv
Finally, resize the filesystem to match the new size of the logical volume:
Shell
sudo resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
Do you have a question or a suggestion about this post? Contact me!
Enjoy this blog?
💖 Sponsor on GitHub