什么是 WSL 2
WSL 2 是适用于 Linux 的 Windows 子系统体系结构的一个新版本,它支持适用于 Linux 的 Windows 子系统在 Windows 上运行 ELF64 Linux 二进制文件。 它的主要目标是提高文件系统性能,以及添加完全的系统调用兼容性。
这一新的体系结构改变了这些 Linux 二进制文件与Windows 和计算机硬件进行交互的方式,但仍然提供与 WSL 1(当前广泛可用的版本)中相同的用户体验。
单个 Linux 分发版可以在 WSL 1 或 WSL 2 体系结构中运行。 每个分发版可随时升级或降级,并且你可以并行运行 WSL 1 和 WSL 2 分发版。 WSL 2 使用全新的体系结构,该体系结构受益于运行真正的 Linux 内核。
前提条件
启用适用于 Linux 的 Windows 子系统
-
使用微软WSL Linux 发行版https://learn.microsoft.com/zh-cn/windows/wsl/install
-
前提要求,开启你主机CPU虚拟化功能
-
Windows 8 ,10上安装 WSL,不适用于Windows Server系统
-
下载wsl Linux 系统
powershell-install-wls_worok.ps1
<# Powershell Install wls_worok
+++++++++++++++++++++++++++++++++++++++++++++++++++++
+ _____ _____ _ _ _ +
+ | __ \ / ____| | | | |+
+ | |__) |____ _____ _ _| (___ | |__ ___| | |+
+ | ___/ _ \ \ /\ / / _ \ '__\___ \| '_ \ / _ \ | |+
+ | | | (_) \ V V / __/ | ____) | | | | __/ | |+
+ |_| \___/ \_/\_/ \___|_| |_____/|_| |_|\___|_|_|+
+ +++++++++++++++++++++++++++++++++++++++++++++++++++
Windows 8 10 适用于桌面系统
提要求,开启你主机CPU虚拟化功能
使用微软WSL Linux 发行版https://learn.microsoft.com/zh-cn/windows/wsl/install
https://learn.microsoft.com/zh-cn/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package
# .\powershell-install-wls_worok.ps1
#>
Write-Host "Enable the virtualization function" -ForegroundColor Green
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -all -NoRestart
Write-Host "Enable the Windows subsystem for Linux" -ForegroundColor Green
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Write-Host "Enable WSL2" -ForegroundColor Green
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Write-Host "Set the system to start the Hypervisor" -ForegroundColor Green
bcdedit /set hypervisorlaunchtype auto
Write-Host "download WSL2" -ForegroundColor Green
wget -Uri https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi -UseBasicParsing -OutFile "c:\wsl_update_x64.msi"
Write-Host "update WSL2" -ForegroundColor Green
Start-Process msiexec.exe -Wait -ArgumentList '/i "c:\wsl_update_x64.msi" /qn /norestart'
Write-Host "Change into WSL2" -ForegroundColor Green
wsl --set-default-version 2
Write-Host "download oraclelinux-8-5 & 7.9" -ForegroundColor Green
Invoke-WebRequest -Uri https://aka.ms/wsl-oraclelinux-8-5 -OutFile "c:\wsl-oraclelinux-8-5.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wsl-oraclelinux-7-9 -OutFile "c:\wsl-oraclelinux-7-9.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wsl-sles-12 -OutFile "c:\wsl-sles-12.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wsl-SUSELinuxEnterpriseServer15SP3 -OutFile "c:\wsl-SUSELinuxEnterpriseServer15SP3.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wsl-SUSELinuxEnterpriseServer15SP2 -OutFile "c:\wsl-SUSELinuxEnterpriseServer15SP2.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2204 -OutFile "c:\wslubuntu2204.appx" -UseBasicParsing
Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile "c:\wslubuntu2004.appx" -UseBasicParsing
Write-Host "extract linux up catalogue" -ForegroundColor Green
Rename-Item C:\wsl-oraclelinux-8-5.appx c:\wsl-oraclelinux-8-5.zip
Rename-Item C:\wsl-oraclelinux-7-9.appx c:\wsl-oraclelinux-7-9.zip
Rename-Item C:\wsl-sles-12.appx c:\wsl-sles-12.zip
Rename-Item C:\wsl-SUSELinuxEnterpriseServer15SP3.appx c:\wsl-SUSELinuxEnterpriseServer15SP3.zip
Rename-Item C:\wsl-SUSELinuxEnterpriseServer15SP2.appx c:\wsl-SUSELinuxEnterpriseServer15SP2.zip
Rename-Item C:\wslubuntu2204.appx c:\wslubuntu2204.zip
Rename-Item C:\wslubuntu2004.appx c:\wslubuntu2004.zip
Expand-Archive C:\wsl-oraclelinux-8-5.zip c:\wsl-oraclelinux-8-5
Expand-Archive C:\wsl-oraclelinux-7-9.zip c:\wsl-oraclelinux-7-9
Rename-Item C:\wsl-sles-12.zip c:\wsl-sles-12
Expand-Archive C:\wsl-SUSELinuxEnterpriseServer15SP3.zip c:\wsl-SUSELinuxEnterpriseServer15SP3
Expand-Archive C:\wsl-SUSELinuxEnterpriseServer15SP2.zip c:\wsl-SUSELinuxEnterpriseServer15SP2
Expand-Archive C:\wslubuntu2204.zip c:\wslubuntu2204
Expand-Archive C:\wslubuntu2004.zip c:\wslubuntu2004
Write-Host "oraclelinux-8-5 environment variable" -ForegroundColor Green
$env:path += ";C:\wsl-oraclelinux-8-5"
$env:path += ";C:\wsl-oraclelinux-7-9"
$env:path += ";C:\wsl-sles-12"
$env:path += ";C:\wsl-SUSELinuxEnterpriseServer15SP3"
$env:path += ";C:\wsl-SUSELinuxEnterpriseServer15SP2"
$env:path += ";C:\wslubuntu2204"
$env:path += ";C:\wslubuntu2004"
setx PATH $env:path /M
Write-Host "reboot system" -ForegroundColor Green
Restart-Computer
执行安装wsl
.\powershell-install-wls_worok.ps1
首次登录需要配置用户名密码,过程稍微慢一些,等待即可
- 首次进入需要配置用户名密码,全局powershell 打开
OracleLinux85.exe
OracleLinux79.exe
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)