WSL系统选择安装,centos


win环境安装Python 3 Python

# 如果你已经安装子系统,进入下载windows版本,然后在win安装
bash
wget https://www.python.org/ftp/python/3.7.1/python-3.7.1.exe
# win安装之后,配置python全局变量环境

下载项目WSL-Distribution-Switcher

git clone https://github.com/RoliSoft/WSL-Distribution-Switcher.git
# OR
wget https://github.com/RoliSoft/WSL-Distribution-Switcher/archive/master.zip

下载最子系统镜像

# 进入cmd
cd/d WSL-Distribution-Switcher
# 推荐使用生产环境的系统,我是centos
# 下载rootfs,最新last
python get-source.py centos
# 版本:https://hub.docker.com/_/centos/
python get-source.py centos:6.9
# 下载docker镜像/docker pull(这里不需要)
# python get-prebuilt.py kalilinux/kali-linux-docker

rootfs安装

# 直接下载安装
python install.py centos:6.9
# 指定刚刚下载的rootfs文件
python install.py rootfs_centos_sid.tar.xz

# This operation extracts the tarball into your home directory in WSL, then replaces the current rootfs with the new one.
# This means that broken rootfs installations can now be repaired to some extent, since the WSL does not have to be able to start beforehand.

钩子文件 python install.py同时执行的一个sh脚本,随rootfs文件安装之后执行,因为国内原因,可以把aliyun源写进去.

# 运行一个全局钩子文件,初始化系统
# It's possible to write hook scripts which are copied to WSL and run as root by the installer during the initial installation.
# The provided script supports Arch Linux, APT-based (such as Debian and Ubuntu) and RPM-based (such as Fedora and CentOS) distributions. For all other distributions, it will gracefully terminate.
# If you would like your user to be added directly to sudoers with NOPASSWD, send SUDONOPASSWD=1 as an environmental variable.
cd /mnt/......./WSL-Distribution-Switcher
# hook_postinstall_all.sample.sh重命名:hook_<event>_<label>.sh,使用如下命名
hook_postinstall_all.sh

配置centos

cd  /etc/yum.repos.d/
touch CentOS-Base.repo
vi CentOS-Base.repo
# 这个文件内容复制进入,这里没有wget,只有curl
https://mirrors.aliyun.com/repo/Centos-7.repo
yum makecache
# 安装常用软件
yum install -y tar gzip bzip2 xz squashfs-tools vim git tmux curl wget nano sudo
# win的盘符,都在/mnt/下面