启用WSL,用管理员打开powershell输入
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
启用虚拟平台,用管理员打开powershell输入
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
安装WSL2内核,下载地址:
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
将WSL2设置为默认版本,用管理员打开powershell输入
wsl --set-default-version 2
安装LxRunOffline,下载地址:
https://github.com/DDoSolitary/LxRunOffline/releases
下载Archlinux,下载地址:
# 下载bootstrap版本的,如:archlinux-bootstrap-2021.10.01-x86_64.tar.gzhttps://mirrors.tuna.tsinghua.edu.cn/archlinux/iso/latest/
安装archlinux到WSL
usage:LxRunOffline i -n <自定义名称> -f <Arch镜像位置> -d <安装系统的位置> -r root.x86_64eg:LxRunOffline i -n archlinux -f archlinux-bootstrap-2021.10.01-x86_64.tar.gz -d C:\wsl\archlinux -r root.x86_64
将wsl升级到wsl2
usage:wsl --set-version <名称> 2eg:wsl --set-version archlinux 2
进入系统,编辑pacman.conf和mirrolist配置文件
wsl -d archlinuxrm /etc/resolv.confexitwsl --shutdown archlinuxwsl -d archlinuxcd /etc/explorer.exe .用windows的文件管理器打开/etc目录,然后找到pacman.conf,在这个文件最后加入[archlinuxcn]Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch进入下一级目录pacman.d,编辑里面的mirrolist文件,将China的源注释去掉(选择部分即可)pacman -Syypacman-key --initpacman-key --populatepacman -S archlinuxcn-keyringpacman -S base base-devel vim git wget
设置root密码
passwd
新建普通用户
useradd -m -G wheel -s /bin/bash <用户名>passwd <用户名># 将文件/etc/sudoers中的wheel ALL=(ALL) ALL那一行前面的注释去掉vim /etc/sudoers
设置使用普通用户登录Archlinux
# 查看当前用户idid -u <用户名># 退出archlinuxexit在powershell中执行lxrunoffline su -n <你的arch名字> -v <账户id>
中文乱码
# 安装字体pacman -S wqy-zenhei ttf-fireflysung打开sudo vim /etc/locale.gen将en_US.UTF-8注释去掉将zh_CN.UTF-8注释去掉生效sudo locale-gen
解决wsl下win的文件系统挂载过来后全是777权限的问题
win文件挂载权限
创建/etc/wsl.conf,写入如下内容
[automount]enabled = trueroot = /mnt/options = "metadata,umask=22,fmask=11"mountFsTab = true
修改完成后,需要重启WSL使设置生效
wsl -t <使用发行版的名称>wsl -l -v #确定是否已经停止
mkdir文件夹权限
在.bashrc中加入以下内容
#Fix mkdir command has wrong permissionsif grep -q Microsoft /proc/version; thenif [ "$(umask)" == '0000' ]; thenumask 0022fifi
