WSL Redis encountered System has not been booted with systemd as init system (PID 1). Can't operate [closed]
Asked Answered
S

9

310

I'm trying to follow the Redis installation process that was discuss in this article of digital ocean, for in WSL(Windows Sub-System for Linux). The Ubuntu version installed is Ubuntu 18.04.

Everything in redis installation is fine but when I tried to run this sudo systemctl start redis I got this message.

System has not been booted with systemd as init system (PID 1). Can't operate.

Any Idea on what should I do with that?

Sherlynsherm answered 6/9, 2018 at 5:46 Comment(1)
Follow this method github.com/Microsoft/WSL/issues/365Orozco
H
475

Instead, use: sudo service redis-server start

I had the same problem, stopping/starting other services from within Ubuntu on WSL. This worked, where systemctl did not.

And one could reasonably wonder, "how would you know that the service name was 'redis-server'?" You can see them using service --status-all

Heterochromatin answered 21/10, 2018 at 20:43 Comment(5)
Yes.. I been using this too since I wrote the problem, that one from the comment also has a comment that helpSherlynsherm
Great, thank you very much. This work for most all services that have been install in WSL environment while we cannot use systemctl to start|stop|restart services.Protoxide
Given this is the highest rated answer it would have been nice to see a little more info what happens here. To my understanding service is an abstraction and can fall back to either init.d (sysv init) or systemd which as the question implied does not work. serverfault.com/questions/867322/…Eschalot
fraleone, since it was my answer, I'll try to address your concern. To be clear, the question was about an error trying to start Redis (on WSL specifically), where using the common start command documented elsewhere, systemctl start redis, was not working for the OP. It wasn't working for me, either. I found this alternative (redis-server start) and came here to offer it as an answer. I'm glad it's helped others. But I wasn't/am not in a position to explain "what happens here", or why it counters your expectations. Feel free to elaborate as you may find more, or perhaps others will.Heterochromatin
You can also call the needed commands from ".profile" already at boot up time, see the similar issue for docker “sudo systemctl enable docker” not available: Automatically run Docker at boot on WSL2 (using a “sysvinit” / “init” command or a workaround) which also explains in detail why you need to use "service" here instead of systemd.Certain
O
61

Instead of using

sudo systemctl start redis

use:

sudo /etc/init.d/redis start

as of right now we do not have systemd in WSL

Or sometime it might be redis-server, like:

>> sudo /etc/init.d/redis-server start
Starting redis-server: redis-server.

Just do a ls, like: ls /etc/init.d

Olson answered 10/4, 2020 at 20:12 Comment(4)
Do you know if it available on WLS 2 ?Reedbuck
From a quick search WSL2 is not booted with systemd. There is a workaround here though which I have not tested. github.com/microsoft/WSL/issues/994#issuecomment-502055417Olson
How I use that in a fedora / centos image.Sobriquet
sudo /etc/init.d/redis-server start fixed the problem after all other commands had failed. I am on WSL.Sheepdog
R
28

I had this problem running WSL 2

the solution was the command

 $ sudo dockerd

if after that you still have a problem with permission, run the command:

 $ sudo usermod -aG docker your-user
Royster answered 11/6, 2020 at 5:33 Comment(4)
you'd also have to start the distro. So I have 2 terminals one runs docker and the other one I use for my workLancer
You can use "sudo dockerd &" and you won't need 2 terminals.Pursuer
I get sudo: dockerd: command not foundRuthenic
Is there a solution, like that, for ssh?Columbary
P
17

I was trying to start Docker within ubuntu and WSL.

This worked for me,

sudo service docker start

Phebephedra answered 17/8, 2020 at 0:42 Comment(0)
C
11

If you are using Docker, you may try an image that has Ubuntu with System D already active with this command:

docker run -d --name redis --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro jrei/systemd-ubuntu:18.04

Then you just need to run:

docker exec -it redis /bin/bash

and there you can just install Redis, start it, restart it or whatever you need.

Cemetery answered 11/4, 2020 at 18:26 Comment(2)
Docker won't run in WSL.Dwt
@Aditya It does in WLS 2Reedbuck
W
6

Total newbie here - after trying most of the above suggestions, the command that worked for me was sudo service apache2 --full-restart and the web server started up.

Maybe the error came up because I have been following lots of setup instructions without a reboot/restart. I'm working on Ubuntu 20.04 in WSL2 using Apache2 Debian.

Wilkie answered 5/3, 2021 at 2:16 Comment(0)
T
5

For WSL2, I had to install cgroupfs-mount, than start the daemon, as described here:

sudo apt-get install cgroupfs-mount
sudo cgroupfs-mount
sudo service docker start
Thevenot answered 23/1, 2021 at 0:28 Comment(0)
B
3

This worked for me (using WSL)

sudo /etc/init.d/redis start

(for any other service, check the init.d folder for filenames)

Blues answered 31/7, 2020 at 20:37 Comment(0)
D
2

use this command for run every service just write name service for example :

for xrdp :

sudo /etc/init.d/xrdp start

for redis :

sudo /etc/init.d/redis start

(for any other service, check the init.d folder for filenames)

Decane answered 9/8, 2020 at 13:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.