Optimize-Volume -DriveLetter C -ReTrim -Verbose
If you outgrow your initial storage allocation, you can easily increase the boundaries of your QCOW2 image:
Then ensure defragmentation is scheduled. QCOW2 will automatically reclaim space on your Linux host when Windows deletes files. windows 10qcow2
Convert other virtual disk formats to QCOW2 using qemu-img convert :
virt-install \ --name=Windows10_VM \ --ram=4096 \ --vcpus=2 \ --cpu host-passthrough \ --os-variant=win10 \ --disk path=/var/lib/libvirt/images/win10.qcow2,format=qcow2,bus=virtio,cache=none,io=native \ --disk path=/path/to/windows10.iso,device=cdrom \ --disk path=/path/to/virtio-win.iso,device=cdrom \ --network network=default,model=virtio \ --graphics spice,listen=0.0.0.0 \ --boot uefi Use code with caution. Step 3: Load Drivers inside the Windows Installer Step 3: Load Drivers inside the Windows Installer
Once configured, Windows 10 will automatically optimize the storage via its internal "Optimize Drives" tool (Defrag), passing TRIM signals that compress the physical QCOW2 footprint on the host filesystem. Manual Disk Compacting
# Disable Windows Search Indexing Stop-Service -Name "WSearch" Set-Service -Name "WSearch" -StartupType Disabled # Disable Scheduled Defrag/Trimming (KVM handles this better) Disable-ScheduledTask -TaskName "ScheduledDefrag" -TaskPath "\Microsoft\Windows\Defrag\" Use code with caution. Turn Off Hibernation For automation or testing, pre-made images are available
Creating your own takes 30-45 minutes of clicking. For automation or testing, pre-made images are available. Warning: Only download from trusted sources to avoid malware.