Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSL2: Virtual hard disk files must be uncompressed and unencrypted and must not be sparse #4103

Open
squeaky-pl opened this issue Jun 13, 2019 · 64 comments

Comments

@squeaky-pl
Copy link

@squeaky-pl squeaky-pl commented Jun 13, 2019

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:

Screenshot_205

  • What's wrong / what should be happening instead:

I should get a brand new distro under WSL2.

@squeaky-pl
Copy link
Author

@squeaky-pl squeaky-pl commented Jun 13, 2019

Attaching logs.

logs.zip

@squeaky-pl
Copy link
Author

@squeaky-pl squeaky-pl commented Jun 13, 2019

OK, I managed to resolve it by myself after some intensive Googling by running those two commands:

fsutil behavior set disableencryption 1
fsutil behavior set disablecompression 1

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?

@benhillis
Copy link
Member

@benhillis benhillis commented Jun 13, 2019

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.

@caffme
Copy link

@caffme caffme commented Jun 13, 2019

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.

shot_190613_171648

wsllogs.zip

@caffme
Copy link

@caffme caffme commented Jun 13, 2019

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.

shot_190613_181110

@dmchurch
Copy link

@dmchurch dmchurch commented Jun 13, 2019

I'm encountering the same issue as @caffme. I assume this is because the folder the VHD is supposed to go into is marked as compressed or something, even though I've done the fsutil workaround. Where is the WSL2 VHD supposed to be located? I can't find any documentation on that, even though the "expand your VHD" documents mention putting in the path to it.

@dmchurch
Copy link

@dmchurch dmchurch commented Jun 13, 2019

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-version command should work.

@illera88
Copy link

@illera88 illera88 commented Jun 13, 2019

I had the same error. Fixed with a combination of @squeaky-pl and @dmchurch solutions

@caffme
Copy link

@caffme caffme commented Jun 14, 2019

@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.

@krzys-h
Copy link

@krzys-h krzys-h commented Jun 22, 2019

Thanks, the workaround of manually disabling compression on %localappdata%\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc worked 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)

@jsbarrett
Copy link

@jsbarrett jsbarrett commented Jul 2, 2019

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.

@WSLUser
Copy link

@WSLUser WSLUser commented Jul 3, 2019

When creating the VHD's I'll make sure that compression and encryption are both disabled on them.

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.

@benhillis
Copy link
Member

@benhillis benhillis commented Jul 3, 2019

@WSLUser - Indeed, we are looking into better solutions.

@mebeZ
Copy link

@mebeZ mebeZ commented Aug 8, 2019

Here's what worked for me...

Go to this link: https://docs.microsoft.com/en-us/windows/wsl/install-win10

When you're installing linux distro, do option 3: Download and manually unpack and install (for Windows Server - instructions here)

@scardena
Copy link

@scardena scardena commented Aug 18, 2019

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:

Exporting the distribution failed.
bsdtar: Write error

@kevinthemself
Copy link

@kevinthemself kevinthemself commented Aug 30, 2019

Just ran into this issue and had to restart the computer a few times before I saw my distro running under wsl -l -v, fwiw. I ran through the fsutil commands, as well as manually decompressing the package in %localappdata%\Packages\CanonicalGroup... I'm guessing the VHD is compressed until it's started, at which point the conversion works?

@davidasync
Copy link

@davidasync davidasync commented Sep 14, 2019

OK, I managed to resolve it by myself after some intensive Googling by running those two commands:

fsutil behavior set disableencryption 1
fsutil behavior set disablecompression 1

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?

Based on my experience, because of this command, I cannot install windows terminal from windows store, so I set it back to zero,
cheers!

@benhillis
Copy link
Member

@benhillis benhillis commented Sep 11, 2020

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.

@EdwardBaek
Copy link

@EdwardBaek EdwardBaek commented Sep 11, 2020

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-version command should work.

Thank you for the solution. This works.

  1. Upgrade Windows 10 version from 190x to 2004
  2. Right-clicked on %LOCALAPPDATA%\Packages{yourPackgeName}
  3. Properties->General->Advanced, unchecked 'Compress contents to save disk space', applied to this folder only
  4. Fail to change wsl version to 2
  5. Right-clicked on %LOCALAPPDATA%\Packages{yourPackgeName}\LocalState
  6. Properties->General->Advanced, unchecked 'Compress contents to save disk space', applied to this folder only
  7. Success to change wsl version to 2

@baharestani
Copy link

@baharestani baharestani commented Dec 31, 2020

ecause all you're doing

It worked using this solution only after I applied to all folders/subfolders. Applying to this folder only didn't work.

@lukasgodfrey
Copy link

@lukasgodfrey lukasgodfrey commented Jan 1, 2021

Try checking the folder or drive if it was compressed to save disk space. Uncheck the box and try again. It worked for me.
image

@Adron4444
Copy link

@Adron4444 Adron4444 commented Jan 2, 2021

@Lmendev
Copy link

@Lmendev Lmendev commented Jan 7, 2021

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-version command should work.

This fixed my issue

Same for me. Did this get added to install instructions? I must have skimmed the page.

This fixed my issue too

@Injected420
Copy link

@Injected420 Injected420 commented Jan 25, 2021

OK, I managed to resolve it by myself after some intensive Googling by running those two commands:

fsutil behavior set disableencryption 1
fsutil behavior set disablecompression 1

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?

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!!

@FormyStar
Copy link

@FormyStar FormyStar commented Feb 3, 2021

i hade a problem to and i did not know how to fix it and it was a error code 0xc03a001a and i did not help with all the solutions of yours. so i searched up in apps from settings and searched kali linux or ubuntu and healed/ reinstalled it and now it works again and i can use kali linux or ubuntu
so for people that dont have a sultion anymore here you go

@Darknez07
Copy link

@Darknez07 Darknez07 commented Feb 5, 2021

Microsoft should really do something about WSL, it often causes the problem with the docker specially.

@highlightswitch
Copy link

@highlightswitch highlightswitch commented Feb 8, 2021

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-version command should work.

Even after doing this and a reboot it still didn't work for me. I got it working by doing this then reinstalling Ubuntu from the Windows Store. Thanks for the help :)

@zhengyangma9517
Copy link

@zhengyangma9517 zhengyangma9517 commented Feb 8, 2021

I don't even see the \AppData\Local\ in my disk.

@zhengyangma9517
Copy link

@zhengyangma9517 zhengyangma9517 commented Feb 8, 2021

WSL2 works perfectly last Friday, and It gave me this error just right after 2 days.
I don't know why this happened and why the system can update the file settings itself, compressing some of the files on my disk, which is ridiculous.
I can't work actually because of this issue.

@Injected420
Copy link

@Injected420 Injected420 commented Feb 10, 2021

WSL2 works perfectly last Friday, and It gave me this error just right after 2 days.
I don't know why this happened and why the system can update the file settings itself, compressing some of the files on my disk, which is ridiculous.
I can't work actually because of this issue.

I think they dropped an update for the WSL around that time. My stance on Open-Source software, especially something of this level: I can't complain, it is free, all I can do is submit feedback/bugs when I run into them and solider on!

@ErwinP
Copy link

@ErwinP ErwinP commented Feb 10, 2021

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-version command should work.

Just dropping by to say that this helped for me as well. I'm on a Surface Pro and disk space is becoming sparce. After a reboot, I got the error above. I suppose that due to the limited disk space, the compression of the virtual machine kicked in. Unchecking the "compress" flag, followed by wsl --shutdown in powershell, enabled wls2 without the need of a compleet reboot.

Thanks!

Edit

After solving this problem, internet on WSL2 wasn't working. It appeared that %TEMP% was compressed as well, which causes this problems. Decompressing %TEMP% worked emmediately. Here is the link to that particular issue.

@johndelavega
Copy link

@johndelavega johndelavega commented Feb 25, 2021

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.

@QAston
Copy link

@QAston QAston commented Apr 20, 2021

If you find this error while googling and the file compression attributes are fine, the problem might be caused by the sparse flag.

fsutil sparse getflag path/to/file.vhdx

Sadly, I think removing the flag using

fsutil sparse setflag path/to/file.vhdx 0

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.

@pedro0506
Copy link

@pedro0506 pedro0506 commented Apr 21, 2021

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-version command should work.

WORKING FOR ME !!!!

@soredake
Copy link

@soredake soredake commented May 26, 2021

compact /U "$env:USERPROFILE\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState"

@JohnRDOrazio
Copy link

@JohnRDOrazio JohnRDOrazio commented Jun 11, 2021

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).

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.

@djbrown
Copy link

@djbrown djbrown commented Jun 16, 2021

Same here. I got the error after updating Windows.

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.

For me it only worked after I uncompressed all subdirectories and files (explicitly ext4.vhdx).

@Bha91
Copy link

@Bha91 Bha91 commented Jul 11, 2021

uninstalling 18.04 and installing 20.4 solved my problem

@swayok
Copy link

@swayok swayok commented Jul 19, 2021

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-version command should work.

This worked for me too.
Also it would be better to uncheck File/Folder is ready for archiving either on root folder of your distro selecting apply to all files and subfolders or just on LocalState/ext4.vhdx file to prevent this problem in future.

@GDI512
Copy link

@GDI512 GDI512 commented Aug 17, 2021

Decompressing the *.vhdx file won't work as you still won't be able to get the network connection from WSL2. Unless you don't plan to apt update ever again that is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet