theking2
(John King)
August 14, 2026, 8:48am
1
Setup a Windows 1 box with disk drivers as virtio.
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="writeback" discard="unmap"/>
<source file="/var/lib/libvirt/images/win11-2.qcow2" index="2"/>
<backingStore/>
<target dev="vda" bus="virtio"/>
<boot order="1"/>
<alias name="virtio-disk0"/>
<address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</disk>
I have problems doing a Optimize in Windows:
"Defragmentierung" wird für "(C:)" aufgerufen...
Vor der Optimierung ausgeführter Bericht:
Volumeinformationen:
Volumegröße = 94.97 GB
Freier Speicherplatz = 43.37 GB
Fragmentierter Speicherplatz insgesamt = 7%
Größter freier Speicherplatz = 16.22 GB
Hinweis: Dateifragmente, die größer als 64 MB sind, sind nicht in den Fragmentierungsstatistiken enthalten.
Erneut optimieren: übersprungen.
Datenfehler (CRC-Prüfung) (0x80070017)
If I connect this (to another win11 vm as second devices with SATA drivers) I can optimize without a problem. Is it possible that the virtio drivers are faulty? Installed what I think are the latest
I google translated the message into english and then did a web search for “windows defrag Data Error (CRC Check) (0x80070017)”.
There are a number of promising pages suggesting how to fix this error.
moskimus
(Justin Gibson)
August 15, 2026, 1:53pm
3
Is it possible you’re hitting this?
opened 06:34PM - 24 May 26 UTC
vioscsi
Jira_Attached
May 12, 2026—KB5089549
Running a Windows 11 Pro guest VM with VirtIO-SCSI boot … drive:
- Proxmox 9.2 Hypervisor
- VMs stored on ZFS
- Windows 11 Pro Guest VM
- virtio-win-0.1.285-1
Until May 2026 VirtIO trim from within the VM has worked very nicely, passing the trim requests up to the ZFS layer, and releasing storage there.
However, trim stopped working as of 12 May 2026 (Patch Tuesday) Trim attempts within the Windows 11 guest now fail. Each attempt generates a defrag failure event, Event Id 264, in the guest Event log:
```
Log Name: Application
Source: Microsoft-Windows-Defrag
Date: 5/12/2026 4:47:18 PM
Event ID: 264
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: One
Description:
The storage optimizer couldn't complete retrim on (C:) because: Incorrect function. (0x80070001)
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Defrag" />
<EventID Qualifiers="32768">264</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2026-05-12T20:47:18.5110469Z" />
<EventRecordID>67606</EventRecordID>
<Correlation />
<Execution ProcessID="18676" ThreadID="0" />
<Channel>Application</Channel>
<Computer>One</Computer>
<Security />
</System>
<EventData>
<Data>retrim</Data>
<Data>(C:)</Data>
<Data>Incorrect function. (0x80070001)</Data>
<Binary>01000780C00200005B010000CB01000022B63823DBB1BD381B0700000000000000000000</Binary>
</EventData>
</Event>
```
Nothing has changed within the VM configuration to cause this, and an adjacent Windows 10 VM, running on the same hypervisor with the same VirtIO drivers, continues to have functional trim support.
From the guest VM, and I can see:
1. Last successful trim was 11 May 2026
2. First unsuccessful trim (Event Id 264) above is 12 May 2026
**This date coincides May 2026 Patch Tues. It is likely that Microsoft's most recent monthly update, possibly 2026-05 Security Update (KB5089549) (26200.8457), has broken something.**
While I realize it is Microsoft that has likely broken something, nevertheless this likely will be an issue going forward.
theking2
(John King)
August 16, 2026, 3:14pm
4
By circumstance I’ve found out that the latest virtio drivers do not support trim or at least not ntfs optimizing.
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="unsafe" discard="unmap"/>
<source file="/var/lib/libvirt/images/win11.qcow2" index="4"/>
<backingStore/>
<target dev="sda" bus="sata"/>
<alias name="sata0-0-0"/>
<address type="drive" controller="0" bus="0" target="0" unit="0"/>
</disk>
Optimize-Volume -DriverLetter C returns:
VERBOSE: Invoking retrim on (C:)...
VERBOSE: Retrim: 0% complete...
VERBOSE: Retrim: 100% complete.
VERBOSE: Performing pass 1:
VERBOSE: Retrim: 87% complete...
VERBOSE: Retrim: 100% complete.
VERBOSE:
Post Defragmentation Report:
VERBOSE:
Volume Information:
VERBOSE: Volume size = 62.95 GB
VERBOSE: Cluster size = 4 KB
VERBOSE: Used space = 28.37 GB
VERBOSE: Free space = 34.58 GB
VERBOSE:
Retrim:
VERBOSE: Backed allocations = 63
VERBOSE: Allocations trimmed = 4967
VERBOSE: Total space trimmed = 37.42 GB
But with:
<disk type="file" device="disk">
<driver name="qemu" type="qcow2" cache="unsafe" discard="unmap"/>
<source file="/var/lib/libvirt/images/win11.qcow2"/>
<target dev="vda" bus="virtio"/>
<address type="pci" domain="0x0000" bus="0x06" slot="0x00" function="0x0"/>
</disk>
(observe: the same image)
The command returns:
VERBOSE: Invoking slab consolidation on (C:)...
VERBOSE: Slab Analysis: 0% complete...
VERBOSE: Slab Analysis: 100% complete.
VERBOSE: Retrim: 0% complete...
VERBOSE:
Slab consolidation was skipped because there were few evictable slabs.
VERBOSE: Retrim: 100% complete.
Optimize-Volume : The operation failed with return code 40004
Activity ID: {eecd28dd-2d8e-0000-834f-cdee8e2ddd01}
At line:1 char:1
+ Optimize-Volume -DriveLetter C -Verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (StorageWMI:ROOT/Microsoft/...age/MSFT_Volume) [Optimize-Volume], CimExcep
tion
+ FullyQualifiedErrorId : StorageWMI 40004,Optimize-Volume
I wonder if there is documentation on the drivers? I use this as source
grumpey
(Joe Walker)
August 16, 2026, 4:15pm
6
Merging the new thread with the existing thread.
Thanks