0

shrink sparse qcow2 file

When a vm’s been running for a while the sparse file will get bigger and bigger. If a cleanup has been done and the space usage is back down to minimal the sparse file will remain the largest size it was before. you can shrink the sparse file back down to minimal space usage by issuing the following. Please note that VM should be off during this. mv myqcow2file.qcow2 myqcow2file.qcow2.bak qemu-img convert -O qcow2 myqcow2file.qcow2.bak myqcow2file.qcow2 start up the VM and everything should be back to normal and the space of the sparse qcow2 file should be much less.

0

mount qcow2 with libguestfs

sometimes you have multiple qcow2 files sitting around from older upgrades and OS’s that you just need to grab a file or a config from and dont want to bother with booting it up. there is a way to mount the filesystem using libguestfs which can save time! This works with LVM and non LVM qcow2 files and also even if you dont know how the qcow2 partitions are laid out you can feed it a bogus partition and it will list it for you. # guestmount -a rhel5.qcow2 -m /dev/sdzz1 /mnt libguestfs: error: mount_options: mount_options_stub: /dev/sdzz1: No such file… Continue Reading