Can't trim Windows disk after restore

Rickb

New Member
Jan 16, 2024
12
2
3
Hey All,

I have a couple question on restoring windows VM from PBS on thin LVM.

1) We had a Windows 2022 server that had a 10TB disk with only 1TB od data in it that we had to restore. When we tried to restore it consumed the 10TB on the Thin LVM storage. Is there a why to work around this so it does not consum the whole configured disk size?

2) Why #1 is a big issue. I figured that I could just trim the disk after it was complete. At first I was getting a time out running the 'qm guest cmd 104 fstrim' from PVE. When I tried the "Optimize-Volume -DriveLetter D -ReTrim -Verbose" in the OS I kept getting the attached error(FullyQualifiedErrorId : StorageWMI 40002,Optimize-Volume) . I was able to concluded with some trial and error that there must be a limitation to where you can't run ReTrim on disk partition over about 4TB but I have not been able to find any supporting documentation. If I take the same 10TB and shrink the partition down to less then 4TB then it will run but will not remove all of the unused space, it only removed about 2.9TB of space on the thin LVM storage which make sense if the partition is not consuming the whole 10TB virtual disk.

I also added another test disk to the vm and with no data on the new 10TB disk I could not run ReTrim on it, shrunk the disk to just under 4TB and then it would run. It did take me a while to find out that you need to reboot on any shrink or expand of the partition or it will not see the partition size change when you run .

Thanks in advanced!

windowstrim.JPG
 
  • Like
Reactions: h4xor1701
I have the very same situation with a Windows 11 VM 24H2
the VM has 2 vDisks with this configuration:
- virtio0 for C drive [size=60Gb,iothread=1,discard=on]
- virtio2 for general DATA [size=500Gb,iothread=1,discard=on,cache=writeback,backup=0]
- controller=VirtIO SCSI single
- Proxmox version 8.2.4

the main one with OS partition can correctly execute trim with thin-LVM space optimization, but the other one can't.
This issue happen after i moved the DATA 'virtio2' drive from an LVM-thin with HDD backend storage to an SSD one.
 
Faced the same issue with a VM with 3 and 7 TB disks. I ended up using sdelete -z while being sure that the VM uses a VirtIO SCSI single controller and the Discard checkbox was ticked. Once the sdelete finished, the space got thin provisioned again in the storage.