I have Ubuntu 18.04 as a guest os and I needed to resize the partition with virt-resize
:
#:/var/lib/uvtool/libvirt/images# virt-resize --shrink /dev/sda1 guest1.qcow guest1-shrunk.qcow
[ 0.0] Examining guest1.qcow
**********
Summary of changes:
/dev/sda14: This partition will be left alone.
/dev/sda15: This partition will be left alone.
/dev/sda1: This partition will be resized from 17.9G to 5.5G. The
filesystem ext4 on /dev/sda1 will be expanded using the 'resize2fs' method.
**********
[ 3.3] Setting up initial partition table on guest1.qcow
[ 11.7] Copying /dev/sda14
[ 11.7] Copying /dev/sda15
[ 11.8] Copying /dev/sda1
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00
[ 29.9] Expanding /dev/sda1 (now /dev/sda3) using the 'resize2fs' method
Resize operation completed with no errors. Before deleting the old disk,
carefully check that the resized disk boots and works correctly.
I checked if everything was ok with:
#:/var/lib/uvtool/libvirt/images# virt-df -h guest1-shrunk.qcow
Filesystem Size Used Available Use%
guest1-shrunk.qcow:/dev/sda2 104M 3.6M 101M 4%
guest1-shrunk.qcow:/dev/sda3 5.3G 4.6G 612M 89%
However, when I try to start it virsh start guest1-shrunk
, I cannot log into the server with ssh or even with virsh console guest1-shrunk
. No errors are shown and virsh list --all
shows the guest is running. However, it's not possible yo shut it down with virsh shutdown
and I have to use virsh destroy
. Obviously, it's not booting properly and my suspicion is this is because partitions were re-arranged. There's a similar question here: KVM .img can not boot after resized by virt-resize although in that case the person can see the error explicitly.
How do I go about fixing the partition table?