New in virt-sparsify ≥ 1.25.44, you can now sparsify disk images without copying them, so-called in-place sparsification.
It’s easy to use:
$ virt-sparsify --in-place fedora.img Trimming /dev/sda1 ... Clearing Linux swap on /dev/sda2 ... Trimming /dev/sda3 ... Sparsify in-place operation completed with no errors.
… and much faster. However it does require very recent kernel and qemu support.
Thanks: Paolo Bonzini, Eric Sandeen & Kevin Wolf for implementing discard support and patiently helping out when we started to test and use it.
That’s fantastic. The disk usage of virt-sparsify has often frustrated or stumped me before now. Thanks!
You’ll be glad to know the disk usage of
--in-place
is almost zero. It just gives back.Does it work with kernel-3.13.6-200.fc20.x86_64 and qemu-system-x86-1.7.0-5.fc20.x86_64?
I believe yes. We’ll be checking this when I push this to Fedora 20, probably next month.
Pingback: libguestfs 1.26 released | Richard WM Jones
Pingback: libguestfs RHEL 7.1 preview packages (yes, really) | Richard WM Jones
One more question: is
--in-place
mode less efficient than the regular one?It depends on how you define efficient. In the usual sense, yes it’s far more efficient. It uses far less host resources to do in-place sparsification.
However it’s not as “efficient” at finding opportunities to free space and sparsify guests. For some filesystems in-place sparsification won’t work at all (ie. no extra space can be found unless it is already zero) because we require that the fstrim ioctl has been implemented for every filesystem in the Linux driver for that filesystem.
Even for ext4 where fstrim has been implemented, the fstrim implementation in the kernel unfortunately does not free up the journal (whereas copying-mode can), so there’s some opportunity for improvement. As usual patches welcome — in this instance, to the linux kernel mailing list.
Pingback: virt-v2v: better living through new technology | Richard WM Jones
One good options to add it –continue-on-error I have thin lvm based CentOS 7 KVM image where first partition is /boot, second is SWAP and third is / it fails on SWAP and exits with continue options even on error it will try on next partition.
Second issue that I have is it fails to sparsify windows 7 ntfs disk. I have seen discussion about your Block Discard patch for NTFS but not sure on its commit status. I do is ntfsresize to minimum, create a linux partition, mkfs.ext4 (it will call discard first) delete linux partition, resize ntfs partition back to full.
The NTFS discard patch is upstream, but requires the latest ntfs-3g plus possibly backporting the patches (which we have done in RHEL 7.1 and Fedora 21).
Thanks for info, waiting for Dec 9 to get my laptop updated to Fedora 21
You could file a bug about the CentOS thing. A swap partition shouldn’t stop conversion, but I’d need to see the debug output to know what’s really going on here.
https://bugzilla.redhat.com/enter_bug.cgi?component=libguestfs&product=Virtualization+Tools
https://bugzilla.redhat.com/show_bug.cgi?id=1170771
I didn’t see any debug options for virt-sparsify except for debug-gc, attached –verbose output to bug.
Does virt-sparsify work on vmdk files?
Probably. virt-sparsify just uses qemu, so we support whatever qemu supports, and qemu supports certain types of VMDK (the “standard” is not very well standardized, and a moving target). If trying to sparsify VMDK, then definitely use copying mode, and not
--in-place
.how to install this version on centos 6.7?
It can be compiled from source, but there is no package for it.