VM Iamge qcow2 : 80 GB Kali Linux how to shrink

Hi folks
Looking for a little help

I uploaded the QEMU VM image from Kali.org to the default data store.

The image file qcow2 size was about 15 Gb.

Once uploaded , The default data store on the other hand takes up 80 GB.

When I run the image, 63 GB is free space and and near about 17 GB is used inside the VM.

I have tried to install from the ISO a couple of million times on disk sizes as big as 60 GB, but it always fails, the VM however runs fine except for the mammoth disk size.

Any advice on the matter would be greatly appreciated, a more reasonable disk size would be advantageous.

Hi @Twisted

I didn’t use kali image before, but probably they need that amount of disk, also depends on your datastore storage backend. We use ceph so all the images are always converted to raw.

Maybe you can try to shrink the Kali image before uploading it to opennebula datastore. There are several wikis that explains how to do that with a qcow image for kvm:

or

https://pve.proxmox.com/wiki/Shrink_Qcow2_Disk_Files#Shrink_the_Disk_File

I hope this will help.

Cheers
Álvaro

1 Like

Thank you very much for the response, I will certainly give it a try.
Cheers

Another option is to configure the VM disk as virtio-scsi[*] and enable trim/discard. Then use fstrim inside the guest(Kali) to tell the block layer that the free space in the (guest) filesystem is indeed “free” so it will free the disk space taken by the backing qcow2 file too.

[*] The discard option virtio-block backed disks works in recent qemu-kvm too. But you need to check does it works in your case first.

Hope this helps.
Best Regards,
Anton Todorov

Thank you very much, I will give it a try.
Really appreciate the advice
Cheers