WSL: System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Version
Microsoft Windows [Version 10.0.22621.521]
WSL Version
- WSL 2
- WSL 1
Kernel Version
5.15.57.1
Distro Version
Ubuntu 22.04.1 LTS
Other Software
N/A
Repro Steps
Enable systemd via /etc/wsl.conf
Run sudo systemctl list-units --type=service
Expected Behavior
List of services show.
Actual Behavior
System has not been booted with systemd as init system (PID 1). Can’t operate. Failed to connect to bus: Host is down
Diagnostic Logs
No response
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 129
Let me unify the answers
wsl --version. If you see “WSL version: 1.0.0.0” (or higher in 1.x.x.x) then you are ready to go. Else, follow the installation instructions until you see it. (Installing KB5020030 might be needed as discussed in https://github.com/microsoft/WSL/issues/9157)wslcommand in the same or new windows console (orubuntufor example, if you have many distributions)/etc/wsl.conffile as root or with sudo:sudo nano /etc/wsl.conf(use your favorite linux editor)exitthe shellwsl --shutdownwsl.EDIT: 2023-03-07 There were new cases and new defining moments to solve the problem. In addition to above lines, as a summary of things below, here are a few new requirements to be aware of:
in addition to /etc/wsl.conf with correct content:
Problem solved: Goto https://github.com/microsoft/WSL/releases, download new version of WSL (0.67.6 and higher), install and reboot your system. Enable systemd via
/etc/wsl.confThen retry.Thanks to @echoechoin.
it is not
%userprofile%\.wslconfigyou would be editing. it is/etc/wsl.confinside. you will need to have root accessPS: this
.wslconfigthing might be something that wsl team have in mind. at least for now, that is the other file you need to edit.PS: please refer to this post down below for a short intro/warning about terminal editors: https://github.com/microsoft/WSL/issues/8883#issuecomment-1465758773
I’m running a fully updated 21H2 version, was unable to start WSL with systemd enabled. My wsl.conf came with
by default, nevertheless, systemd was not available.
I installed “Windows Subsystem for Linux” from the MS Store, like I always did, which is apparently where the issue comes from. Store version of WSL is broken, and it does not even come up in the Store search (it was hidden and I had to google for the URL).
wsl --statusreported that I indeed use WSL2, but my WSL kernel version was 5.10.102.1. Apparently, this version does not support systemd and WSLg.wsl --updatealso reported that my WSL is updated to the last available version, which is not true. Latest WSL kernel at this moment is 5.15, but this kernel is not listed on MS’s own update catalog.I tried to download latest WSL from the Github releases page, but the installer just crashed.
My solution was to install WSL from dism:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestartAfter that, reboot and run
wsl --update. Now my kernel version is 5.15 and systemd works properly.Hi, thanks for your resnpose: About the KB version: Device name pc-PC Processor Intel® Core™ i5-4200M CPU @ 2.50GHz 2.50 GHz Installed RAM 8.00 GB Device ID 6BA11125-2FCF-4573-8DA3-266A8ED87C58 Product ID 00330-80000-00000-AA476 System type 64-bit operating system, x64-based processor Pen and touch No pen or touch input is available for this display
tried the x64 version but when it fails, just in case ive tried all versions, and tried with the 21H1 and 22H2 (i was on 21H1 before thinking having systemD was a good idea xD…)
C:\Users\diegu>wsl --list Distribuciones de subsistema de Windows para Linux: Ubuntu-20.04 (predeterminado)
C:\Users\diegu>wsl -d Ubuntu-20.04 diego@pc-PC:/mnt/c/Users/diegu$ sudo nano /etc/wsl.conf [sudo] password for diego: sudo: a password is required diego@pc-PC:/mnt/c/Users/diegu$ sudo cat /etc/wsl.conf [sudo] password for diego: [boot] systemd=true diego@pc-PC:/mnt/c/Users/diegu$
About the wsl or wsl2 version you pointed me in the right direction:
C:\Users\diegu>wsl -l -v NAME STATE VERSION
C:\Users\diegu>wsl --set-version Ubuntu-20.04 2 Para obtener información sobre las diferencias clave con WSL 2, visita https://aka.ms/wsl2
Conversión en curso. Esta operación puede tardar unos minutos. The operation completed successfully.
C:\Users\diegu>wsl -l -v NAME STATE VERSION
C:\Users\diegu>
and 👍 tadaaa! diego@pc-PC:/mnt/c/WINDOWS/system32$ systemctl status --no-pager ● pc-PC State: starting Jobs: 5 queued Failed: 1 units Since: Sun 2023-03-05 10:17:53 -03; 26s ago CGroup: / ├─init.scope │ └─1 /sbin/init
thank you very much!!!
@yilmazdurmaz you are correct, I had been mistakenly editing %USERPROFILE%.wslconfig
should go into
/etc/wsl.confon the filesystem inside WSL. And now it works ! I really appreciate your help !your wsl version is 1.1.3.0 which means you already have a compatible version. that KB update possibly fails since you try to use arm64 on x64, or vice versa (you downloaded a wrong version).
each distro is a new virtual machine, and each machine must be configured separately to start with systemd, then must be restarted.
there is one thing I am not sure about: this might require an x64 machine but you use x86 (32bit). and one more possible thing is, I don’t know if has any relation, is WSL versus WSL2; can’t say if 1.1.3.0 is possible with WSL but worth checking. try the above way first, then check these possibilities.
EDIT: After receiving the next answer, I put the “set-version” step in case someone in the future reads these steps. we need WSL2.
I already have
in
.wslconfig. And I did runwsl --shutdownto restart.Thanks, This https://github.com/microsoft/WSL/issues/8883#issuecomment-1455090207 worked for me
Although the question was asked for Windows 11, the same error also comes up in Windows 10 installations if some updates are missing. These steps are for W10 users.
This “install from Store” might also solve W11 problems. Check that first if this error happens.
nice! I wasn’t sure about that. It is good to know WSL2 is required to get a working SystemD.
@Oluadepe yes, if
/etc/wsl.confis not present already create a new file and addsystemdsetting to it.It worked after an update
wsl --update, i tried all the above without successI still had issues with
systemctlprobably because of the line breaks. I removed the/etc/wsl.conffile and recreated it again with nano inside WSL and it worked.I did exactly what you stated here. for some reasons my kernel version still remains at 5.10.102.1
Hi @doraemonxxx, Here, this might be the culprit in your case 😉
Please first restart your PC and then check if the problem continues. Also check if the “default” is to use version 2, not version 1.
https://learn.microsoft.com/en-us/windows/wsl/install#upgrade-version-from-wsl-1-to-wsl-2
Ubuntu 22.04 comes with a config file set for systemd, thus it should work fine if WSL gets installed fine and set correctly.
Installed Windows, WSL2 and Ubuntu this weekend. In ‘/etc/wsl.conf’ it was already set to true, but systemd did not work. Out of frustration I changed it to false, shutdown, change back to true and shutdown again. Now systemd is working 😫
ps.
wsl --versionreturns help…@dieguiariel Thanks , bro. “wsl --set-version Ubuntu-2204 2” made it. stu**d ms…
On Windows 10, running these commands fixed systemd issue:
Found it from this link: https://gist.github.com/alyleite/ca8b10581dbecd722d9dcc35b50d9b2b
Распределение по умолчанию: Ubuntu-20.04 Версия по умолчанию: 2 (WSL-2) Версия ядра: 5.10.102.1
I got an error:
I did all the things above:
I did run
wsl --shutdownto restartYeah so I just figured it out now whenever I run the command and it just takes a while and gives me
Failed to list units: Transport endpoint is not connected@TylerJaacks based on the kernel version you posted, you’re using
WSL 0.65.1. In order to usesystemdyou’ll have to upgrade to latest release,WSL 0.67.6. What is the output ofwsl --versionorwsl --status?I was spending an hour trying to get systemd working on an old WSL install of Arch. /etc/wsl.conf was perfectly fine, yet systemd did not start.
For anyone who is convinced that everything else is right: You need a symlink in
/sbin(or, well,/usr/bin), which is part of new Arch installs but not my old one:ln -s ../lib/systemd/systemd initsystemd works like a charm now. 😃
@MeechaPooch you seem you have edited the config file to add default user. My guess is that you used an editor that changed the line endings from linux format (LF-0A) to dos format (CRLF-0D0A). system fails to load the config file in this case.
try
hexdump /etc/wsl.confand see if this is the case (does Ubuntu have hexdump by default? you may need to install it)Fixing it depends on the editors to use and their settings for this format, and it will be long to give instructions here. Please search the internet about fixing this line ending problem.
@nathanneibauer looks like your WSL was updated on 2/12/2014, but the kernel version is
5.10.16. That’s an old kernel. Latest WSL kernel is5.15.146.1.I just did a quick test and systemd is working right after installation:
WSL info:
@yilmazdurmaz @elsaco I have checked the link above, and it turns out that I just need to type “wsl --update” in the command prompt to update to the store version. and it works after that, thank you
I found this thread useful. I was struggling with the upgrade and realised that the WSL2 was installed but I also needed to update existing distros to be of the new version. I found this comment and the following one very useful. https://github.com/microsoft/WSL/issues/8883#issuecomment-1455090207
@dieguiariel Hola, dear Diegu. Your solution worked for me. Muchas gracias🙏
The file doesn’t exist on my Debian system and after creatiing it and following your steps my systemd is still not running in WSL.
Edit: Found the reason. Your formatting is wrong. Should have been:
Now it works fine! 😃
@fredxia , using
daemonizeis just overkill as it is an ancient relic of programs. and at least for Ubuntu and Debian distros, there is no need for such a thing either, let alone if it works as it should for this is not a stand-alone Linux system because, again, it was created in ancient times before Linux even existed. ubuntu change logs for example has “unstable” in each version maintained last 10 years.However here, there are just a couple of missing things in instructions, and this discussion has them most, if not all to solve problems in modern (and easy) ways. From the command you gave, it seems that system is possibly a Debian and it misses
dbus. just installing it would even solve their problem. [here in this answer above from @elsaco ]https://github.com/microsoft/WSL/issues/8883#issuecomment-1458687389) tellslibpam-systemdwould solve without going fancy.@yilmazdurmaz Thanks alot as described in #9029 removing acpid has worked for me
@yilmazdurmaz that’s correct, Debian distro (at least the one pulled by
wsl --install Debianis from thewingetstore, didn’t try with themsstoreversion) is lackingdbuspackage, preventingsystemdfrom working. After adding itsystemd status --useris still not working showingFailed to connect to busbecause of the missing PAM module. After installinglibpam-systemdit works. Without this plugin(s) PAM won’t be able toRegister user sessions in systemd control group hierarchy. Usepam-auth-updatefor more details.Quick test:
No
libpam-systemdpackage:libpam-systemdinstalled:Hi @B0ba-Yaga, it seems, in Debian, it might be one of these: either you forgot to create
/etc/wsl.confwith the correct content, or you created it with an editor that uses CRLF line endings (we discussed just above). I suggest you check these probabilities. however, for Ubuntu, you somehow disabledsystemdfor USER.I already have Ubuntu 20 and 22 with no issue running it. I have now downloaded the current Debian (update note says 11.6) and with the correct config file, it gave me only the error you described for the Ubuntu:
Failed to connect to bus: No such file or directory. despite the error,systemdis running and the root user can use it.I searched for this second error, and it is directly related to
DBUS, in fact to its absence.apt list --installed | grep buswill tell you it is missing. I installed dbus for debian,sudo apt-get install dbus, and immediately, the problem is solved 🎉 🎉 🎉 (yours should also be solved, I am hoping)Fact summary, in addition to
/etc/wsl.confwith correct content:dbusinside the distro so that users can use it too. (at least, Debian comes without dbus)@yilmazdurmaz thanks for help. its caused by the
wsl.conffile encoding or right i dont konw, but i was use explorer.exe to create this file in windows env before. when i drop this file and recreate it in wsl bash, it’s worked now.😊check this link if you haven’t yet. https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
You need to have the “Store version” from now on. Open “Microsoft Store” app and search “Windows Subsystem for Linux”. I forgot where I read but there was a statement like “WSL will continue with the store version and receive all new ‘feature’ updates from there”. and its latest version has the following signature (at least mine shows no update available). Also use
wsl --updateto make sure of getting fixes. my current version shows these lines.for a few other important details, check my above post: https://github.com/microsoft/WSL/issues/8883#issuecomment-1345472665