Windows Subsystem for Linux launches independently
Windows Subsystem for Linux launches independently
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 January 7, 2021 by Zerebratox Narrowed the problem down
It's only WSL 2.0, but I managed to simplify the issue. It appears WSL restarts periodically—every few minutes—when it isn't actively running (like when I manually start it). This causes the Hyper-V-VmSwitch to log entries 234 and 233. 234 seems to remove the WSL port from the system, while 233 deletes the instance. About a minute later, a new WSL instance appears, and when I run wsl -l --running in PowerShell it shows as active, even though I didn't start it. I'm unsure how to stop this automatic restart.
You might want to consider dual booting with Linux for better flexibility and system management.
I’d consider trying to remove and reinstall WSL first, though I think it’s a bad idea. You’re not alone in having problems with that. Dual boot or using a VM are both options, but they’re just my preferences. I have two SSDs—one with PopOS and the other running Windows 10.
It's not what you think. Just stop talking too much. It's commonly used by developers and it's functioning well.
Before clearing your system, losing significant time—possibly more than that—as previously mentioned (which seems unhelpful and I truly wish you hadn't started this)—I looked into the issue myself. Specifically, on Version 20H2 Build 19042.685, I checked the behavior and confirmed that WSL2 doesn't restart automatically under certain conditions. This was verified using Event Viewer and by running wsl --list --running for a short period. I also noted that Windows Docker, which works with WSL2, has this capability. You mentioned not using Docker, but it seems possible you have another method on Windows that triggers a restart. Visual Studio Code, which supports WSL integration, is another example. Another possibility is that your Linux distribution has a kernel issue causing it to panic and reboot during shutdown. If this is the case, it likely depends on what you did on Linux. One way to test would be to start your WSL2 environment and run: wsl --terminate <distro name>, replacing <distro name> with the actual name, such as Ubuntu-20.04. This would force a clean shutdown without graceful exit. Regarding the logs, the information provided is accurate—this should happen when you shut down WSL2. Remember, removing WSL would erase your setup, so backing up is essential. I suggest saving your environment via wsl --export <distro name> "<path/filename>.tar" for safety. This should be part of your regular backup routine. To restore, run wsl --import <distro name> with the exported file and the specified path. In summary, based on what you shared, it appears your WSL2 kernel might crash and restart at shutdown, or there could be a Windows-side process restarting it. Check task scheduler, task manager, and installed WSL-related software for any unusual activity. If you run a script that executes wsl without arguments, it could be the culprit.