Hot answers tagged

24 votes
Accepted

How do you create a qcow2 file that is small yet commodious on a Linux server?

To create a qcow2 image for a virtual disk size of 100MB do: qemu-img create -f qcow2 foobar.qcow2 100M The created foobar.qcow2 will be about 200KB. You can easily create a very big virtual disk ...
user avatar
  • 695
22 votes
Accepted

free up not used space on a qcow2-image-file on kvm/qemu

virt-sparsify can do all this with less hassle on your part: http://libguestfs.org/virt-sparsify.1.html
user avatar
20 votes
Accepted

Which is better image format, raw or qcow2, to use as a baseimage for other VMs?

For your specific use case (base image + qcow2 overlay), the RAW format should be preferred: It's faster: as it has no metadata associated, it is as fast as possible. On the other hand, Qcow2 has two ...
user avatar
  • 43.5k
8 votes

Which is better image format, raw or qcow2, to use as a baseimage for other VMs?

Please be advised....if you are using linux you can use raw and get the same benifits of qcow2 as far as size goes. ...If your file system supports holes (for example in ext2 or ext3 on Linux or ...
user avatar
  • 220
8 votes
Accepted

How to create a qcow2 file that is not thin provisioned?

You can use the preallocation option. qemu-img create -o preallocation=full -f qcow2 /var/lib/libvirt/images/urb-dat0.qcow2 10G Reference: https://linux.die.net/man/1/qemu-img Preallocation mode (...
user avatar
  • 9,350
8 votes

Any way to convert qcow2 to ovf?

qemu-img convert -f qcow2 -O vmdk whatever.qcow2 whatever.vmdk
user avatar
  • 99.6k
7 votes

free up not used space on a qcow2-image-file on kvm/qemu

You can use virt-sparsify for this. It automatically zeros and sparsifies free space on most filesystems it finds within the source disk image (supports ext2/3/4, btrfs, NTFS, etc) . Step-by-step ...
user avatar
  • 1,193
6 votes

Is there any way to shrink qcow2 image without converting it raw?

I use virt-sparsify: virt-sparsify /path/to/source.qcow2 --compress /path/to/output.qcow2
user avatar
6 votes
Accepted

How to move KVM image to another directory/partition?

Backup Original VM: virsh shutdown wwe virsh list --all cp /etc/libvirt/qemu/wwe.xml /etc/libvirt/qemu/orig-wwe.xml cp /kvm/vhdd/wwe.img /kvm/vhdd/orig-wwe.img Move VM image to partition /mnt/kvm: ...
user avatar
5 votes

free up not used space on a qcow2-image-file on kvm/qemu

In addition to the accepted answer (which describe the more common, general method to shrink a qcow2 file), modern version (ie: RHEL7+) of the libvirt/qemu/qcow2 stack supports the virtio-scsi driver ...
user avatar
  • 43.5k
5 votes

Incredibly low KVM disk performance (qcow2 disk files + virtio)

I experienced exactly the same issue. Within RHEL7 virtual machine I have LIO iSCSI target software to which other machines connect. As underlying storage (backstore) for my iSCSI LUNs I initially ...
user avatar
  • 51
4 votes
Accepted

Is it safe to use fallocate --dig-holes while being modified

I'd generally say no. If the file is an image mounted to a VM, you can try TRIM (e.g., fstrim -a) instead. Strictly speaking, this is not an equivalent (TRIM can also free space of some deleted file ...
user avatar
  • 226
4 votes

Incredibly low KVM disk performance (qcow2 disk files + virtio)

On old Qemu/KVM versions, Qcow2 backend was very slow when not preallocated, more so if used without writeback cache enabled. See here for more information. On more recent Qemu versions, Qcow2 files ...
user avatar
  • 43.5k
4 votes

Incredibly low KVM disk performance (qcow2 disk files + virtio)

If you're running your vms with a single command, for arguments you can use kvm -drive file=/path_to.qcow2,if=virtio,cache=off <...> It got me from 3MB/s to 70MB/s
user avatar
4 votes

Is there any way to shrink qcow2 image without converting it raw?

I have been successfully using this procedure many times now. In short, first in the virtual guest fill all free space on all partitions with zeroes: dd if=/dev/zero of=zerofile bs=1M When done, ...
user avatar
4 votes

How to repair a broken-resized qcow2 disk image for libvirt/kvm?

Did you run the "qemu-img resize diskimage.qcow2 +22GB" while the QEMU process was still running with the same disk open ? If so, that would certainly explain the data corruption, as you would ...
user avatar
  • 1,465
4 votes

Terraform Libvirt - How to use local qcow2 file in the hypervisor instead of cloud images?

You will have to specify it like this: resource "libvirt_volume" "terraform-test" { name = "terraform-test.qcow2" pool = "default" source = "file:///...
user avatar
3 votes

Do I need to zero-fill a qcow2 image before compacting it?

See also: virt-sparsify, an utility which can zero-fill filesystems inside disk images (supporting various formats): http://libguestfs.org/virt-sparsify.1.html
user avatar
3 votes

qemu-img convert CentOS7 vmdk to qcow2 and vice versa error

I might be wrong, however, you could try https://www.starwindsoftware.com/converter I was converting VMDK to VHDX using this soft, and job was done.
user avatar
  • 5,606
3 votes

KVM snapshotting. How to see what's inside the qcow2 file?

In order to shrink the image, I'd suggest to use virt-sparsify export TMPDIR=/var/tmp/ virt-sparsify --check-tmpdir=continue <name>.qcow2 <name>_sparsed.qcow2 Make sure you have enough ...
user avatar
3 votes

How to move KVM image to another directory/partition?

If I understand, your need is to move /kvm/vhdd/wwe.img to somewhere in /mnt (let's say /mnt/kvm/vhdd/wwe.img ) ? If so I would : stop the virtual machine (using poweroff or other command in the ...
user avatar
  • 1,007
3 votes
Accepted

xfs_db reports high file fragmentation where VM is located, but VM shows almost no fragmentation

The correct, yet partial, view of the backing file is the one provided by the host system. In other words: if host reports a file as fragmented, it is really fragmented, whatever the guest say. ...
user avatar
  • 43.5k
3 votes

Which file has chaged from one VM-overlay to the next?

virt-diff can list the different files between raw or qcow2 images. It claims to allow diff between overlays, in which case try creating an empty qcow2 for the -a argument. Or, compare guests with and ...
user avatar
2 votes

Qcow2 images growing far beyond what they should

Several things: When you use sparse images, they will grow when the VM writes data into the disks. A snapshot is a new sparse image, able to grow to the same size as the original. So if you take a ...
user avatar
  • 18.4k
2 votes

QCOW2 virtual size lowering

You need to convert the qcow2 image to raw qemu-img convert -O raw guest.img guest.raw Then resize the raw file qemu-img resize guest.raw 3G Then convert it back to qcow2 qemu-img convert -O qcow2 -o ...
user avatar
2 votes
Accepted

QCOW2 virtual size lowering

If you want to shrink the virtual size, you need to use virt-resize
user avatar
  • 18.4k
2 votes
Accepted

Accessing linux guest OS filesystem in qcow2 image

Alternatively have a look at guestfish, guestmont or virt-copy-out (both from libguestfs.org).
user avatar
  • 1,050
2 votes

Accessing linux guest OS filesystem in qcow2 image

There may be a bug with the physical volume not being initialized (udev). Try this: modprobe nbd max_part=63 qemu-nbd -n -c /dev/nbd0 /var/lib/libvirt/images/vm-image.qcow2 partprobe /dev/nbd0 ...
user avatar
  • 2,726
2 votes
Accepted

qemu-img: Could not open '/dev/stdin': Could not refresh total sector count: Operation not permitted

Standard input is not seekable, which is what qemu-img convert is trying to do here. To work around the problem, use an input image which is a file on the filesystem or a block device, both of which ...
user avatar
2 votes

How to create a qcow2 file that is not thin provisioned?

An existing thin-provisioned qcow2 file can be converted to a fully allocated one like this: qemu-img convert -p -f qcow2 -O qcow2 -S 0 original-file.qcow2 new-file.qcow2 (This is not an answer to ...
user avatar
  • 151

Only top scored, non community-wiki answers of a minimum length are eligible