microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.37k stars 817 forks source link

Ubuntu 22.04 with systemd can't start #11411

Closed Alex6357 closed 6 months ago

Alex6357 commented 6 months ago

Windows Version

Microsoft Windows [版本 10.0.22631.3374]

WSL Version

2.1.5.0

Are you using WSL 1 or WSL 2?

Kernel Version

6.6.23, also 5.15.146.1-2

Distro Version

Ubuntu 22.04

Other Software

No response

Repro Steps

Import ubuntu via ubuntu-base-22.04.3-base-amd64.tar.gz Enable systemd in /etc/wsl.conf Restart Ubuntu

Expected Behavior

Boot normally

Actual Behavior

灾难性故障 Error code: Wsl/Service/CreateInstance/E_UNEXPECTED

[已退出进程,代码为 4294967295 (0xffffffff)] 现在可以使用Ctrl+D关闭此终端,或按 Enter 重新启动。

Diagnostic Logs

WslLogs-2024-04-02_17-17-52.zip

github-actions[bot] commented 6 months ago

View similar issues

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

Diagnostic information
.wslconfig found
    Custom kernel found: 'C:\WSL2\boot\kernel-6.6.23'
Detected appx version: 2.1.5.0
Detected user visible error: Wsl/Service/CreateInstance/E_UNEXPECTED

zcobol commented 6 months ago

@Alex6357 it fails because that image has no systemd installed:

[    0.977488] init[144]: segfault at 1 ip 00000000003000ca sp 00007ffe4bda7758 error 4 in init[277000+14c000]
[    0.978003] Code: e9 db 01 00 00 cc cc cc cc cc cc cc cc cc cc cc 48 85 d2 41 0f 95 c0 40 f6 c7 07 0f 84 2b 01 00 00 48 85 d2 0f 84 22 01 00 00 <40> 38 37 75 0b 48 89 f8 48 89 d1 e9 96 01 00 00 48 8d 47 01 48 89
[    0.978843] potentially unexpected fatal signal 11.
[    0.979086] CPU: 5 PID: 144 Comm: init Not tainted 5.15.150.1-microsoft-standard-WSL2 #1
[    0.979518] RIP: 0033:0x3000ca
[    0.979687] Code: e9 db 01 00 00 cc cc cc cc cc cc cc cc cc cc cc 48 85 d2 41 0f 95 c0 40 f6 c7 07 0f 84 2b 01 00 00 48 85 d2 0f 84 22 01 00 00 <40> 38 37 75 0b 48 89 f8 48 89 d1 e9 96 01 00 00 48 8d 47 01 48 89
[    0.980399] RSP: 002b:00007ffe4bda7758 EFLAGS: 00010206
[    0.980633] RAX: 000000007fffffff RBX: 000000007fffffff RCX: 000000000022d354
[    0.981025] RDX: 000000007fffffff RSI: 0000000000000000 RDI: 0000000000000001
[    0.981422] RBP: 0000000000000000 R08: 00000000ffffff01 R09: 000000000022d460
[    0.981740] R10: cccccccccccccccd R11: 00000000ffffffff R12: 000000007fffffcd
[    0.982125] R13: 0000000000000073 R14: 0000000000000001 R15: 00000000ffffffff
[    0.982495] FS:  00000000003dcb00 GS:  0000000000000000

To get a Ubuntu image with systemd download from https://cloud-images.ubuntu.com/wsl or install required packages before enabling systemd and restart.

Alex6357 commented 6 months ago

Hi, @zcobol

Thanks for your help!

@Alex6357 it fails because that image has no systemd installed:

I do have systemd installed in my distro.

alex11@DESKTOP-F0ORQ92:~$ whereis systemd
systemd: /usr/bin/systemd /usr/lib/systemd /etc/systemd /usr/share/systemd

But I just realized that it didn't install the package systemd-sysv to create link /usr/sbin/init -> /lib/systemd/systemd automatically...

To get a Ubuntu image with systemd download from https://cloud-images.ubuntu.com/wsl or install required packages before enabling systemd and restart.

I searched for "wsl" with apt and found the package ubuntu-wsl. My distro can start after installing it.

uuxia commented 2 months ago

@Alex6357 could you share more detail about how to fix this? I have the same problem and don't know how to start the Ubuntu and change the wsl.conf file.

Alex6357 commented 2 months ago

@Alex6357 could you share more detail about how to fix this? I have the same problem and don't know how to start the Ubuntu and change the wsl.conf file.

Install ubuntu-wsl. This will install systemd-sysv and create symbolic /usr/sbin/init -> /lib/systemd/systemd. Also you can just install systemd-sysv or create the link manually.

You can mount ext4.vhdx to another wsl and edit the file.

uuxia commented 2 months ago

I see. So I have to create another wsl and mount this broken in new wsl to edit the conf file?