Skip to content

[Bug]: Windows 11 WSL2 completely shuts down when inactive #10157

Closed

Description

@LWJerri

Windows Version

Microsoft Windows [Version 10.0.23471.1000]

WSL Version

Версия WSL: 1.2.5.0 Версия ядра: 5.15.90.1 Версия WSLg: 1.0.51 Версия MSRDC: 1.2.3770 Версия Direct3D: 1.608.2-61064218 Версия DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Версия Windows: 10.0.23471.1000

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) #1 SMP Fri Jan 27 02:56:13 UTC 2023

Distro Version

Release: 22.04

Other Software

Docker version 24.0.2, build cb74dfc

Repro Steps

  1. Open terminal with WSL2
  2. Close terminal and wait ~1 min.
  3. Open terminal again and run htop and see fresh uptime.

Expected Behavior

WSL should not shut down after some time of inactivity, I did not have this until a complete reinstallation of Windows.

Actual Behavior

WSL turns off completely.

Diagnostic Logs

No response

Activity

  1. LWJerri commented on Jun 2, 2023

    @LWJerri
    Author

    I don't have .wslconfig and my ws.conf:

    [boot]
    systemd=true
    
    [network]
    generateResolvConf=false
    
  2. aki-k commented on Jun 6, 2023

    @aki-k

    Andrii Zontov (@LWJerri) This is an intentional design decision by Microsoft. The time is actually just 8 seconds when the instance gets shut down.

    You can work around this issue by enabling systemd with https://github.com/DamionGans/ubuntu-wsl2-systemd-script instead of the solution provided by Microsoft.

    For Ubuntu 22.04 you also need the patch from DamionGans/ubuntu-wsl2-systemd-script#36 (comment) (the patch goes to the end of enter-systemd-namespace.

    You should also change basic.target to multi-user.target in both enter-systemd-namespace and start-systemd-namespace before running "bash ubuntu-wsl2-systemd-script.sh".

  3. LWJerri commented on Jun 6, 2023

    @LWJerri
    Author

    Andrii Zontov (@LWJerri) This is an intentional design decision by Microsoft. The time is actually just 8 seconds when the instance gets shut down.

    You can work around this issue by enabling systemd with https://github.com/DamionGans/ubuntu-wsl2-systemd-script instead of the solution provided by Microsoft.

    For Ubuntu 22.04 you also need the patch from DamionGans/ubuntu-wsl2-systemd-script#36 (comment) (the patch goes to the end of enter-systemd-namespace.

    You should also change basic.target to multi-user.target in both enter-systemd-namespace and start-systemd-namespace before running "bash ubuntu-wsl2-systemd-script.sh".

    Hello! Yeap, this solved my problem, thanks!

  4. aki-k commented on Jun 6, 2023

    @aki-k

    Andrii Zontov (@LWJerri) You could have left this issue open so that Microsoft could've also commented about the problem :)

  5. LWJerri commented on Jun 6, 2023

    @LWJerri
    Author

    Andrii Zontov (@LWJerri) You could have left this issue open so that Microsoft could've also commented about the problem :)

    I think it's something out of the realm of impossible, but okay, let's try it.

  6. aki-k commented on Jun 6, 2023

    @aki-k

    btw; you can check with

    tasklist | findstr /i "vm wsl"
    

    when the Windows-side processes close down

  7. ghost closed this as completedon Jun 6, 2023
  8. aki-k commented on Jun 16, 2023

    @aki-k

    Found a fix for this problem: #10138 (comment)

  9. zhl-HFUT commented on Oct 17, 2023

    @zhl-HFUT

    Andrii Zontov (@LWJerri) You could have left this issue open so that Microsoft could've also commented about the problem :)

    You helped me a lot today! I can see you under this relevant question, and it feels like you have a good understanding of WSL2. I'm really curious how you discovered the command "dbus-launch true".

  10. aki-k commented on Oct 17, 2023

    @aki-k

    I'm really curious how you discovered the command "dbus-launch true".

    I don't really remember how I found it, but it had something to do with other peoples' solutions to start a process in WSL 2 to keep the instance alive.

  11. aki-k commented on Oct 18, 2023

    @aki-k

    I think what's happening is that when you run "dbus-launch true" in WSL 2 instance, it starts the user dbus-daemon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions