WSL: systemctl doesn't work
I followed the instructions from DigitalOcean to install the LAMP stack on WSL, but I found that I cannot use systemctl to control the server programs (including but not limited to Apache and Nginx).
After installing Apache, I tried using systemctl to start Apache server but it did not work.
$ sudo systemctl start apache2
Failed to connect to bus: No such file or directory
PS. systemctl list-units also outputs the same error.
Though I can still start it with sudo service apache2 start or sudo /etc/init.d/apache2 start, I’m curious about if systemctl will be supported in Ubuntu on Windows in the near future? Thanks.
Version: Windows 10 Insider Preview Build 15002
About this issue
- Original URL
- State: open
- Created 10 years ago
- Reactions: 32
- Comments: 23
You may want to try using Upstart to run and manage third-party services Also, Follow me on linkedIn , I am going to publish an article very soon on WSL and running opensource project with WSL. Hopefully, it should give you a comprehensive guide while you start working with WSL
Like @khanguslee says above, you can work around the issues with
systemctlby replacing it with @gdraheim’s script. just do the following (assumes/usr/bin/systemctl) :You might be able to try replacing
/usr/bin/systemctlwith https://github.com/gdraheim/docker-systemctl-replacement/blob/master/files/docker/systemctl.pyStarting dbus (
sudo service dbus start) will get you a little further but in short nosystemdnosystemctl.#994.
I hope WSL 2 auto start linux, and auto start systemd , as a real linux Operating system. I want to let Database to auto start .
Hi, is there any official information about this https://bugs.launchpad.net/ubuntu/+source/wsl-setup/+bug/1962556? I couldn’t find how to activate experimental support of systemd on Ubuntu 22.04 which is now available for WSL 2.
I had to curl it down into my current directory and then sudo move it to the bin directory. I also didn’t start with one to begin with.
https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl/
I have been using distroid from few months works like charm to install on WSL2:
curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"chmod +x install.shsudo ./install.sh install/opt/distrod/bin/distrod enableor you can even do
/opt/distrod/bin/distrod enable --start-on-windows-bootnot sure if the last one is even available with the systems in wsl by Microsoft but if you cant upgrade or want to use it asap… this works perfectly.
I’m also interested in learning about this.
servicecallssystemctlin openSUSE, so we are back to square 1.Not sure. All of that legacy-init-transition-related stuff is being sorted out by the distros. Upstart used to map the “service” command to upstart, which managed the init scripts. Since the switch to systemd, Ubuntu has replaced upstart with a mix of “native unit files” (i.e. little .ini-looking files that instruct systemd how to launch daemons) and classic-style-init-init scripts, which are controlled through the systemd-sysvcompat module of systemd.
For daemons of the second type, you can manually run the init.d scripts as before, not sure how they have aliases the old upstart commands. But otoh, for daemons controlled with native unit files, you will have to manually start the actual daemon executables by themselves or with your own custom ‘init’ scripts (depending on the daemon, this could be easy or could be hard).
It seems like some of the basic building blocks for using systemd for init are being added into WSL. The team has quietly added things like the cgroups fs, and the NT kernel has apparently always supported namespaces, two key features used by systemd. Ben Hillis also mentioned in his interop video and blogpost that Microsoft’s init process (which sets up quite a bit of the magic) could probably be moved out of pid 1 and into a non-init role in the future.
I’ll let you speculate about what that could mean. The devs here are very sphinx-like about future plans until they have been announced officially or at least until someone like Alex Ionescu has reverse engineered the surprise to the point where it is public knowledge. 🙃
Systemd isn’t running and won’t run without major changes tothe initialization process.
Edit: @therealkenc lol, Systemd in Ubuntu is still trying to use kdbus?