Problem entry · machine-readable · 编码代理与终端

WSL 里 systemctl 报 System has not been booted with systemd / 服务起不来

本页嵌入 #trove-entity JSON(本条目全量结构化数据);全库数据见 /agent/trove.json。

元数据

idwsl-systemd-not-running收录2026-08-31
问题域编码代理与终端主题分组容器与 WSL
适用工具wsl · 外部工具

症状

```

$ systemctl status docker

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

Failed to connect to bus: Host is down

```

特征:`systemctl` 任何子命令都报 booted 错误;`ps -p 1` 不是 systemd;wsl.conf 没有 `[boot] systemd=true` 或改完没重启。

原因

WSL2 默认 PID1 是 WSL 自带 init,不是 systemd;systemctl 需要 systemd 作 PID1。`/etc/wsl.conf [boot] systemd=true` 启用 systemd 后必须重启发行版才重新初始化。

解法

1. `ps -p 1 -o comm=` 确认 PID1;

2. wsl.conf 加 `[boot] systemd=true`;

3. Windows 侧 `wsl --terminate <发行版名>` 重启;

4. 验证 `ps -p 1 -o comm=` = systemd 后重跑原命令。

验证证据

- 机制核对:微软官方文档(learn.microsoft.com/windows/wsl/systemd);

- 本机对照(2026-08-31):定制预构建版 PID1 = systemd、`systemctl is-system-running` = degraded、wsl.conf 已有 `[boot] systemd=true`——健康路径验证;未做禁用复现(避免影响工作环境);

- 实测复现日志(2026-08-31)

来源与证据

素材来源:微软官方文档机制核对 + 本机对照(2026-08-31)

验证证据:Evidence details kept locally (2026-08-31)