724

Windows10安装Centos8子系统并开启systemd

检查系统知否支持WSL2

若要更新到 WSL 2,需要 Windows 10 或 Windows 11。

  • 对于 x64 系统:版本 1903 或更高版本,内部版本为 18362 或更高版本。
  • 对于 ARM64 系统:版本 2004 或更高版本,内部版本为 19041 或更高版本。

开启Hyper-V、虚拟机平台、子系统

前提:BOIS开启了CPU虚拟化支持

打开windows设置 -> 应用和功能 -> 可选功能 -> 更多Windows功能

Hyper-V虚拟机平台适用于Linux的Windows 子系统选项全部勾上

启用适用于 Linux 的 Windows 子系统

开始菜单 -> PowerShell -> 单击右键 -> 以管理员身份运行

然后输入以下命令:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
1661

Windows10 git-bash 安装 zsh 和 oh_my_zsh 或 prezto

安装git-bash for windows

https://gitforwindows.org/
下载安装一直下一步即可

下载zsh

https://dotatong.cn/tools/zsh-5.8-3-x86_64.pkg.tar

下载后解压到 Git 安装的根目录,相当于对git bash做一个补充包。

安装oh_my_zsh

安装oh_my_zsh(MacOS也可使用该步骤安装oh_my_zsh)

sh -c "$(curl -fsSL https://dotatong.cn/tools/oh_my_zsh.sh)"
2694

Win10安装MSYS2和zsh

安装MSYS2

以下地址下载安装
https://www.msys2.org/

http://repo.msys2.org/distrib/

修改home目录

修改home目录为Windows home目录

vim /etc/nsswitch.conf

db_home: windows

安装zsh

pacman -S zsh
293

docker访问宿主机

host模式,容器内共享宿主机的网络

--network host
8558

Win10子系统Alpine服务管理工具openrc

场景

win10安装alpine作为linux子系统

注意

安装完成子系统后,提示输入用户名时,如果只想使用root账号,直接按Ctrl+C终止

可选初始配置

#!/bin/bash

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
apk update
apk add git nginx tzdata openssh-client openssl curl zsh
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
echo "Asia/Shanghai" > /etc/timezone
sed -i 's/ash/zsh/g' /etc/passwd
sh -c "$(curl -fsSL https://dotatong.cn/tools/oh_my_zsh.sh)"
sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="ys"/g' /root/.zshrc

服务管理工具

类似于centos的systemd,alpine使用openrc来管理服务