WSL: WSL2: Virtual hard disk files must be uncompressed and unencrypted and must not be sparse
Please fill out the below information:
-
Your Windows build number: Microsoft Windows [Version 10.0.18917.1000]
-
What you’re doing and what’s happening: I am trying to launch new distro under WSL2. I did first
wsl --set-default-version 2, went to the shop and downloaded Ubuntu. Then I went to Start and clicked Ubuntu. After couple of seconds I was greeted with following error:

- What’s wrong / what should be happening instead:
I should get a brand new distro under WSL2.
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 122
- Comments: 87 (3 by maintainers)
Okay, after some lucky guesses I’ve confirmed it and I have an addendum to the workaround (cc @caffme in case this works for you as well) - go to the Ubuntu directory in your profile folder (something like %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited…), right click on “LocalState”, Properties, Advanced, deselect “Compress contents” (and I suppose “Encrypt contents” as well if that’s checked). When it asks whether you want to apply to just this folder or to all subfolders and files, you can say “just this folder”, because all you’re doing is clearing that “compress” flag. After that the
wsl --set-versioncommand should work.OK, I managed to resolve it by myself after some intensive Googling by running those two commands:
and rebooting.
Now it just works™
Nonetheless I dont remember changing anything about NTFS behavior myself. Could it be that my laptop manufacturer (Dell) did it? Maybe this should be handled more gracefully by WSL2. Could WSL2 set those properties per virtual hard disk file to prevent others from hitting this?
Thanks, the workaround of manually disabling compression on
%localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgscworked for me. My guess is that the compression was enabled by the update that started doing that automatically a while ago to free up space for more updates (except from my experience it never actually decompresses them afterwards, unlike what the official website says)Same issue, slightly easier fix.
In my case, no reboot or reinstall of the app was necessary (effectively, just @dmchurch’s solution)
Problem solved using the @dmchurch solution, specifically: "go to the Ubuntu directory in your profile folder (something like %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited…), right click on “LocalState”, Properties, Advanced, deselect “Compress contents”
Target: Fresh install of wsl1+2 onto Windows Version 2004 (Build 19041.264) Fresh install of Ubuntu 20.04 onto wsl2
I had the same error. Fixed with a combination of @squeaky-pl and @dmchurch solutions
I can not update my existing distro, I am getting the same error in PS when trying to run the wsl --set-version. The workaround (set disableencryption and disablecompression, followed by reboot) did not help.
I can install a different distro and that works. I only tried that after I tried the workaround.
wsllogs.zip
Also, after hitting the error subsequent attempts give a different error: “The operation timed out because a response was not received from the virtual machine or container.” unless I use hcsdiag to kill the wsl container.
This error might also occur if you have manually set your WSL instance into sparse mode. Turns out there are two ways to do it: in .wslconfig and in terminal via
wsl --manage Ubuntu-20.04 --set-sparse true. To check whether your vhd is in sparse mode you should go to its LocalState folder and check if ext4.vhdx size on disk is smaller than its actual size. To unsparse it you should removesparseVhd=Truefrom .wslconfig and dowsl --manage Ubuntu-20.04 --set-sparse false.Just wanted to drop in and say thanks to @dmchurch for the tip about uncompressing those folders (and everyone else in the discussion helping each other find answers)
And afterwards I got the error about timing out … so I just restarted the computer and tried again and it worked just fine.
Based on my experience, because of this command, I cannot install windows terminal from windows store, so I set it back to zero, cheers!
@WSLUser - Indeed, we are looking into better solutions.
Shouldn’t the more correct solution be to support compression/decompression and encryption/decryption like you would with any other VHD utility? I’d say disabling is a good hot fix, but will need revisiting.
Thank you for the solution. This works.
Success to change wsl version to 2@dmchurch Thanks, yes that worked for me. I wondered about checking that but had no idea where WSL stored anything, good hunting!
@benhillis I am fairly sure that I didn’t set the compressed flag myself. C:\Users\James\AppData\Local\Packages was the highest folder in the tree that had the compressed flag and I would not have done that manually.
For me, nothing above was working, I just kept getting the “must not be encrypted or compressed” error. Even
wsl --manage Ubuntu-20.04 --set-sparse falseas mentioned by @nexus-chebykin didn’t seem to work until I manually setsparseVhd=falsein the .wsl_config file. Then, since I’m on Windows 10 home, proceeding with (in powershell):@nmbecke Different distribution would have different package folders. Mine Debian is in
%LOCALAPPDATA%\Packages\TheDebianProject.DebianGNULinux_76v4gfsz19hv4\LocalStateHow to find your distribution folder:This fixed my issue
I used @dmchurch method to solve the above problem, but I used this command instead of clicking
Maybe faster
My situation was a little different than @leodagostino.
sparseVhd=truein my .wsl_config file.wsl --shutdownthen rebooting linux).wsl --manage Ubuntu --set-sparse falseIf you find this error while googling and the file compression attributes are fine, the problem might be caused by the sparse flag.
Sadly, I think removing the flag using
corrupts the file if it is sparse. To not have your file corrupted you need to copy it in file explorer, verify in properties that size and size on disk are equal, and then run the above command to remove the flag.
Try checking the folder or drive if it was compressed to save disk space. Uncheck the box and try again. It worked for me.
It worked using this solution only after I applied to all folders/subfolders. Applying to this folder only didn’t work.
Compressed disks are now supported in 20211.
Be aware there is a performance penalty for running in this configuration. We are investigating adding support for encrypted VHDs.
I tried @dmchurch and @squeaky-pl solutions, and although I got rid of the “The requested operation could not be completed due to a virtual disk system limitation”, now I am getting:
Same here. I got the error after updating Windows.
For me it only worked after I uncompressed all subdirectories and files (explicitly
ext4.vhdx).I solved this issue by runnig the following from here:
fsutil sparse setflag “C:\Users\Public\Documents\Hyper-V\Virtual hard disks\testserver.vhdx” 0Ran into same error: 0xc03a0001a. Tried advice from @squeaky-pl fsutil behavior set disableencryption 1 fsutil behavior set disablecompression 1 with restart
Then advice from @dmchurch to locate %USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited…), right click on “LocalState”, Properties, Advanced, deselect “Compress contents” with restart
Still encountered error. Then…tried checking the “compress contents” and applying the change. Received an error that compression couldn’t be applied since the location was de-compressed (from executing the fsutil command previously). So unchecked the box and applied (to all subfolders). Did the same for the other folder in the Packages folder (there were two CanonicalGroupLimited Ubuntu folders), restarted and the install went through…finally!
Wanted to let folks know in case it was helpful to someone who tried this advice already and was still running into the issue.
Thanks @dmchurch and @squeaky-pl. After combining your advice and undoing/redoing the folder compression, it worked!
I just got the error mentioned in this issue after my computer was restarted from the latest Windows Update. I’m guessing the update process went and automatically compressed some folders to make space on the machine for updates? In any case clearing this flag on this folder did the trick, I was able to start Ubuntu 20.04 WSL2 again without having to restart the computer.
This Works!
WSL2 install apps in system partition in default. I met the same problem and tried execute “fsutil” command, but not solved. So i change location where apps install, in “Settings"→"Change where new content is saved"→"New apps will save to”, select another partition. It’s help to me.
Hi, the sad news, I do not have a solution, but maybe a helpinng workaround, which helped me. I tried all ideas over here (and some further ones from the whole web) without success. For me creating a new folder
%localappdata%\Packages\DebianWSL2for the WSL2-version of my running Debian (WSL1) and executing the following helpedOkay - it took some time, but it worked. Good luck. By the way - in the new folder the growing vhdx-file could be watched and the command
wsl -l -vshowedwhile running.
Is there any word on when WSL 2 will allow the virtual disk to be on a Bitlocker device? I tried it last week (19037.1) and WSL 2 fails to start when the ext4.vhdx file is encrypted.
I’d rather not use Ubuntu disk encryption in the VM if I can use Bitlocker instead
Thank you very much for filing this issue. It’s interesting that I’m not seeing that error in the logs, I’ll have to dig into why that isn’t showing up. I am seeing an invalid parameter error when trying to mount the VHD, so I bet that’s the inner error.
When creating the VHD’s I’ll make sure that compression and encryption are both disabled on them.
Been searching for a while how to recover a .vhdx drive that was made Windows-unmountable by nbd (in Linux). Thank you.
The error “The requested operation could not be completed due to a virtual disk system limitation. Virtual hard disk files must be uncompressed and unencrypted and must not be sparse” could also appear if you are using Windows Subsystem for Android (WSA).
Using these commands should do the trick:
+
(We don’t have any --set-sparse option for WSA.)
You might also need to manually untick “Compress contents to save disk space” (Properties -> Advanced) for userdata.vhdx and metadata.vhdx.
Then, if you want to shrink the VHDX files, you should be able to run via PowerShell:
Another alternative for
Optimize-VHDis by using diskpart: https://github.com/microsoft/WSL/issues/4103#issuecomment-2083127863 (mount both VHDX files and compact them, one by one)After you shrink the VHDX files, set sparse back:
And WSA will work afterward.
I leave this comment since this topic is very popular among Google search results, and it might be useful for people using WSA.
EDIT 2025: I’m not very sure if the first two commands (those starting with “
fsutil behavior set”) are really necessary, but you can do the rest commands via Powershell.Run in a elevated window of Powershell the following command:
$files=Get-ChildItem "$env:LOCALAPPDATA\Packages\MicrosoftCorporationII.WindowsSubsystemForAndroid_8wekyb3d8bbwe\LocalCache" -Recurse -Filter *.vhdx; $files|%{compact /u /i "$($_.FullName)"}; $files|%{fsutil sparse setflag "$($_.FullName)" 0}; $files|%{Optimize-VHD -Path $_.FullName -Mode Full}; $files|%{compact /c /i "$($_.FullName)"}; $files|%{fsutil sparse setflag "$($_.FullName)" 1}The above command programmatically removes compression and the sparse flag from each VHDX file, performs a full optimization, then re-applies compression and the sparse attribute.
Wow; I did not know this was a thing.
So, my
ext4.vhdxfor Docker Desktop was a bit big and I figured I’d enable NTFS compression on it. Didn’t save much anyway, but then I started having WSL issues after, hadn’t used Docker Desktop in a few days but after rebooting after a Windows Update (which was the first thing I blamed, of course) WSL instances weren’t starting up (non-Docker ones, I wasn’t even using Docker at the time) and I was able to kill WSL in task manager and get my Ubuntu instance running. I couldn’t even kill WSL usingwsl --shutdownor by stopping it inservices.mscor even PSGet-Service WSLService | Stop-Service(though I could stop/restartLxssManagerwith PS.Didn’t think about it for a few days and needed Docker today and it wouldn’t start, just hung. Tried the usual, Windows Update, Reboot, restart services, nothing.
Checked Event Viewier:
Dunno if anything broke while it was compressing after enabling compression; 7-zip seems to read it file other than mentioning a header error.
Can’t disable compression on the file either now:
Same error using
compact.exe… Figured I’d copy it to another drive and copy back to disable compression; just as I was typing this I got an error about not enough disk space, the target drive definitely has enough space so I was thinking ‘WTF’ again but now my C: is completely filled (I guess it decompressing it on the same drive before copying?), space isn’t being reclaimed after the copy failure and I don’t even know where to start looking to purge the cache.I’m about to just obliterate it, it’s 99.99% Docker cache and ephermal stuff, but I’d still rather not.
And after looking; as I suspected it’s not even a visible file but now my C: is technically corrupt.
So, I delete a bunch of stuff to make sure I have well over the 150gb that the VHDX is free, try copying again. Got a successful copy to another drive, but again the journal didn’t release the space after copy; now have 300gb stuck in the journal. Ugh. Now to delete the original, reboot, hope it releases, if not, kill/recreate the journal and cross fingers I don’t have to image the drive, format, copy back with crossed fingers, or worse, re-install. I almost miss Win3.1/Win95/Win98 days when re-install was a daily/weekly thing, now I’m old and crusty and don’t want to set everything up again 😢
Ugh; and of course, the file doesn’t want to delete.
Well, after a reboot that I almost gave up waiting for, free space is as expected and the file was able to be deleted. Let’s hope this hell is over.
Phew. Even got my Docker back after copying the VHDX back over.
Note to self and anyone else; Don’t ever use NTFS compression on WSL VHDX files! Ever! EVER!@#$
Deselecting only the
UbuntuonWindows’sLocalStatedidn’t solve it for meC:\Users\%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalStatebut also deselecting theUbuntu’sLocalStatesolved it.C:\Users\%USERPROFILE%\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu_79rhkp1fndgsc\LocalStateI didn’t even have to restart anything before running
--set-version Ubuntu 2again.Thank you.
Dropping in to say I had this issue and I couldn’t solve it for the life of me until I realized the drive was set for “Compress this drive to save disk space” in Disk Management Unchecked box and formatted drive solved it for me Hope it helps someone 😃
WORKING FOR ME !!!
I was worried BitLocker could be part of the problem with encryption part, but it was not a problem. I do have compression on the whole drive and partial setting turning off compression using file explorer for
%USERPROFILE%\AppData\Local\Packages\<some linux os>works for me. I have to turn off compression on all folders below<some linux os>to get it to work.It has not been updated in any way on the instructions page. Over a year since the original problem was reported…and it’s still happening.
I get the potential inability with why you can’t install VHD on Encrypted NTFS, but why at least isn’t this in the troubleshooting section of the install instructions page?
And in case anyone hasn’t guessed, exact same problem here…same solution.
same problem here fixed with @dmchurch solution
Also, @squeaky-pl solution works, but after rebooting you have to uninstall and install again Ubuntu. Hope this helps.
Tried solutions from comments https://github.com/microsoft/WSL/issues/4103#issuecomment-501511504 https://github.com/microsoft/WSL/issues/4103#issuecomment-501885534 by @squeaky-pl and @dmchurch . Didn’t work. Restarted a couple of times. The error message is either
or timing out. Checked BIOS. The virtualization is enabled. Laptop Dell XPS 15 9560.
UPDATE: I actually made it working. So, contrary to @dmchurch 's answer, I did go over of subfolders of C:\Users\stran\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_… folder and unmarked “compress to save disk space” checkbox, but when asked I went for “also for subdirectories”. It took around 2 hours though. On an SSD.
Tequi
I don’t even see the \AppData\Local\ in my disk.
I copied a pasted those commands, one at a time, into Powershell, restarted my pc and BAM! Every distro I wanted is now installing again. Thanks for the save!!
This fixed my issue too
These commands seem to cause my UWP applications (include Microsoft Todo and Windows Terminal) to crash back.
@quangkieu yeah that’s understood, I’m stating that the fix does not work for the fedora release currently available on the MS store. It works on Ubuntu 18.04 and 20.04.
Thanks for the fixes above. I used @squeaky-pl and @dmchurch 's solutions, including rebooting. It still showed up the same error. I then reset the Ubuntu 20.04 app, and opened it, and it worked fine.
Thanks you everyone