WSL2 现已支持 Systemd

2022-09-22 12:36:06 +08:00
 charlieethan

根据微软的官方博客: https://devblogs.microsoft.com/commandline/systemd-support-is-now-available-in-wsl ,在最新版的 WSL2 中已经支持了 Systemd ,升级的方法如下(以 Windows 商店内的 Ubuntu 发行版为例,Windows 版本为 Windows 11 22H2 ):

如果第一行显示为 WSL version: 0.67.6.0 ,则已升级到支持 systemd 的版本

sudo cat > /etc/wsl.conf <<EOF
[boot]
systemd=true
EOF
10985 次点击
所在节点    Windows
58 条回复
brucmao
2022-09-22 12:51:56 +08:00
升级失败
❯ wsl.exe --update
正在检查更新。
The system cannot find the file specified.
Error code: Wsl/UpdatePackage/ERROR_FILE_NOT_FOUND
codehz
2022-09-22 12:59:07 +08:00
wsl 也要商店安装的版本,于是 win10 用不了了)
brucmao
2022-09-22 13:00:15 +08:00
我用的商店里 Windows Subsystem for Linux Preview ,版本才 0.66.2.0
charlieethan
2022-09-22 13:06:04 +08:00
@brucmao 没遇到过,建议直接去 https://github.com/microsoft/WSL/releases/tag/0.67.6 下载 msixbundle 安装
BeautifulSoap
2022-09-22 13:08:09 +08:00
@brucmao 我也一样的问题,结果看到了: "This version of WSL is now available in the Microsoft Store to users on Windows Insiders build for initial testing" 。干,不光要 win11 ,还要装 store 版本,还必须系统是 insider 。

不过文档也说了可以从 WSL release page 安装还算好,但手动安装的话今后更新估计麻烦
Hylenbin
2022-09-22 13:08:39 +08:00
看了,必须 win11 ,很讨厌圆角,还是坚守 win10
momocraft
2022-09-22 13:09:14 +08:00
用这个可以在 wsl VM 里跑 dockerd 吗
learningman
2022-09-22 13:09:51 +08:00
PS C:\Users\u> wsl --update
正在检查更新。
已安装最新版本的适用于 Linux 的 Windows 子系统。
PS C:\Users\u> wsl --version
WSL 版本:0.66.2.0
内核版本:5.15.57.1
WSLg 版本:1.0.42
MSRDC 版本:1.2.3401
Direct3D 版本:1.606.4
DXCore 版本:10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows 版本:10.0.22000.978
kindjeff
2022-09-22 13:16:18 +08:00
22H2 Preview 升级成功

不过我最需要 systemd 的应用 docker 已经用 podman 替代了,现在还真没有东西要用 systemd
DonkeyBenjamin
2022-09-22 13:19:31 +08:00
买了 systemd 作者算是值了?
不过还是不想用 win, 广告,ebpf 不支持,ssh 和 syncthing 配置方案麻烦,部份软件需要特殊配置。。。
hahastudio
2022-09-22 13:19:50 +08:00
@kindjeff docker 用 systemd 么?我自己装 docker service 跑着没感觉出什么问题
kindjeff
2022-09-22 13:26:22 +08:00
@hahastudio #11 不用 systemd 如何自动启动 daemon 呢
cyaki
2022-09-22 13:31:03 +08:00
@kindjeff 可以用 systemd + Podman
andyskaura
2022-09-22 13:40:34 +08:00
wsl2 监听局域网 ip 有没有什么好点的办法
oldshensheep
2022-09-22 13:42:03 +08:00
成功了,用的 ArchLinux 。

➜ ~ systemctl list-unit-files --type=service | grep docker
docker.service disabled disabled
Nitroethane
2022-09-22 13:46:09 +08:00
@DonkeyBenjamin #10 了解下 epbf-for-windows ( https://github.com/microsoft/ebpf-for-windows ),不过我不用 windows ,没试过,不知道效果咋样
DonkeyBenjamin
2022-09-22 13:49:08 +08:00
@Nitroethane 感谢指出,这个当初看过一点,但是项目还处于早期阶段,懒得自己去踩坑。目前很多基于 ebpf 的工具和项目没有提到支持 wsl2 和 ebpf for windows.
dinghmcn
2022-09-22 13:59:06 +08:00
@oldshensheep #15 成功了,同用的 ArchLinux 。
hahastudio
2022-09-22 14:06:49 +08:00
@kindjeff
我在 profile 里加了 service docker start
wolfie
2022-09-22 14:31:10 +08:00
@kindjeff
nohup dockerd &

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/882117

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX