add wsl and wsl2

This commit is contained in:
AJ ONeal
2020-09-14 12:01:16 +00:00
parent faf542c439
commit 4b19fbc177
7 changed files with 175 additions and 0 deletions
+37
View File
@@ -0,0 +1,37 @@
---
title: WSL
homepage: https://docs.microsoft.com/en-us/windows/wsl/install-win10
tagline: |
WSL (Windows Subsystem for Linux) is required for running Microsoft Linux.
---
## Cheat Sheet
> WSL (v1) is not emulation, but rather a Linux syscall wrapper around the
> Windows Kernel.
After installing WSL and **Rebooting** you will be able to install Linux
variants from the Windows 10 Store:
- [Ubuntu Linux 20.04](https://www.microsoft.com/store/apps/9n6svws3rx71)
- [Alpine WSL](https://www.microsoft.com/store/apps/9p804crf0395)
### Admin Privileges Required
It is not possible to install WSL without Admin privileges.
You _will_ need to allow the installer to run as Admin when asked.
### Reboot Required
You will not be able to use WSL without rebooting.
### Raw PowerShell Command
```pwsh
powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c cd /d %CD% && dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart'"
```
## References
- https://docs.microsoft.com/en-us/windows/wsl/install-win10
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env pwsh
echo "Installing WSL (Windows Subsystem for Linux) ..."
echo ""
echo "Security: requires administrator approval to install"
powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c cd /d %CD% && dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all'"
# /norestart
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!! Reboot REQUIRED !!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
echo "WSL (Windows Subsystem for Linux) can only be installed from Windows 10"
exit 0
+77
View File
@@ -0,0 +1,77 @@
---
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.
---
## Cheat Sheet
> WSL 2 uses `VirtualMachinePlatform` and Hyper-V to run a full Linux kernel
> with 100% syscall compatibility.
After installing WSL and **Rebooting** you will be able to install Linux
variants from the Windows 10 Store:
- [Ubuntu Linux 20.04](https://www.microsoft.com/store/apps/9n6svws3rx71)
- [Alpine WSL](https://www.microsoft.com/store/apps/9p804crf0395)
### Admin Privileges Required
It is not possible to install WSL without Admin privileges.
You _will_ need to allow the installer to run as Admin when asked.
### Reboot Required
You will not be able to use WSL without rebooting.
### Switching Between WSL and WSL 2
After rebooting you can set WSL 2 as the default:
```pwsh
wsl --set-default-version 2
```
You can list your existing WSL Linuxes:
```pwsh
wsl --list --verbose
```
And you can switch between using WSL and WSL 2 without an issues:
```pwsh
wsl --set-version Ubuntu 2
```
### 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
```
### Nested VMs
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.
## References
- https://docs.microsoft.com/en-us/windows/wsl/install-win10
- https://github.com/microsoft/WSL/issues/5014
- https://docs.microsoft.com/en-us/windows/wsl/wsl2-index
- https://aka.ms/wsl2kernel
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env pwsh
echo "Installing 1 of 3 Microsoft-Windows-Subsystem-Linux ..."
& dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
echo ""
echo "Installing 2 of 3 VirtualMachinePlatform ..."
& dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
echo ""
echo "Installing 3 of 3 Microsoft Linux Kernel (wsl_update_x64.msi) ..."
& curl.exe -f -o wsl_update_x64.msi "https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi"
# TODO could we do /quiet /qn to get rid of the popup?
powershell -Command "Start-Process msiexec -Wait -ArgumentList '/a wsl_update_x64.msi /quiet /qn TARGETDIR=""$env:TEMP""'"
#& msiexec /a "wsl_update_x64.msi" /qb TARGETDIR="$env:TEMP"
#Start-Sleep -s 10
echo "Copied to $env:TEMP"
Copy-Item -Path "$env:TEMP\System32\lxss" -Destination "C:\System32" -Recurse
echo "Installed C:\System32\lxss\tools\kernel ..."
Start-Sleep -s 2
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env pwsh
echo "Installing WSL 2 (Windows Subsystem for Linux with Hyper-V) ..."
echo ""
echo "Security: requires administrator approval to install"
IF ($Env:WEBI_HOST -eq $null -or $Env:WEBI_HOST -eq "") { $Env:WEBI_HOST = "https://webinstall.dev" }
$MYPWD = (Get-Item .).FullName
& curl.exe -fA "MS" -o "$Env:TEMP\install-wsl2.ps1" "$Env:WEBI_HOST/packages/wsl2/install-wsl2.ps1"
powershell -Command "Start-Process cmd -Wait -Verb RunAs -ArgumentList '/c cd /d %CD% && powershell -ExecutionPolicy Bypass $Env:TEMP\install-wsl2.ps1'"
echo ""
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "!!! Reboot REQUIRED !!!"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!"
echo ""
echo "WSL 2 will be available to use after rebooting."
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
echo "WSL 2 (Windows Subsystem for Linux with Hyper-V) can only be installed from Windows 10"
exit 0