fstrim for Windows Guests and Ceph Storage

starnetwork

Renowned Member
Dec 8, 2009
422
8
83
Hello,
how can I run fstrim solution for Windows KVM with Ceph storage?
the best is if possible to run it In a constant timing

Thanks!
 
discard is possible with virtio-scsi, but only with 2012 / Vista upwards

Windows 7 and Windows 2008R2 (and older ones of course) don't support the scsi unmap command.
(they support s-ata trim, but that is not supported in sata and virtio-blk driver)

with Windows server 2012 the optimization is usually run on a scheduled task
look for the "optimize drives" tool

so the answer is yes but not with Windows 7 or older
 
Hi,
thanks for that response!
as you can see at the screenshot, discard is disabled, Ceph + Virtio + OS Type: Win10/2016

any suggestion?
os should be power Off for that?

snip_20180321105505.png
 
You seem to use the virtio-blk driver (which does not support trim and may get deprecated)

Do the following:

-> add a additional dummy disk with virtio-scsi driver
-> install the virtio-scsi driver in the WIndows VM via device manager
-> remove the dummy disk again

then:

shutdown the vm
detach the disk from the vm
add it again with virtio-scsi treiber and discard on

Ahh and hopefully you did a backup and/or snapshot of the VM before in case something goes wrong ......
 
  • Like
Reactions: starnetwork
Thanks Klaus!
I did and got for the Win2016 blue screen after moved to virtio-scsi
also, for the win2012 it's not detecting the virtIO scsi driver from the last and stable ISOs

suggestions?
 
sure, I did for the 2016
add dummy drive, install and remove the dummy drive
after that I moved the disks to virtio-scsi and try to boot
 
did you really add the dummy disk as virtio-scsi?

with some of the ISO's for virtio-win some time back I had the problem that the device-manager did not find the correct driver and installed an incorrect one.
Then you had to browse to the correct driver and os Version to get the correct version
 
discard is possible with virtio-scsi, but only with 2012 / Vista upwards

Windows 7 and Windows 2008R2 (and older ones of course) don't support the scsi unmap command.
(they support s-ata trim, but that is not supported in sata and virtio-blk driver)
I just tested discard with latest proxmox 5.3, and sata is now trimming correctly with win7/2008r2 !
So if you want to have discard working correctly you need to use local-lvm (thin) and:
  1. os >= Win8/2012 + VirtIO SCSI controller + SCSI hdd + Discard option (best HDD perf)
  2. os = Win7/2008r2 + VirtIO SCSI controller + SATA hdd + Discard option
 
Last edited:
Hi,

after reading your posts I reconfigured my Windows 7 and Server 2008r2 systems to use SATA on Ceph RBD storage.

...
bootdisk: sata0
ostype: win7
sata0: ceph-proxmox-VMs:vm-106-disk-0,cache=writeback,discard=on,size=30G
scsihw: virtio-scsi-pci
...


Using https://github.com/CyberShadow/trimcheck I was able to confirm that it works for both mentioned versions.

Unfortunatly the qm agent <VMID> fstrim command gives the following message:

root@proxmox01:~# qm agent 106 fstrim
{
"error" : {
"class" : "GenericError",
"desc" : "fstrim is only supported for Win8+"
}
}
root@proxmox01:~#


So I ran disk optimizer within the OS.

Overall I was able to save 11% of the total used space on the Ceph storage...
 
Well, I validate this behavious with:
  • I setup on kvm with win7 "sata + discard" on one "local-lvm" + "thin pool" storage.
  • my win7 doesn't have any agent, so I can't run "qm agent xxx fstrim"
  • I made a backup of vm --> 20GB
  • I copied a big 10 gb file on my vm, I made a backup --> 30 GB
  • I delete the big 10 gb file on my vm, I made a backup --> 20GB again :)
 
Last edited:
Confirmed with another VM on Windows 7 and proxmox-ve: 5.3-1, discard is working well here with following conf:
Localt agent is not needed, nor fstrim command.

Code:
bootdisk: sata0
cores: 4
ide2: none,media=cdrom
keyboard: fr
memory: 8192
name: Generateur-Win7-202
net0: virtio=00:11:97:09:02:02,bridge=vmbr0
numa: 0
onboot: 1
ostype: win7
sata0: local-lvm:vm-202-disk-0,discard=on,size=110G
scsihw: virtio-scsi-pci
sockets: 1
tablet: 0
vga: std
 
Last edited:
Be carefull, even if "discard=on" is working with sata, there is a huge performance drop with sata vs scsi on Win7x64 :(
My local test on SSD show me that sata driver is 2 to 4 x slower than scsi.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!