Table of Contents

Create mountable compressed disk image

  1. Install tools
    apt install -y qemu-utils libguestfs-tools
  2. Sparsify the disk
    virt-sparsify -v --in-place disk.img
  3. Convert the disk to dynamic VHD
    qemu-img convert -p -o subformat=dynamic -f raw -O vpc disk.img disk.vhd

Batch

for i in *.img; do virt-sparsify -v --in-place $i; done
for i in *.img; do echo $i; qemu-img convert -p -o subformat=dynamic -f raw -O vpc "$i" "${i%%.img}.vhd"; done

See Alsos