Jump to content

Windows Subsystem for Linux starts on it's own

Zerebratox

Hi,

 

i'm not sure if im right in the Windows Part of the Forum, but at the end its an Windows application so i try it here.

I have WSL 2.0 installed and it normally doesnt make any problems, but lately my computer starts to randomly freeze and when i check why, in the events manager, it says that the HyperV Switch does some things like:

 

234: Hyper-V-VmSwitch: NIC 1A05225E-75E5-4A4F-8638-AE14E222EC32--FC785225-9131-5661-AC0C-3A157C61AE15 successfully disconnected from port
233: Hyper-V-VmSwitch: The operation 'Delete' succeeded on nic 1A05225E-75E5-4A4F-8638-AE14E222EC32--FC785225-9131-5661-AC0C-3A157C61AE15 (Friendly Name: ).

i realized that whenever i have a freeze, the event 234 and 233 is logged at the same time.

I use WSL as programming enviroment and had this problem some months before, it tried to resolve it by reinstalling windows from scratch, but now after a month it seems to reoccur.

Then i tried to use "Wsl -l --running" to check if WSL is currently running, and it does, without me ever starting it. I did wsl --shutdown and after that it wasn't running anymore, but 5 minutes later after checking it did start from it's own again.

I don't know what to do about the freezes and the wsl starting from its own.


Maybe someone can help me out here.
~Felix
 

Edited by Zerebratox
Narrowed the problem down
Link to comment
Share on other sites

Link to post
Share on other sites

31 minutes ago, GoodBytes said:

Do you have Docker, under Windows, installed?

No it's only WSL 2.0

But i narrowed the problem down.

It seems like WSL restarts every some minutes, when i is not currently started (when i manually start it).

Therefore if i dont work with it and close it, every 5-6 minutes the Hyper-V-VmSwitch decides to throw the log 234 and 233, 234 seems to unregister the port from WSL and 233 seems to delete the instance. 1 minute after that, it creates a new instance of WSL, and when i type wsl -l --running in powershell it is marked as running instance of wsl, but i didnt start it myself.

So i came to the conclusion that wsl tries to restart every 5-6 minutes, and i am not sure how to disable that.

Link to comment
Share on other sites

Link to post
Share on other sites

WSL is trash, advice is remove it.

Try removing WSL, rebooting, reinstall.

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, wilamu said:

WSL is trash, advice is remove it.

Try removing WSL, rebooting, reinstall.

Well, in this case you recommend me to use dual boot with linux?

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Zerebratox said:

Well, in this case you recommend me to use dual boot with linux?

I would try the removal and reinstallation of WSL first, but it's only my opinion that it's trash. You're not the only person I've seen with issues.

 

Either dual boot or run a VM but again that's just personal opinion and it's what I do. I've got 2 SSD's, one with PopOS! and the other running W10.

Link to comment
Share on other sites

Link to post
Share on other sites

35 minutes ago, wilamu said:

WSL is trash, advice is remove it.

Try removing WSL, rebooting, reinstall.

No its not. Stop spewing shit. It is used by a lot of dev and is working great.

 

Link to comment
Share on other sites

Link to post
Share on other sites

19 minutes ago, GoodBytes said:

No its not. Stop spewing shit. It is used by a lot of dev and is working great.

 

and you're a mod.......?

Link to comment
Share on other sites

Link to post
Share on other sites

5 hours ago, Zerebratox said:

No it's only WSL 2.0

But i narrowed the problem down.

It seems like WSL restarts every some minutes, when i is not currently started (when i manually start it).

Therefore if i dont work with it and close it, every 5-6 minutes the Hyper-V-VmSwitch decides to throw the log 234 and 233, 234 seems to unregister the port from WSL and 233 seems to delete the instance. 1 minute after that, it creates a new instance of WSL, and when i type wsl -l --running in powershell it is marked as running instance of wsl, but i didnt start it myself.

So i came to the conclusion that wsl tries to restart every 5-6 minutes, and i am not sure how to disable that.

 
 
 

So before wiping your environment, losing hours of work, if not more, as it was suggested above (which is completely unhelpful, and I really hope you didn't start doing it):

 

I investigated on my side on the behavior and WSL2 doesn't restart automatically, at least under: Version 20H2 Build 19042.685.

Confirmed by Event Viewer, and by executing (yes, I waited 10min and checked every 3min):

wsl --list --running

 

However, I confirmed that Windows Docker (which can integrate with WSL2) has such ability. Now you said that you don't use Docker, from my understanding, but to me it would suggest that you have a something else, on Windows side that relaunches it. Another example is Visual Studio Code, as it has WSL integration.

 

Another possibility, which I can't test to confirm, is if your Linux distro is borked where it kernel panics and reboots during shutdown. If that is indeed the case (not sure how to test this), it would depend on what you did under Linux. I guess one way to confirm this is to start your WSL2 distro, and open the command prompt and type it:

wsl --terminate <distro name>

Replace <distro name> with the name of the distro, example: Ubuntu-20.04

This should just kill it and not gracefully shutdown.

 

As for the event logs, the text itself is fine. for both It should occur when you shut down your WSL2.

 

Keep in mind, if you uninstall WSL, you could lose your distro, and you'll have to setup everything back. I highly recommend if you don't want to lose your distro work, if you want to do troubleshooting steps, you can back up your environment via:

wsl --export <distro name> "<path/filename>.tar"

Example:
wsl --export Ubuntu20.04 "C:\Users\Public\Ubuntu.tar"

In fact, I recommend to back it up regardless, for backup purposes. It should be part of your system backup routine.

 

This will take your distro and package it as a tar file, and store were specified (make sure the path you put has write access, else you'll need to run the command prompt as elevated credentials)

 

And to import it back in, to restore your distro environment, simply execute:

wsl --import <distro name> <tar folder location> <tar file name> --version 2

'version' specifies if it is WSL1 and 2.

 

So, to recap:

So far, based on the info you provided, I suspect that either your WSL2 distro kernel panics and restarts at shutdown, or simply, you have something under Windows, opening your WSL. This can be a script that executes: "wsl" command (without args). Check task scheduler and task manager for a program/script running that shouldn't. Check for any installed programs that integrates with WSL such as your IDE of choice (CLion is another one that integrates with WSL and will start it if it goes down).

Link to comment
Share on other sites

Link to post
Share on other sites

11 hours ago, GoodBytes said:

So before wiping your environment, losing hours of work, if not more, as it was suggested above (which is completely unhelpful, and I really hope you didn't start doing it):

 

I investigated on my side on the behavior and WSL2 doesn't restart automatically, at least under: Version 20H2 Build 19042.685.

Confirmed by Event Viewer, and by executing (yes, I waited 10min and checked every 3min):


wsl --list --running

 

However, I confirmed that Windows Docker (which can integrate with WSL2) has such ability. Now you said that you don't use Docker, from my understanding, but to me it would suggest that you have a something else, on Windows side that relaunches it. Another example is Visual Studio Code, as it has WSL integration.

 

Another possibility, which I can't test to confirm, is if your Linux distro is borked where it kernel panics and reboots during shutdown. If that is indeed the case (not sure how to test this), it would depend on what you did under Linux. I guess one way to confirm this is to start your WSL2 distro, and open the command prompt and type it:


wsl --terminate <distro name>

Replace <distro name> with the name of the distro, example: Ubuntu-20.04

This should just kill it and not gracefully shutdown.

 

As for the event logs, the text itself is fine. for both It should occur when you shut down your WSL2.

 

Keep in mind, if you uninstall WSL, you could lose your distro, and you'll have to setup everything back. I highly recommend if you don't want to lose your distro work, if you want to do troubleshooting steps, you can back up your environment via:


wsl --export <distro name> "<path/filename>.tar"

Example:
wsl --export Ubuntu20.04 "C:\Users\Public\Ubuntu.tar"

In fact, I recommend to back it up regardless, for backup purposes. It should be part of your system backup routine.

 

This will take your distro and package it as a tar file, and store were specified (make sure the path you put has write access, else you'll need to run the command prompt as elevated credentials)

 

And to import it back in, to restore your distro environment, simply execute:


wsl --import <distro name> <tar folder location> <tar file name> --version 2

'version' specifies if it is WSL1 and 2.

 

So, to recap:

So far, based on the info you provided, I suspect that either your WSL2 distro kernel panics and restarts at shutdown, or simply, you have something under Windows, opening your WSL. This can be a script that executes: "wsl" command (without args). Check task scheduler and task manager for a program/script running that shouldn't. Check for any installed programs that integrates with WSL such as your IDE of choice (CLion is another one that integrates with WSL and will start it if it goes down).

Thank you for your detailed information on this topic.

I did not wipe my WSL, because that was not my intention all along. I will check if VSCode or the Kernel does create a problem.

I will update if i have some new information.

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×