WSL2: How to Fix "Virtual hard disk files must be uncompressed and unencrypted and must not be sparse"


I recently migrated from WSL 1 to WSL 2, which is simply a new version of the WSL architecture that changes how Linux distributions interact with Windows.

I was trying to set my WSL version with this command:

# Set Ubuntu distro to WSL 2
wsl --set-version Ubuntu-20.04 2

This resulted in the following error:

The requested operation could not be completed due to a virtual disk limitation. 
Virtual hard disk files must be uncompressed and unencrypted and must not be sparse.

In order to fix this, open up File Explorer and navigate to:

C:\Users\YOUR_USER\AppData\Local\Packages\CanonicalGroupLimited...

Right click on LocalState, then Properties, then Advanced.

Ensure Compress contents to save disk space and Encrypt contents to secure data are both deselected.

Click OK, then Apply, then Apply changes to this folder only

Voila. You’re free to use wsl --set-version.