WSL icon indicating copy to clipboard operation
WSL copied to clipboard

System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

Open TylerJaacks opened this issue 3 years ago • 129 comments

Version

Microsoft Windows [Version 10.0.22621.521]

WSL Version

  • [X] 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

TylerJaacks avatar Sep 24 '22 23:09 TylerJaacks

└─(18:13:37)──> cat /etc/wsl.conf                                                                       ──(Sat,Sep24)─┘
[boot]
systemd=true```

TylerJaacks avatar Sep 24 '22 23:09 TylerJaacks

@TylerJaacks based on the kernel version you posted, you're using WSL 0.65.1. In order to use systemd you'll have to upgrade to latest release, WSL 0.67.6. What is the output of wsl --version or wsl --status?

elsaco avatar Sep 24 '22 23:09 elsaco

Yeah 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 avatar Sep 24 '22 23:09 TylerJaacks

@TylerJaacks based on the kernel version you posted, you're using WSL 0.65.1. In order to use systemd you'll have to upgrade to latest release, WSL 0.67.6. What is the output of wsl --version or wsl --status?

If I am not wrong then it's only available to insiders for now, or is it available for all?

tusharsnx avatar Sep 26 '22 06:09 tusharsnx

download 0.67.6 in https://github.com/microsoft/WSL/releases page

echoechoin avatar Sep 27 '22 03:09 echoechoin

So I just gave up on this Preview and will wait for Stable cause it works fine on Stable Windows 11 Branch and then Systemd just breaks and If I try to run wsl.exe --shutdown I get the hanging computer issue.

TylerJaacks avatar Sep 27 '22 19:09 TylerJaacks

So I have the same issue. It was working previously so I have no idea why it stopped working. I am using version from github releases. Here is the output for --version.

Kernel version: 5.15.62.1
WSLg version: 1.0.44
MSRDC version: 1.2.3401
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.22000.1042```

ejazahm3d avatar Oct 02 '22 06:10 ejazahm3d

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.conf Then retry.

Thanks to @echoechoin.

scruel avatar Nov 21 '22 06:11 scruel

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.

  • Install WSL from within Windows Store
  • Install update KB5020030. (I had to download it manually from the Update Catalog)

This "install from Store" might also solve W11 problems. Check that first if this error happens.

yilmazdurmaz avatar Nov 24 '22 20:11 yilmazdurmaz

I'm having the same issue on windows 10 pro

C:\WINDOWS\system32>wsl --version
WSL version: 1.0.0.0
Kernel version: 5.15.74.2
WSLg version: 1.0.47
MSRDC version: 1.2.3575
Direct3D version: 1.606.4
DXCore version: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows version: 10.0.19045.2311
luc@wsl2-ubuntu$ systemctl status cron
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

luc-vocab avatar Nov 30 '22 06:11 luc-vocab

@luc-languagetools your system seems ready to use it. I am guessing you have forgotten to activate it in /etc/wsl.conf. please read answers in this thread to see how you do it.

yilmazdurmaz avatar Nov 30 '22 09:11 yilmazdurmaz

I already have

[boot]
systemd=true

in .wslconfig. And I did run wsl --shutdown to restart.

luc-vocab avatar Nov 30 '22 09:11 luc-vocab

it is not %userprofile%\.wslconfig you would be editing. it is /etc/wsl.conf inside. you will need to have root access

wsl  # in cmd or powershell
sudo nano /etc/wsl.conf # or use your fav editor
  #insert those 2 lines you have, then save the file and exit the editor
  # Ctrl+X for nano, confirm write, confirm the name
exit
wsl --shutdown #  first shutdown
wsl # then restart

PS: this .wslconfig thing 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

yilmazdurmaz avatar Nov 30 '22 10:11 yilmazdurmaz

@yilmazdurmaz you are correct, I had been mistakenly editing %USERPROFILE%.wslconfig

[boot]
systemd=true

should go into /etc/wsl.conf on the filesystem inside WSL. And now it works ! I really appreciate your help !

luc-vocab avatar Nov 30 '22 10:11 luc-vocab

@yilmazdurmaz @luc-languagetools I cant find the /etc/wsl.conf on the filesystem, do I need to create it myself

Oluadepe avatar Dec 10 '22 22:12 Oluadepe

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.conf Then retry.

Thanks to @echoechoin.

I have the latest release of WSL, but /etc/wsl.conf is not present in the filesystem, do i have to manually create it?

Oluadepe avatar Dec 10 '22 22:12 Oluadepe

@Oluadepe yes, if /etc/wsl.conf is not present already create a new file and add systemd setting to it.

elsaco avatar Dec 10 '22 22:12 elsaco

@Oluadepe yes, if /etc/wsl.conf is not present already create a new file and add systemd setting to it.

I just did and it worked. 🎉🎉🎉

Oluadepe avatar Dec 10 '22 22:12 Oluadepe

Let me unify the answers

  • open a terminal and run this command: 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)
  • now log into WSL by wsl command in the same or new windows console (or ubuntu for example, if you have many distributions)
  • inside the wsl shell, edit /etc/wsl.conf file as root or with sudo: sudo nano /etc/wsl.conf (use your favorite linux editor)
  • insert these 2 lines
[boot]
systemd=true
  • exit the shell
  • shutdown wsl: wsl --shutdown
  • then restart it again: wsl.

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:

  • we need the new WSL 1.x.x series, or Store version (latest 1.1.3.0, as of now),
  • and version 2 (WSL2 not WSL),
  • and LF/0A line endings (not CRLF/0D0A)
  • also dbus inside the distro might be needed, install related packages so that users can use it too. (at least, Debian comes without dbus)
  • also acpi inside the distro causes problems, uninstall related packages.

yilmazdurmaz avatar Dec 11 '22 06:12 yilmazdurmaz

Распределение по умолчанию: Ubuntu-20.04 Версия по умолчанию: 2 (WSL-2) Версия ядра: 5.10.102.1

I got an error:

sudo systemctl status postgresql

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

I did all the things above:

cat /etc/wsl.conf
[boot]
systemd=true

I did run wsl --shutdown to restart

ghost avatar Dec 12 '22 16:12 ghost

@Luxpy what version of WSL are you running? systemd support was added in https://github.com/microsoft/WSL/releases/tag/0.67.6, the same release that introduced Microsoft.WSL.Kernel version 5.15.62.1. Looks like you're running an older kernel implying an older WSL.

I can confirm that systemd works okay in Ubuntu 20.04 and WSL 1.0.0:

elsaco@RIPPER:~$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.3 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
elsaco@RIPPER:~$ systemctl status --no-pager
● RIPPER
    State: degraded
     Jobs: 0 queued
   Failed: 6 units
    Since: Mon 2022-12-12 08:22:02 PST; 19s ago
   CGroup: /
           ├─user.slice
           │ └─user-1000.slice
           │   ├─[email protected]
           │   │ ├─session.slice
           │   │ │ ├─pipewire-media-session.service
           │   │ │ └─pipewire.service
           │   │ ├─app.slice
           │   │ │ ├─at-spi-dbus-bus.service
           │   │ │ └─dbus.service
           │   │ └─init.scope
           │   └─session-c1.scope
           ├─init.scope
           └─system.slice
---cut---

elsaco avatar Dec 12 '22 16:12 elsaco

check this link if you haven't yet. https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/

Ensuring you are on the right WSL version This change is only available in the "Microsoft Store version of WSL" version 0.67.6 and higher. You can check your version number by running wsl --version. If that command fails then you are running the in-Windows version of WSL and need to upgrade to the Store version

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 --update to make sure of getting fixes. my current version shows these lines.

WSL version: 1.0.3.0
Kernel version: 5.15.79.1

for a few other important details, check my above post: https://github.com/microsoft/WSL/issues/8883#issuecomment-1345472665

yilmazdurmaz avatar Dec 12 '22 19:12 yilmazdurmaz

Let me unify the answers

* open a terminal and run this command: `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 [WSL v1.0.0 cannot be installed on Windows 10 Version 19045, whereas supported on the System Requirements on Microsoft Store #9157](https://github.com/microsoft/WSL/issues/9157))

* now log into WSL by `wsl` command in the same or new windows console (or `ubuntu` for example, if you have many distributions)

* inside the wsl shell, edit `/etc/wsl.conf` file as root or with sudo: `sudo nano /etc/wsl.conf` (use your favorite linux editor)

* insert these 2 lines
[boot]
systemd=true
* `exit` the shell

* shutdown wsl: `wsl --shutdown`

* then restart it again: `wsl`.

Yup. This worked like a charm! Thanks

Tamoghna-Saha avatar Dec 14 '22 04:12 Tamoghna-Saha

wsl --version

Hi @yilmazdurmaz , What if we don't have access to store version (as it is blocked by company's IT policy in my case). Do you have any suggestion for this problem?

Thanks in advance.

mert-kurttutan avatar Dec 16 '22 11:12 mert-kurttutan

What if we don't have access to store version (as it is blocked by company's IT policy in my case).

In case you use your own laptop, just find a permissive internet (a friend's maybe). If it is a company PC/laptop and you are in constant use of WSL, especially for docker containers, you need to contact your administrators to have it installed. otherwise, any other way you install it may seem offensive to them. However, if you are new to WSL and you don't care about initd, which is the main problem we were discussing, you can still try installing the internal one, enabling it from windows features. from "app & features" settings, find "related settings" down the list, go to "programs and features" and use "turn windows features on or off" link on the left. it is still a full-featured WSL except for some new features added in recent months. only when you need these new things, then you need the new store version.

yilmazdurmaz avatar Dec 16 '22 18:12 yilmazdurmaz

if you use WSL. run service service_name start insted of ystemctl start service_name

Systemd command => Sysvinit command -- | -- systemctl start service_name=>service service_name start systemctl stop service_name=> service service_name stop systemctl restart service_name=> service service_name restart systemctl status service_name=>service service_name status systemctl enable service_name => chkconfig service_name on systemctl disable service_name=> chkconfig service_na

TechNov avatar Jan 16 '23 10:01 TechNov

Hi! im trying to make systemD work on WSL, followed all the instructions from above (i couldn't install KB5020030 as it keeps failing telling me This Update Is Not Applicable To Your Computer, tried from 21H1 version and upgraded to 22H2 version with no sucess). Currently: C:\Users\diegu>wsl --version Versión de WSL: 1.1.3.0 Versión de kernel: 5.15.90.1 Versión de WSLg: 1.0.49 Versión de MSRDC: 1.2.3770 Versión de Direct3D: 1.608.2-61064218 Versión DXCore: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp Versión de Windows: 10.0.19045.2673

Tried with ubuntu 20.04 and upgraded to 22.04 but still didn't work: cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy

systemctl status --no-pager System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down

sudo cat /etc/wsl.conf [boot] systemd=true

any ideas?

dieguiariel avatar Mar 05 '23 03:03 dieguiariel

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).

Tried with ubuntu 20.04 and upgraded to 22.04 but still didn't work

each distro is a new virtual machine, and each machine must be configured separately to start with systemd, then must be restarted.

wsl --list -v # need version 2
wsl --set-version distronameyouset 2
wsl -d distronameyouset
sudo nano /etc/wsl.conf # or any editor that uses LF, or 0A, as new line
exit
wsl --terminate distronameyouset # shutdown single
# wsl --shutdown # shutdown all
wsl -d distronameyouset

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.

yilmazdurmaz avatar Mar 05 '23 06:03 yilmazdurmaz

Hi, thanks for your resnpose: About the KB version: Device name pc-PC Processor Intel(R) Core(TM) 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

  • Ubuntu-20.04 Running 1

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

  • Ubuntu-20.04 Stopped 2

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!!!

dieguiariel avatar Mar 05 '23 13:03 dieguiariel

About the wsl or wsl2 version you pointed me in the right direction: wsl -l -v Ubuntu-20.04 Running 1 wsl --set-version Ubuntu-20.04 2

nice! I wasn't sure about that. It is good to know WSL2 is required to get a working SystemD.

yilmazdurmaz avatar Mar 05 '23 13:03 yilmazdurmaz