발생할 때마다 적는 에러노트

[Ubuntu Linux/WSL] System has not been booted with systemd as init system (PID 1). Can't operate.

archive-er 2024. 8. 6. 16:26

mysql을 시작시켜달라

Ubuntu 20.04, 정확히는 WSL에 mysql을 설치하고 시작하려니 이난리가 났다

 

우선 결론부터 적자면

 

In Ubuntu

sudo apt update
sudo apt install -y git
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh --force

 

 

In cmd

wsl --shutdown

 

 

이제부터 과정 시작

 

 

1. 시도 1 (실패)

 

https://parkkingcar.tistory.com/96

 

[Linux] systemctl 명령 에러 System has not been booted with systemd as init system (PID 1).

WSL을 사용 중 systemd 환경이 아니라는 오류가 발생합니다. $ sudo systemctl status System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down 원인은 WSL은 루트 시스템 프

parkkingcar.tistory.com

구글링해보니 WSL의 루트 시스템 프로세스가 systemd이 아닌 init이고

근데 systemctl으로 서비스 실행하려 하니 "??? 내가 그걸 어케함"이라고 하는 상태인것 같다

 

해당 링크에서 말하는 해결 방법은 /etc/wsl.conf 파일에 (없으면 생성)

[boot]
systemd=true

 

를 적으면 된다는데

 

됐다면 이 게시글이 올라올 일은 없었을 것이다

 

 

2. 시도 2 (실패)

 

새로운 해결 방법을 위해 다시 한 번 구글으로 뛰어든 결과

https://www.sysnet.pe.kr/2/0/13104?pageno=16#google_vignette

 

Linux: 51. WSL - init에서 systemd로 전환하는 방법

Linux: 51. WSL - init에서 systemd로 전환하는 방법 [링크 복사], [링크+제목 복사], 조회: 12903 글쓴 사람 정성태 (techsharer at outlook.com) 홈페이지 첨부 파일 부모글 보이기/감추기 (연관된 글이 1개 있습니

www.sysnet.pe.kr

이걸 찾아서 해봄

 

구체적으로는

wget --content-disposition "https://github.com/arkane-systems/genie/releases/download/v2.4/systemd-genie_2.4_amd64.deb"
apt-get install -y daemonize systemd-container
dpkg -i systemd-genie_2.4_amd64.deb

 

를 해봄

 

허허허허허허

 

시발진짜 소리 나왔다가

뭔가 나왔으니 일단 진정

 

따라해보니 또 뭔가 성공적으로 설치되긴 했다

 

 

이제 다시 pstree로 프로세스 트리를 확인해볼차례였고

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

3. 시도 3 (성공!)

다시한번 구글링을 진행했고 또다른 친구를 발견했다

https://superuser.com/questions/1509703/connection-reset-by-peer-on-systemctl-as-root

 

Connection reset by peer on systemctl as root

I've setup WSL 2 (Ubuntu) and I installed systemd (and systemd-sysv) there. After that, I ran: sudo mkdir -p /run/dbus sudo dbus-daemon --system sudo daemonize /usr/bin/unshare --fork --pid --moun...

superuser.com

 

아예 wsl의 루트 시스템을 systemd로 바꾸는 git 레포에서 직접 스크립트를 내려받아 실행하는거였고 아무리 생각해도 이게 정말로 마지막 보루였으며

sudo apt update
sudo apt install -y git
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh

 

이걸 했다

 

ㅋㅋㅋㅋㅋㅋㅋㅋㅋ아제발진짜요ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

 

sudo apt update
sudo apt install -y git
git clone https://github.com/DamionGans/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
# bash ubuntu-wsl2-systemd-script.sh
bash ubuntu-wsl2-systemd-script.sh --force

어 강제로 시킬거야

 

성공한 후 cmd에서

wsl --shutdown

 

으로 셧다운 후 Ubuntu 재실행하고 나면

 

따란

 

드디어 성공!