ubuntu-wsl2-systemd-script icon indicating copy to clipboard operation
ubuntu-wsl2-systemd-script copied to clipboard

Endless startup loop

Open Galmeno opened this issue 5 years ago • 22 comments

Running this made ubuntu endlessly loop with echo pausing one second to let ubuntu start.

Galmeno avatar Jul 26 '20 18:07 Galmeno

You're right, there appears to be a bug. I'll fix this in my branch at diddledan/ubuntu-wsl2-systemd-script and file a PR shortly.

lucyllewy avatar Jul 26 '20 18:07 lucyllewy

Maybe I'm wrong, I can't replicate this....

lucyllewy avatar Jul 26 '20 18:07 lucyllewy

I flushed it, but I had other configs. Might depend on user running it.

Galmeno avatar Jul 27 '20 18:07 Galmeno

fresh install of ubuntu 20.04 on wsl2, get's the endless loop for me as well

sleep: cannot read realtime clock: Invalid argument
Sleeping for 1 second to let systemd settle
sleep: cannot read realtime clock: Invalid argument
Sleeping for 1 second to let systemd settle
sleep: cannot read realtime clock: Invalid argument

adrianlyjak avatar Aug 08 '20 15:08 adrianlyjak

This is not closed.

Galmeno avatar Aug 13 '20 09:08 Galmeno

Same issue here. Fresh ubuntu 20 (wsl2). I tried the same installation on ubuntu 18, I don't get any loop - instead, there is an error and the terminal automatically closes.

I've mentioned it here: https://github.com/DamionGans/ubuntu-wsl2-systemd-script/issues/37#issuecomment-683871548

pavitrakumar78 avatar Aug 31 '20 16:08 pavitrakumar78

Just ran the script on Ubuntu-20.04 and I'm seeing the loop as well. I installed ubuntu-desktop and gnome before running the script. I will try uninstalling and running the script before installing anything in hopes that this fixes it. I'll return with the results of the retry.

MeachamusPrime avatar Oct 26 '20 18:10 MeachamusPrime

No luck. Fresh 20.04-LTS install -> "apt update" -> "apt upgrade" -> "sudo bash ubuntu-wsl2-systemd-script.sh" leads to infinite "Sleeping for 1 second to let systemd settle" loop.

MeachamusPrime avatar Oct 26 '20 19:10 MeachamusPrime

Any progress on this one? I'm still stuck on the endless systemd loop.

vasbinde avatar Nov 04 '20 02:11 vasbinde

Got past the endless loop - missed the fact that Windows installs WSL1 by default and that I need to manually update it to WSL2. Now that this is complete, I'm banging my head against the wall of trying to get a GNOME session to start.

vasbinde avatar Nov 04 '20 07:11 vasbinde

Just to say it happens here as well. Brand new laptop, freshly installed "Ubuntu" package from the app store and copied the lines on the Readme. but more like @MeachamusPrime , I don't have any other output in between.

buggtb avatar Nov 13 '20 21:11 buggtb

same here, endless loop Ubuntu 20.04-LTS

bonepl avatar Feb 18 '21 11:02 bonepl

Same here. WSL2, Ubuntu 18.04. It seems bash.bashrc is being called twice. I put a log statement in bash.bashrc before calling start-systemd-namespace

# Start or enter a PID namespace in WSL2
echo "bash.bashrc: Calling /usr/sbin/start-systemd-namespace"
source /usr/sbin/start-systemd-namespace

and the output is:

C:\Users\Zardosht> wsl

bash.bashrc: Calling /usr/sbin/start-systemd-namespace
Sleeping for 1 second to let systemd settle
Last login: Sat Mar  6 19:32:14 CET 2021 on pts/0
Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 5.4.72-microsoft-standard-WSL2 x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sat Mar  6 19:39:30 CET 2021

  System load:  0.02               Processes:           10
  Usage of /:   4.5% of 250.98GB   Users logged in:     0
  Memory usage: 0%                 IP address for eth0: 172.21.65.172
  Swap usage:   0%


6 packages can be updated.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


bash.bashrc: Calling /usr/sbin/start-systemd-namespace

zardosht avatar Mar 06 '21 18:03 zardosht

I got an infinite loop too (with Ubuntu 20.04 LTS)

Forever-CodingNoob avatar Apr 09 '21 16:04 Forever-CodingNoob

Same here ubuntu 20.04, using wsl2 (end goal to run gnome desktop)

nsalit avatar Apr 23 '21 09:04 nsalit

Same here using WSL2 Ubuntu-20.04

lin71008 avatar Apr 25 '21 01:04 lin71008

This comment should help solve this issue.

How about I suggest we go ahead and we all first before using this script follow the instructions first in the comment created by @zardosht before we do anything else.

williamwilkerson2 avatar May 24 '21 16:05 williamwilkerson2

Issue still persists with Ubuntu 20.04 WSL2 as of August 2021. Never ending loop of "Sleep for 1 second to let systemd settle." Nothing to do but uninstall Ubuntu, reinstall, and don't try running this script again...

Not sure what config files I should try making changes to in order to revert back or fix the issue.

jrodd96 avatar Aug 10 '21 07:08 jrodd96

Hi! I had the same problem and then ended up completely abandoning this solution. Then I stumbled upon https://forum.snapcraft.io/t/running-snaps-on-wsl2-insiders-only-for-now/13033 which almost worked out of the box. A comment on this Reddit thread (comment by inspectulation) addresses some of the problems when trying to run this on Ubuntu 20.04: https://www.reddit.com/r/bashonubuntuonwindows/comments/gc8lle/usrsbindaemonize_no_such_file_or_directory/

After updating the scripts with the recommendations from the Reddit Thread, it worked! I created a new repo and put all of the scripts and documentation there: https://github.com/andraspatka/k3s-wsl The first part of the README.md explains how to set up systemd. You can ignore the part about k3s, that's not relevant to this topic.

Please note, that my repo is more of a documentation and doesn't (yet?) include any fancy bash script which automates the whole thing. But at least it works :)

The output of ps -efw looks like this:

UID          PID    PPID  C STIME TTY          TIME CMD
root           1       0  4 23:45 ?        00:00:00 /lib/systemd/systemd --system-unit=basic.target
root           2       0  0 23:45 pts/0    00:00:00 /bin/login -p -f
root          58       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-journald
root          82       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          83      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          84      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
systemd+      85       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-networkd
root          86      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          87      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          88      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          89      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          90      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          91      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          92      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          93      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          94      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          95      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          96      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          97      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          98      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root          99      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root         100      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root         101      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root         102      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
root         103      82  0 23:45 ?        00:00:00 /lib/systemd/systemd-udevd
andras       324       2  1 23:45 pts/0    00:00:00 -bash
systemd+     349       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-resolved
systemd+     350       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-timesyncd
root         354       1  0 23:45 ?        00:00:00 /usr/lib/accountsservice/accounts-daemon
message+     355       1  0 23:45 ?        00:00:00 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root         356       1  0 23:45 ?        00:00:00 (savelog)
root         358       1  0 23:45 ?        00:00:00 /usr/sbin/irqbalance --foreground
root         359       1  1 23:45 ?        00:00:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
syslog       360       1  0 23:45 ?        00:00:00 /usr/sbin/rsyslogd -n -iNONE
root         361       1 16 23:45 ?        00:00:00 /usr/lib/snapd/snapd
root         362       1  1 23:45 ?        00:00:00 /lib/systemd/systemd-logind
root         363       1  1 23:45 ?        00:00:00 /usr/lib/udisks2/udisksd
root         379       1  0 23:45 ?        00:00:00 /usr/sbin/cron -f
daemon       388       1  0 23:45 ?        00:00:00 /usr/sbin/atd -f
root         404       1  0 23:45 ?        00:00:00 (agetty)
root         406       1 55 23:45 ?        00:00:01 /usr/local/bin/k3s server
root         421       1  0 23:45 ?        00:00:00 /usr/lib/policykit-1/polkitd --no-debug
root         422       1  1 23:45 ?        00:00:00 /usr/bin/python3 /usr/share/unattended-upgrades/unattended-upgrade-shutdown --wait-for-signal
root         541     406 23 23:45 ?        00:00:00 containerd
andras       551     324  0 23:45 pts/0    00:00:00 ps -efw

Please let me know if this fixes the problem for you guys :)

andraspatka avatar Sep 23 '21 20:09 andraspatka

Also, if your Ubuntu 20.04 in WSL is crashing, you can just simply delete the /usr/sbin/start-systemd-namespace and /usr/sbin/enter-systemd-namespace scripts. After that it should start as expected. I used this method a few times until I got the scripts right for Ubuntu 20.04 You can access the Ubuntu file system from Windows under \\wsl$ (enter it into Windows Explorer) or if that doesn't work then under C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState Source: https://askubuntu.com/questions/759880/where-is-the-ubuntu-file-system-root-directory-in-windows-subsystem-for-linux-an

andraspatka avatar Sep 23 '21 20:09 andraspatka

I will check out your implementation @andraspatka - thx for sharing your approach (especially k3s intrigues me). Just to add to your comment:

While cd C:\Users\<username>\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\usr\sbin works via CMD.exe - it did not under Powershell on a fresh install of Windows 10 Pro Stable/19044.1237 21H2.

The UNC \\wsl$ did neither resolve in Explorer.exe, nor in Powershell.

It was possible to del start-systemd-namespace and del enter-systemd-namespace to get rid of the loop, which might help the one or the other who did already put data into such install to recover it. Nonetheless (just for curiosity sake) i tried to apply your steps in https://github.com/andraspatka/k3s-wsl on top of that, but it didn't work out, a reset of Ubuntu via app-settings for Ubuntu in the System-setting was necessary (just a note - for those that like me like to work through the mudhole - that it was not succesful, lol).

Will try your tutorial now on a fresh WSL2 Ubuntu 20.04.

EDIT: While it was successful, it started to spit a proc/xx/ns-error after installing Docker Desktop for Windows. I cam e across a similar result before together with the Endless startup loop and could solve it only by using a custom kernel. If anyone has an idea or insights into the why, i would like to be enlightened - it is over my head, i gladly admit.

claudiusraphael avatar Oct 12 '21 08:10 claudiusraphael

20.04 LTS, same issue 'Sleeping for 1 second to let systemd settle' . I have no choice but to uninstall and reinstall it."/(ㄒoㄒ)/~~

ifndf avatar Jul 06 '23 10:07 ifndf