CentWSL icon indicating copy to clipboard operation
CentWSL copied to clipboard

Feature request: systemd for CentOS 8 in CentWSL

Open datdinhquoc opened this issue 4 years ago • 10 comments

I'm on WSL2, which supports 'systemd', however, after running CentOS8.exe to install CentOS 8, I found out that there's no systemd.

$ sudo dnf install nginx -y
$ sudo systemctl start nginx
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

May CentWSL (CentOS 8) come with systemd please?

datdinhquoc avatar May 31 '20 04:05 datdinhquoc

This is hard to achieve on WSL. If you are following the same discussions on Microsoft/WSL repo you will get more technical details on why. Alas, it was achieved by a community member to run systemd in a bottle but I can't recall the exact method. I believe you can find it with a quick search in github.

mahmoudajawad avatar May 31 '20 07:05 mahmoudajawad

This is hard to achieve on WSL.

it was promoted every on the internet that wsl2 would support systemd. i'm on wsl2 now, but it's not working :(

datdinhquoc avatar May 31 '20 21:05 datdinhquoc

@yuk7 we can use this solution as a workaround : https://superuser.com/a/1556780 it works for me.

vaska94 avatar Jun 11 '20 19:06 vaska94

i do not working systemctl error message

[root@slimes1 ~]# sudo systemctl start nginx ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ERROR:systemctl: Oops, 1 unsupported directory settings. You need to create those before using the service. ERROR:systemctl: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

choyongsun avatar Aug 07 '20 08:08 choyongsun

Ubuntu 20.04 someway achieved support in systemd although in the very strange way: when Ubuntu 20.04 is started from Ubuntu-2004.exe it systemd starts with PID 1 and supports all necessary features. If any other method is used like wsl -d Ubuntu2004, Open tab in Windows terminal, etc. it starts from init. This is not most graceful solution but reflects 2 different scenario: full Linux bootstrap and simple creation of pipe with Linux Ty. Maybe, it is not so extremally hard? The main issue that full bootstrap takes some time but Ubuntu prints message that user has to be patient until systemd is settled. Nobody expects that Linux reboot and bash invocation takes the same time.

PavelSosin-320 avatar Nov 03 '20 09:11 PavelSosin-320

So, out of my understanding here. I am using CentOS from this repository. Appears to function well and even install the applications and services that I want. However, it does not seem to have systemctl functionality. However, I am trying to run a LAMP stack. So, do I need to create /etc/init.d scripts for the services that I need manually?

Thanks. New to WSL2 and CentOS on it. But old Unix user and trying to get this to function the best possible practices. Will use for application development purposes.

Thanks, Tamer

tziady avatar Nov 06 '20 16:11 tziady

I recommend use subsystemctl for WSL2. This makes systemd work with PID1 in new namespace.

https://github.com/sorah/subsystemctl

yuk7 avatar Nov 06 '20 16:11 yuk7

Thank you for the info. I have installed it and having some trouble; but likely wrong paths or something. Will figure out.

Cheers, T

tziady avatar Nov 07 '20 03:11 tziady

@tziady You can also consider this: https://github.com/gdraheim/docker-systemctl-replacement

It's a Python program that tries to emulate the behavior of systemctl (the master branch also includes some edits to emulate journalctl).

EDIT: pasted the wrong link

cardin avatar Dec 13 '20 18:12 cardin

@yuk7 I use your Centos 8.1 installed from GitHub upgraded to 8.2 because Microsoft Store Centos8 doesn't work at all. Who choose CentOS or Fedora wants RedHat stuff to work. but it uses systemd directly. I mentioned that Ubuntu 20.04 achieved full systemd functionality when it is run from its own Windows Ubuntu20.04 LTS exe bootstrap program and maintains scores of units. The Ubuntu 20.04 looks like OEM installation - it has oem files in the /boot folder. Maybe, this is the secret? Meanwhile, I finally succeeded to upgrade my WSL Kernel to 5.4.

PavelSosin-320 avatar Dec 14 '20 07:12 PavelSosin-320