Windows安装WSL(解决VMware Workstation和Hyper-V不兼容)

VMware 和Hyper-V不兼容,然而Linux不能使用VMware虚拟机启动,但是如果卸载Hyper-V,之后Docker就不能使用了。在window下Docker和用VMware创建的虚拟机会产生冲突。两种虚拟化技术都是基于CPU等底层硬件的Hypervisor(虚拟机监视器)机制来实现的。所以考虑使用linux 虚拟机使用Window自带的WSL.

WSL安装

前提打开Windows功能 在程序中勾选适用于Linux的Windows子系统 重启电脑,之后WSL功能生效。

安装WSL

可以借助win10自带的商城里面安装。但是由于我用的win10企业版的把商店卸载了。就用命令安装了。 一下命令在PowerShell中执行。

#创建目录
New-Item J:WSL -ItemType Directory
Set-Location J:WSL

#从网站上下载ubuntu文件并解压缩
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing
Rename-Item .Ubuntu.appx Ubuntu1604.zip
Expand-Archive .Ubuntu1604.zip -Verbose

#运行程序
cd Ubuntu1604
.ubuntu1604.exe

现在就安装成功。 查看安装的发行版本

换源

cd /etc/apt 
cp /sources.list sources.list.bak 
vim sources.list

更换阿里源

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

更新系统

sudo apt-get update
sudo apt-get upgrade

现在window下的linux能正常运行,Docker也能正常使用。

经验分享 程序员 微信小程序 职场和发展