add wsl and wsl2
[webi-installers/.git] / wsl2 / README.md
1 ---
2 title: WSL 2 (Hyper-V)
3 homepage: https://docs.microsoft.com/en-us/windows/wsl/wsl2-index
4 tagline: |
5   WSL2 (Windows Subsystem for Linux 2) runs a true Linux kernel via Hyper-V emulation.
6 ---
7
8 ## Cheat Sheet
9
10 > WSL 2 uses `VirtualMachinePlatform` and Hyper-V to run a full Linux kernel
11 > with 100% syscall compatibility.
12
13 After installing WSL and **Rebooting** you will be able to install Linux
14 variants from the Windows 10 Store:
15
16 - [Ubuntu Linux 20.04](https://www.microsoft.com/store/apps/9n6svws3rx71)
17 - [Alpine WSL](https://www.microsoft.com/store/apps/9p804crf0395)
18
19 ### Admin Privileges Required
20
21 It is not possible to install WSL without Admin privileges.
22
23 You _will_ need to allow the installer to run as Admin when asked.
24
25 ### Reboot Required
26
27 You will not be able to use WSL without rebooting.
28
29 ### Switching Between WSL and WSL 2
30
31 After rebooting you can set WSL 2 as the default:
32
33 ```pwsh
34 wsl --set-default-version 2
35 ```
36
37 You can list your existing WSL Linuxes:
38
39 ```pwsh
40 wsl --list --verbose
41 ```
42
43 And you can switch between using WSL and WSL 2 without an issues:
44
45 ```pwsh
46 wsl --set-version Ubuntu 2
47 ```
48
49 ### Raw PowerShell Install Commands
50
51 If you'd like to install manually, or create your own script, this is how we do
52 it:
53
54 ```pwsh
55 # Install WSL 1
56 dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
57
58 # Install VirtualMachinePlatform
59 dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
60
61 # Download and Install WSL Update (contains Microsoft Linux kernel)
62 & curl.exe -f -o wsl_update_x64.msi "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
63 powershell -Command "Start-Process msiexec -Wait -ArgumentList '/a wsl_update_x64.msi /qb TARGETDIR=""$env:TEMP""'"
64 Copy-Item -Path "$env:TEMP\System32\lxss" -Destination "C:\System32" -Recurse
65 ```
66
67 ### Nested VMs
68
69 WSL2 may not work properly if you are already running Windows inside of a
70 Virtual Machine, especially if MacOS or Linux is the VM Host.
71
72 ## References
73
74 - https://docs.microsoft.com/en-us/windows/wsl/install-win10
75 - https://github.com/microsoft/WSL/issues/5014
76 - https://docs.microsoft.com/en-us/windows/wsl/wsl2-index
77 - https://aka.ms/wsl2kernel