1

I want to install archlinux in UEFI mode so, I created image from virt-manager with size of 20GB.

Then after booting into VM, I created 2 partition with fdisk named /dev/vda1 and /dev/vda2 with 512MB and what remained (19.5~GB)

I changed the type of /dev/vda1 to EFI from fdisk and then formated it with

mkfs.fat -F32 /dev/vda1

Then I formated the /dev/vda2 to ext4 using

mkfs.ext4 /dev/vda2

and then I successfully installed arch on it. The output of

du -h -d 0 /

on guest gives 5.2GB. But the actual disk size of image on host is 20GB which is same as Virtual size

sudo qemu-img info archlinux.qcow2
image: archlinux.qcow2
file format: qcow2
virtual size: 20 GiB (21474836480 bytes)
disk size: 20 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

I also have windows 10 installed on qcow2 image and It only show 9.73 disk size as expected. I didn't create any extra esp partitions during windows installation as I installed it in bios mode and it boots with seabios

sudo qemu-img info win10.qcow2
[sudo] password for root: 
image: win10.qcow2
file format: qcow2
virtual size: 100 GiB (107374182400 bytes)
disk size: 9.73 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: true
    refcount bits: 16
    corrupt: false

So what am I doing wrong here ? How can create partitions on qcow2 image without reserving partition size on disk ?

1 Answers1

1

I found the answer thanks to @siduck76 on telegram.

sudo qemu-img convert -O qcow2 archlinux.qcow2 archlinuxComped.qcow2

reference:- https://www.jamescoyle.net/how-to/323-reclaim-disk-space-from-a-sparse-image-file-qcow2-vmdk