Open nadavwolfin opened 4 years ago
Looks like daemonize wasn't found for some reason.
You should be able to log into WSL by typing "wsl -u root" in cmd or powershell. Check if daemonize is installed by typing "which daemonize". I assume you'll have no output (I have "/usr/bin/daemonize" for example). If you do have some output, please post it in a reply. You can either install daemonize or disable the startup script.
To install daemonize type: "sudo apt-get install daemonize" Do note however, that it's quite likely that the other things the script tried to install failed. You can run the script again in that case. Remember to sudo it.
If you want to disable the systemd start script, do the following: Enter in "nano /etc/bash.bashrc" Put a # on the start of the line that says "source /usr/sbin/start-systemd-namespace" To enable the systemd start script again, simply remove the newly added #
I'm having this issue as well, could ZSH come into play with it not working?
Not working on a clean install of Ubuntu 20.04 LTS
Fails with:
x@Test:~/ubuntu-wsl2-systemd-script$ systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Script execution output:
x@Test:~/ubuntu-wsl2-systemd-script$ uname -a
Linux Test 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
x@Test:~/ubuntu-wsl2-systemd-script$ bash ubuntu-wsl2-systemd-script.sh
Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Selecting previously unselected package daemonize.
(Reading database ... 31877 files and directories currently installed.)
Preparing to unpack .../daemonize_1.7.8-1_amd64.deb ...
Unpacking daemonize (1.7.8-1) ...
Selecting previously unselected package fontconfig.
Preparing to unpack .../fontconfig_2.13.1-2ubuntu3_amd64.deb ...
Unpacking fontconfig (2.13.1-2ubuntu3) ...
Setting up fontconfig (2.13.1-2ubuntu3) ...
Regenerating fonts cache... done.
Setting up daemonize (1.7.8-1) ...
Processing triggers for man-db (2.9.1-1) ...
'\\wsl$\Ubuntu-20.04\home\x\ubuntu-wsl2-systemd-script'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
SUCCESS: Specified value was saved.
'\\wsl$\Ubuntu-20.04\home\x\ubuntu-wsl2-systemd-script'
CMD.EXE was started with the above path as the current directory.
UNC paths are not supported. Defaulting to Windows directory.
SUCCESS: Specified value was saved.
x@Test:~/ubuntu-wsl2-systemd-script$ systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Not working on a clean install of Ubuntu 20.04 LTS
Fails with:
x@Test:~/ubuntu-wsl2-systemd-script$ systemctl
System has not been booted with systemd as init system (PID 1). Can't operate.Script execution output:
x@Test:~/ubuntu-wsl2-systemd-script$ uname -a Linux Test 4.19.104-microsoft-standard #1 SMP Wed Feb 19 06:37:35 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux x@Test:~/ubuntu-wsl2-systemd-script$ bash ubuntu-wsl2-systemd-script.sh Hit:1 http://security.ubuntu.com/ubuntu focal-security InRelease Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease Reading package lists... Done Selecting previously unselected package daemonize. (Reading database ... 31877 files and directories currently installed.) Preparing to unpack .../daemonize_1.7.8-1_amd64.deb ... Unpacking daemonize (1.7.8-1) ... Selecting previously unselected package fontconfig. Preparing to unpack .../fontconfig_2.13.1-2ubuntu3_amd64.deb ... Unpacking fontconfig (2.13.1-2ubuntu3) ... Setting up fontconfig (2.13.1-2ubuntu3) ... Regenerating fonts cache... done. Setting up daemonize (1.7.8-1) ... Processing triggers for man-db (2.9.1-1) ... '\\wsl$\Ubuntu-20.04\home\x\ubuntu-wsl2-systemd-script' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. SUCCESS: Specified value was saved. '\\wsl$\Ubuntu-20.04\home\x\ubuntu-wsl2-systemd-script' CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows directory. SUCCESS: Specified value was saved. x@Test:~/ubuntu-wsl2-systemd-script$ systemctl System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Same error I get
Same here. Even more, it leads to some other errors(like this https://github.com/DamionGans/ubuntu-wsl2-systemd-script/issues/39). The worst thing is that the uninstall script is not available. Only Ubuntu reinstallation helped me.
Make sure after the script install you terminate the distro with wsl.exe -t Ubuntu-20.04
.
After reopening the terminal you should be able to see the output of snap version
.
A bit of en evil loop - I cannot get wsl
running,
λ wsl
Cannot execute daemonize to start systemd.
in order to get daeminze - I'm back to were I started with apt not working:
root@EP_Win8:/mnt/c/tools/sd_script# sudo apt-get install daemonize
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
accountsservice apport-symptoms command-not-found-data gdisk gir1.2-glib-2.0 iso-codes
libaccountsservice0 libdumbnet1 libgirepository-1.0-1 libllvm8 python-apt-common run-one
Use 'sudo apt autoremove' to remove them.
E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
E: Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Success
Any hope?
It helped however to disable the script as @Xideta pointed.
enter wsl as wsl -u root
, then:
If you want to disable the systemd start script, do the following: Enter in "nano /etc/bash.bashrc" Put a # on the start of the line that says "source /usr/sbin/start-systemd-namespace" To enable the systemd start script again, simply remove the newly added #
This was the 'uninstall' procedure, in my case.
I have the same issue, but when logging in via wsl (wsl -u <user>
), I get this:
Sleeping for 1 second to let systemd settle
nsenter: cannot open /proc/24/ns/cgroup: No such file or directory
I'm using WSL2 + Ubuntu18.04
Edit: Has anyone tried the script mentioned in this comment: https://github.com/systemd/systemd/issues/8036#issuecomment-682240966
same issue. Not working for me. Thanks for the effort.
gnome-session was not workig for me, and then analizing the script, i ran sudo apt-get remove -yqq daemonize dbus-user-session fontconfig
, what is the reverse what did done the script, and I started recieving this message: cannot execure daemonize for systemd.
So the script may be failing to install the packages on some users...
I use WSL2 + Ubuntu20.04. Solve the error "Cannot execute daemonize to start systemd." like this:
wsl -u root
enters the shell, then solve it by installing "apt-get install daemonize".
systemctl System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: 主机关闭
Same for me, exactl the same error like @svpn has. Was able to recover with wsl -u root
in cmd. Turns out, daemonize wasn't installed. Disabling the script for now.
This has left my WSL dead, it doesn't even work the trick it used to:
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME
Error:
nsenter: failed to execute 2744: No such file or directory
[proceso terminado con el código 1]
How can I leave everything as it was?
Put a # on the start of the line that says
source /usr/sbin/start-systemd-namespace
on /etc/bash.bashrc
Ubuntu 18.04 via wsl 2
I ran into this issue and solved it by uninstalling daemonize. Reinstalling sudo apt install daemonize
. Exiting wsl. Re-enter wsl. And made sure the daemonize
command worked.
"wsl -u root did not work for me since the environmental variable pointed to /etc/bash.bashrc. I was able to access the my wsl instance via the windows using \wsl$ in file explorer. I removed source /usr/sbin/start-systemd-namespace from /etc/bash.bashrc with notepad. and the instance worked. I guess I could have removed the environment variable first. Nevertheless, my wsl2 instance is back working. I hope this helps someone. So don't destroy your machine.
"wsl -u root did not work for me since the environmental variable pointed to /etc/bash.bashrc. I was able to access the my wsl instance via the windows using \wsl$ in file explorer. I removed source /usr/sbin/start-systemd-namespace from /etc/bash.bashrc with notepad. and the instance worked. I guess I could have removed the environment variable first. Nevertheless, my wsl2 instance is back working. I hope this helps someone. So don't destroy your machine.
In powershell
wsl.exe -e bash --norc
sudo vi /etc/bash.bashrc
and comment line consist "source /usr/sbin/start-systemd-namespace".
I got similar issue error as
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
My wsl2 Env are using zsh, wslg, ms insider for windows 10 I check wsl in sudo mode or daemonize but it wasn't related to my issue
I check this issue and it works to my wsl https://github.com/DamionGans/ubuntu-wsl2-systemd-script/issues/25#issue-649660338
source /usr/sbin/start-systemd-namespace
in .zshrcsource .zshrc
And work
I solved it!
1: sudo vi /etc/bash.bashrc 2: commit to "source /usr/sbin/start-systemd-namespace"
commenting this line causes this : System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
Each time I restart my wsl2 ubuntu 20.04 all snaps are broken , What s the fix actually ? thanks
Hi, I was able to make systemd to start with the following corrections:
Problem 1: after installation daemonize is installed in /usr/bin/daemonize Correction: file: /usr/sbin/enter-systemd-namespace ... at line 10 /usr/sbin/daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target correct to: /usr/bin/daemonize ...
Problem 2 error: "command /usr/sbin/enter-systemd-namespace not found" Correction: file: /usr/sbin/enter-systemd-namespace make executable sudo chmod +x /usr/sbin/enter-systemd-namespace
Ubuntu 18.04 via wsl 2
I ran into this issue and solved it by uninstalling daemonize. Reinstalling
sudo apt install daemonize
. Exiting wsl. Re-enter wsl. And made sure thedaemonize
command worked.
I love you man :D
Looks like daemonize wasn't found for some reason.
You should be able to log into WSL by typing "wsl -u root" in cmd or powershell. Check if daemonize is installed by typing "which daemonize". I assume you'll have no output (I have "/usr/bin/daemonize" for example). If you do have some output, please post it in a reply. You can either install daemonize or disable the startup script.
To install daemonize type: "sudo apt-get install daemonize" Do note however, that it's quite likely that the other things the script tried to install failed. You can run the script again in that case. Remember to sudo it.
If you want to disable the systemd start script, do the following: Enter in "nano /etc/bash.bashrc" Put a # on the start of the line that says "source /usr/sbin/start-systemd-namespace" To enable the systemd start script again, simply remove the newly added #
It works for me , thank you very much.
Thanks a lot! I thought i was going to reinstall the whole distro.
Looks like daemonize wasn't found for some reason.
You should be able to log into WSL by typing "wsl -u root" in cmd or powershell. Check if daemonize is installed by typing "which daemonize". I assume you'll have no output (I have "/usr/bin/daemonize" for example). If you do have some output, please post it in a reply. You can either install daemonize or disable the startup script.
To install daemonize type: "sudo apt-get install daemonize" Do note however, that it's quite likely that the other things the script tried to install failed. You can run the script again in that case. Remember to sudo it.
If you want to disable the systemd start script, do the following: Enter in "nano /etc/bash.bashrc" Put a # on the start of the line that says "source /usr/sbin/start-systemd-namespace" To enable the systemd start script again, simply remove the newly added #
it saved me finally
I using wsl2+ubuntu22.04. I also meet this problem and can not solve this with followed solutions:
sudo apt install daemonize
and
source /usr/sbin/start-systemd-namespace
because when i enter the wsl with
wsl -u root
and operate the following commands, the wsl2 feedback to me:
-sh: apt: not found
can't open '/usr/sbin/start-systemd-namespace': No such file or directory
and I enter the '/usr/bin', gauss what? there is no 'apt' inside it!!! what the hell !
ohhh! I know everything! I enter the wsl belong to docker!
so firstly, i just close the wsl by wsl.exe -t Ubuntu-20.04
and then open wsl by wsl -u root
now it works
I use WSL2 + Ubuntu20.04. Solve the error "Cannot execute daemonize to start systemd." like this:
wsl -u root
enters the shell, then solve it by installing "apt-get install daemonize".
This worked for me but only after i logged back in as usr and not logged in as root, which i found odd, but for what i'm doing right now i don't care.. just trying to get K3s installed for some fun with ansible/podman and automating custom execution environments. Thank you y8gao!!
try to comment source /etc/bash.bashrc. Found the file is empty.
Try to
sudo apt install daemonize
Any one encounter this ?
This script broke my WSL2 Ubuntnu 20.04 environment!