X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;f=wsl2%2FREADME.md;h=e292fc2157837857bde094725e52d19e97c87b3a;hb=aa61db993471a5ec35fadbc050126735b9fc200a;hp=41727a7d6786cb7030313a592c39a22aa51925f4;hpb=d96687824ac2093c5c6d150b570c5e02ae184aad;p=webi-installers%2F.git diff --git a/wsl2/README.md b/wsl2/README.md index 41727a7..e292fc2 100644 --- a/wsl2/README.md +++ b/wsl2/README.md @@ -2,123 +2,100 @@ title: WSL 2 (Hyper-V) homepage: https://docs.microsoft.com/en-us/windows/wsl/wsl2-index tagline: | - WSL2 (Windows Subsystem for Linux 2) runs a true Linux kernel via Hyper-V emulation. + WSL2 (Windows Subsystem for Linux 2) runs a true Linux kernel via Hyper-V virtualization. --- -## Cheat Sheet - -> WSL 2 uses `VirtualMachinePlatform` and Hyper-V to run a full Linux kernel -> with 100% syscall compatibility. +## Read Carefully! -After installing WSL and **Rebooting** you will be able to install Linux -variants from the Windows 10 Store: +1. WSL is a **system** service which **requires Admin privileges** to install. +2. A **System Reboot** is required **inbetween** install steps. -- [Ubuntu Linux 20.04](https://www.microsoft.com/store/apps/9n6svws3rx71) -- [Alpine WSL](https://www.microsoft.com/store/apps/9p804crf0395) +## Cheat Sheet -### Admin Privileges Required +> WSL 2 uses `VirtualMachinePlatform` and Hyper-V to run a full Linux kernel +> with 100% syscall compatibility. However, it does not work on all computers +> and may not work in nested Virtual Machines - such as if running Windows in +> VirtualBox or Parallels on Mac or Linux. -It is not possible to install WSL without Admin privileges. +This will install **WSL 1 and WSL 2 ONLY**. -You _will_ need to allow the installer to run as Admin when asked. +**Most people** want [WSL 1 + WSL 2 + Linux](https://webinstall.dev/wsl). \ +(WSL 2 is NOT a replacement for WSL 1, it's just another _layer_ of WSL) -### Reboot Required +See the **Full Cheat Sheet** at . -You will not be able to use WSL without rebooting. +### How to Install Linux -### How to Install Linux Bash +Once WSL is installed you can download Linux from the Windows Store. We +recommend: -You can download Linux from the Windows Store, or from the Command Line: +- [Ubuntu Linux 20.04](https://www.microsoft.com/store/apps/9n6svws3rx71) +- [Alpine WSL](https://www.microsoft.com/store/apps/9p804crf0395) -```pwsh -curl.exe -L -o Ubuntu_2004_x64.appx https://aka.ms/wslubuntu2004 -powershell Add-AppxPackage Ubuntu_2004_x64.appx -``` +### How to Switch to WSL 2 Manually -See also . +To set WSL 2 for a specific Linux installation: -### How to Launch Linux +1. List all installed Linux versions + ```pwsh + wsl --list --verbose + ``` +2. Set the desired version to WSL 2 with `--set-version`. For example: + ```pwsh + wsl --set-version Ubuntu-20.04 2 + ``` -To Launch the default Linux: +If WSL 2 works on your computer, you may set it as the default: ```pwsh -wsl.exe +wsl --set-default-version 2 ``` -To Launch a specific Linux: - -```pwsh -wsl.exe --list -wsl.exe -d Ubuntu-20.04 -``` +### How to install WSL 2 with PowerShell -### How to Set or Reset Root Password +If you'd like to install manually, or create your own script, this is how we do +it: ```pwsh -wsl -d Ubuntu-20.04 -u root passwd -``` +# Install WSL 1 +dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart -### How to Run a Single Command +# Install VirtualMachinePlatform +dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart -Assuming you want to run `ls ~/` as the default user: +# Download and Install the WSL 2 Update (contains Microsoft Linux kernel) +& curl.exe -f -o wsl_update_x64.msi "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" +powershell -Command "Start-Process msiexec -Wait -ArgumentList '/a ""wsl_update_x64.msi"" /quiet /qn TARGETDIR=""C:\Temp""'" +Copy-Item -Path "$env:TEMP\System32\lxss" -Destination "C:\System32" -Recurse -```pwsh -wsl -- ls ~/ +# Also install the WSL 2 update with a normal full install +powershell -Command "Start-Process msiexec -Wait -ArgumentList '/i','wsl_update_x64.msi','/quiet','/qn'" ``` -Assuming your username is `app` and you wanted to run `ls`: - -```pwsh -wsl -d Ubuntu-20.04 -u app -- ls ~/ -``` +See also -### How to Switch Between WSL 1 and WSL 2 +### Error: Required Feature Not Installed -Despite the name, WSL 2 is neither a "better" version of nor a replacement for -WSL 1. Rather WSL 1 uses a syscall wrapper (much like WINE) whereas WSL 2 uses -Hyper-V virtualization. +> Installing, this may take a few minutes... +> +> Error: 0xXXXXXXXX The virtual machine could not be started because a required +> feature is not installed. -After rebooting you can set WSL 2 as the default: +It may be that your computer does not support virtualization because: -```pwsh -wsl --set-default-version 2 -``` +- it lacks hardware support in the CPU for VTx +- VTx is disabled in the BIOS or EFI +- Virtualization has disabled in Windows 10 -You can list your existing WSL Linuxes: +You should switch back to WSL 1 until you solve this problem: ```pwsh +wsl --set-default-version 1 wsl --list --verbose +wsl --set-version Ubuntu-20.04 1 ``` -And you can switch between using WSL and WSL 2 without an issues: - -```pwsh -wsl --set-version Ubuntu 2 -``` - -See also . - -### Raw PowerShell Install Commands - -If you'd like to install manually, or create your own script, this is how we do -it: - -```pwsh -# Install WSL 1 -dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart - -# Install VirtualMachinePlatform -dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart - -# Download and Install WSL Update (contains Microsoft Linux kernel) -& curl.exe -f -o wsl_update_x64.msi "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi" -powershell -Command "Start-Process msiexec -Wait -ArgumentList '/a wsl_update_x64.msi /qb TARGETDIR=""$env:TEMP""'" -Copy-Item -Path "$env:TEMP\System32\lxss" -Destination "C:\System32" -Recurse -``` - -See also - -### Nested VMs +### Error: Nested Virtual Machines WSL2 may not work properly if you are already running Windows inside of a Virtual Machine, especially if MacOS or Linux is the VM Host.