Resizing a Ubuntu Disk in a UTM VM
UTM is an awesome virtualization system based on QEMU built for M1 (ARM) Macs. v4.0.8 of UTM, the first v4 stable release, came out today with support for resizing QEMU disk images but while the UTM docs show how to resize the UTM machine, there’s several more steps to get the virtualized file system to recognize the additional disk space.
For an Ubuntu guest OS running a default GPT and LVM partition:
- On a shut down VM, in the UTM UI’s configuration, select the disk you wish to expand, resize the disk, and save the VM configuration.
- Launch the VM and get a terminal
sudo fdisk -land confirm that there is a
GPT PMBR Size Mismatch will be corrected by w(rite)warning
sudo parted -land gparted should ask to automatically fix the size mismatch. Fix the size mismatch.
- If the resizing doesn’t work, manually run
parted /dev/vda resize 3 100%.
sudo lvmto get an lvm console
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lvto expand the lvm logical volume
- Exit the lvm console
sudo resize2fs /dev/ubuntu-vg/ubuntu-lvto expand the ext4 file system to the logical volume
df -hto confirm that the
/dev/mapper/ubuntu--vg-ubuntu--lvhas been expanded.