I'm trying to set up a Windows 10 VM using QEMU and I want to use a thinly-provisioned LVM volume and be able to "retrim" the drive in Windows. I created the device with:
-drive index=0,media=disk,if=virtio,format=raw,file=/dev/vg0/myvol
,
But when I run Optimize-Volume -DriveLetter c -Defrag -ReTrim
in Windows PowerShell, it claims that the backing device does not support trim. How can I get this to work?
Best Answer
So forgive me, but I'm going to answer my own question because I spent almost two days on this and there needs to be an answer somewhere online!
The ChangeLog for the virtio drivers states that they added "preliminary support for discard (unmap) command" to
viostor
in 0.1.172-1, but it still failed -- this is an unstable release anyway.I found the my answer here, which was to essentially replace this:
with this:
To summarize the whole process:
lvcreate -L 1t --thinpool tpool vg0
)lvcreate --verbose --thin vg0/tpool --virtualsize 128G --name win10
)spicy -p 12347 -h localhost -w like_so_secret
e:\vioscsi\w10\amd64
)e:\virtio-win-gt-x64.msi
. It will want to finish the windows setup after it gets a network card, but you can skip it.Optimize-Volume -DriveLetter c -Degrag -ReTrim -Verbose
If all goes well, you won't get an error message and blocks no longer used by the NTFS file system will be discarded and returned back to the LVM thin pool. If you omit
-Verbose
, it prints a pretty progress bar in the top of the powershell, but doesn't print the result because they suck like that. You can select the System Reserved partition as well by replacing-DriveLetter c
with-FileSystemLabel "System Reserved"
.I should probably note that I'm using
gtk-spice
-- the reference implementation for thespice
protocol (also the only one I know of). I set up the ssh port so I can setup cygwin and run sshd.