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

Windows Subsystem for Linux (WSL2) issues #43

Closed
ArcadioN09 opened this issue Jul 9, 2020 · 16 comments
Closed

Windows Subsystem for Linux (WSL2) issues #43

ArcadioN09 opened this issue Jul 9, 2020 · 16 comments
Labels
bug Something isn't working

Comments

@ArcadioN09
Copy link

ArcadioN09 commented Jul 9, 2020

After running the script, WSL2 running Ubuntu 20.04, doesn't seem to be connected to the internet.

Steps to reproduce:

  • Clean Windows Installation (Version 2004, OS Build: 19041.330)
  • Install WSL2 (Enable Windows Features: Windows Subsystem for Linux, Virtual Machine Platform)
  • Install a Distro (Ubuntu 20.04 LTS)
  • Run $ sudo apt-get update
  • Run $ sudo apt-get install build-essential checkinstall
  • Everything should work according to plan

(Issue starting here)

  • Run the latest script
  • Reboot PC.
  • Run $ sudo apt-get update
  • Run $ sudo apt-get install build-essential checkinstall
  • This time, you get the errors attached below.

image
(Figure 1: Running $ sudo apt-get update )

image
(Figure 2: VScode complaining about the same, bottom right corner )

image
(Figure 3: Running $ sudo apt-get install build-essential checkinstall )

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

Hm... Strange. Thanks for the report.

@ArcadioN09
Copy link
Author

Hm... Strange. Thanks for the report.

I tried enabling the disabled optional windows features and still the same.

Looks like it has something to do with the network adapter or perhaps the svchost grouping?

@ArcadioN09
Copy link
Author

ArcadioN09 commented Jul 9, 2020

Hey @farag2, i think i might have found the culprit.

Line #825
[# Change %TEMP% environment variable path to the %SystemDrive%\Temp](https://github.com/farag2/Windows-10-Setup-Script/blob/f6be74d13661aa044bf321ce369b271a0062c076/Win%2010%202004.ps1#L825)

Summary: No network if %temp% is moved.

Check the issue I linked below.
microsoft/WSL#5437

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

@ArcadioN09, LOL. You made me installing a VM and test. But I wasn't able to reproduce.
First, I run this

https://github.com/farag2/Windows-10-Setup-Script/blob/f6be74d13661aa044bf321ce369b271a0062c076/Win%2010%202004.ps1#L825

Restart. You can see that %temp% folder has been changed
Снимок экрана (2)

And all seems OK.
https://pastebin.com/AUVA1deW

@ArcadioN09
Copy link
Author

ArcadioN09 commented Jul 9, 2020

@farag2 , Just tested it by commenting out the lines #827 to #842. And it works perfectly now.

image

That indeed seems to be the issue for me running WSL2.

Did you run WSL2 or just a regular VM through a program like VMware?
Since it looks like a WSL2 specific issue.

EDIT:

Upon further research,
WSL 2 uses a swapFile which is located at %USERPROFILE%\AppData\Local\Temp\swap.vhdx
(https://docs.microsoft.com/en-us/windows/wsl/wsl-config)

When we change our temp directory to %SystemDrive%\Temp, WSL2 is unable to get access to this swapFile.

Possible Fixes:

  1. Disable checks for swapFile. Create a .wslconfig file in %userprofile%\ and enter the following.
[wsl2]
swap=0

(This disables the check for the swapFile)

  1. Comment lines lines #827 to #842 in the script before running.

  2. Monitor No network if %temp% moved microsoft/WSL#5437 as a fix is coming soon.

(All these fixes are mutually exclusive, so just choosing one should work)

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

@ArcadioN09, may the reason is that firstly I Installed WSL2 and then change the %temp% folder? Need more tests...

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

@ArcadioN09, where is the default location of swap.vhdx? I cannot find it in %USERPROFILE%\AppData\Local\Temp

@ArcadioN09
Copy link
Author

ArcadioN09 commented Jul 9, 2020

@ArcadioN09, may the reason is that firstly I Installed WSL2 and then change the %temp% folder? Need more tests...

I tested using two orders,

Order 1

  • Install WSL2
  • Run $ sudo apt-get update
    Everything works✅
  • Run the script
  • Reboot PC
  • Run $ sudo apt-get update
    Internet doesn’t work ❌

Order 2

  • On a fresh install, run the script
  • Reboot PC
  • Install WSL2
  • Run $ sudo apt-get update
    Internet doesn’t work ❌

I think once the script is run, a reboot or wsl —shutdown is required since if the VM instance was running when the debloat script is run, the VM stays unaffected as the swapFile is loaded during initialization.

@ArcadioN09
Copy link
Author

@ArcadioN09, where is the default location of swap.vhdx? I cannot find it in %USERPROFILE%\AppData\Local\Temp

%USERPROFILE%\AppData\Local\Temp

is the default location for the swap.vhdx file.

Could you please run the following command in cmd or powershell and tell me what you see?

wsl -l -v

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

@ArcadioN09

At last installed WSL2. For a long time I did not use WSL. So had to update Linux kernal and

wsl --set-default-version 2

now

PS C:\Windows\system32> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

And as I can see even %temp% changed to %SystemDrive%\Temp swap is located in %USERPROFILE%\AppData\Local\Temp anyway

I'm using Hyper-V only.

@ArcadioN09
Copy link
Author

I’m glad we figured out the issue.

Feel free it mark the issue as closed.

@farag2
Copy link
Owner

farag2 commented Jul 9, 2020

@ArcadioN09

we figured out the issue

Because you're using VMWare?

@ArcadioN09
Copy link
Author

@ArcadioN09

we figured out the issue

Because you're using VMWare?

As I pointed out earlier in one of my replies,

WSL2 looks for the swap.vhdx file in %SystemDrive%\Temp but since it was not created here swap will be inaccessible.
Because it cannot access the swap.vhdx file, network initialization is skipped. So we are left with no network.

I have posted the solutions/work-arounds above.

@farag2
Copy link
Owner

farag2 commented Jul 10, 2020

Temporary fix

https://github.com/farag2/Utilities/blob/master/WSL.ps1

@farag2 farag2 added the bug Something isn't working label Jul 10, 2020
@farag2 farag2 pinned this issue Aug 11, 2020
@farag2
Copy link
Owner

farag2 commented Aug 17, 2020

Seems microsoft/WSL#5437 (comment) has been fixed in the 20185 build.

@farag2 farag2 unpinned this issue Jan 5, 2021
@farag2
Copy link
Owner

farag2 commented Jan 27, 2021

I've tested, and already fixed it many weeks ago. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants