Looking to resize an existing qcow2
or raw data volume with QEMU?
I had to do the same thing and went through some trouble in trying to do this. My first idea was to use GParted and boot from the live-cd iso to extend the apfs
partition. However, it turns out that GParted does not support apfs
(yet?).
First, you’ll need to expand the disk space available to the VM. Depending on the disk format, you can use:
qcow2
:qemu-img resize image.qcow2 +20G
lvm
:lvextend -L /dev/lvmpool/vm +20G
Now you can expand the apfs container from inside the OSX VM. Simply find out the identifier of your partition:
/usr/sbin/diskutil info / | awk '/Part of Whole/ {print $4}'
And use that identifier together with this command:
/usr/sbin/diskutil apfs resizeContainer /dev/{identifier} 0
This will expand to use up all available free disk space.