9 comments

[ 2.7 ms ] story [ 33.4 ms ] thread
I think Optimize-VHD will do the same thing as messing with diskpart.

It's a shame you can't just turn on live TRIM support.

This kind of disk image is a bunch of multi-megabyte blocks of data, plus a list of where each block goes on the virtual disk. Implementations can support TRIM by deleting the block that's zeroed and moving the block at the end of the file into that spot. VirtualBox can do this, shrinking the file when the guest OS TRIMs, but Hyper-V can't.

I'm done with WSL. It just makes life too hard, dual disk is a problem, two network endpoints two firewalls, two different hypervisors you can choose from where some things expect one some the other.

I used to think a windows laptop would be better for hardware management, maybe it is but I just gave up and installed Linux. My life is so much easier.

Actually great intro for step-by-step powershell scripting.

I thought I didn't know about "Throw-And-Exit" command, but no, my powershell doesn't have that and google also doesn't know a thing, so wonder what's up with that.

And instead of manual confirmations, one can write script with ShouldProcess support to have support for builtin -Confirm/-WhatIf/-Force parameters. And it would actually be a great use case for that scheduled task to run with -Force parameter instead of changing code to strip out confirmations. https://learn.microsoft.com/en-us/powershell/scripting/learn...

You also may need to run fstrim inside WSL to make all the free space actually compactible
By the way, is WSL1, which doesn't use vhds and so doesn't suffer from such issues (but has slowed io), effectively abandoned by MS?
You can run wsl1 and wsl2 side by side