Support for TRIM on BitLocker encrypted VHDX
6 posts
I am currently managing a VHDX volume encrypted with BitLocker. At the moment, I mount the VHDX and use manage-bde and compact vdisk to reclaim unused space from the volume. This process is relatively slow and inconvenient. It would be much more convenient if Virtual Disk Trim could handle encrypted volumes directly.
Are there any plans to support TRIM for encrypted volumes in the future?
Thanks for the suggestion, we're looking into it. Technically it's possible if the application can have access to the key, so it comes down to where the key is.
Could you tell us more about your case: how the volume is unlocked when you mount it (a password, the 48-digit recovery key, a key file, or automatically?), and where that key is kept? Or just describe your setup in a few words, for example whether BitLocker was turned on from the host or from inside a VM.
Thank you for confirming that.
In my case, I normally unlock the encrypted volume using a password. I also have access to the recovery key, so I can use that to unlock the volume if necessary.
In most cases, the VHDX is mounted directly on the host. However, I may also copy the VHDX file to a virtual machine and mount it there when needed.
The encrypted volume is never used as a system volume. It is used solely for data storage as a virtual drive.
Good news: the latest build in snapshots can trim BitLocker volumes using the password or the recovery key.
Detach the VHDX, add it to Virtual Disk Trim, choose Image → Unlock and enter the password or the 48-digit recovery key. The free space inside the volume is then trimmed along with the rest.
The volume stays encrypted: data is decrypted in memory only to find the free clusters, and the password is not stored. The command line tool takes it too, prompting for it or reading it from a pipe:
vdtrim trim --replace --password - "D:\Data\Vault.vhdx"
Let us know how it works for you.
Thank you for the update. I tested the new unlock feature, and the encrypted volume is now recognized correctly when I enter the password. I haven't been able to test the shrinking feature yet, as I don't currently have a license.
However, I noticed that the shrinking process requires free space equivalent to the full size of the VHDX. This is a bit of a concern for me, as my VHDX files are nearly 1 TB each. Having to copy that much data every time I want to shrink a volume would be quite demanding in terms of both time and storage space.
Thanks for testing the unlock.
The free space needed is the size of the trimmed image, not the original: only blocks holding data are written, so a 1 TB VHDX with 300 GB in use needs roughly 300 GB free. The copy is deliberate, as the original isn't touched until the new one is verified.
Shrinking in place, with almost no extra space, is something we're looking into for VHDX. But it requires very careful testing, since there's no original to fall back on. What does the Savings column show for your VHDX after unlocking?
As Virtual Disk Trim is a new product, we'd be glad to give you a free licence in exchange for your feedback and testing. Please send us a private message through our contact form and mention this thread.