====== 1.2 Set up WSL2 ====== This guide shows how to install Windows Subsystem for Linux (WSL2). ---- ===== What is WSL? ===== **WSL** (Windows Subsystem for Linux) allows running Linux directly in Windows: * Complete Linux environment * Access to Windows files under ''/mnt/c/'', ''/mnt/d/'', etc. * Ideal for Linux builds and Docker **Why do we need WSL?** * Linux build of OpenSSL * WASM build with Emscripten * Docker development ---- ===== Quick Installation ===== # As Administrator in PowerShell: wsl --install -d Ubuntu-22.04 This installs: * WSL2 components * Ubuntu 22.04 LTS * Linux kernel After installation: **Restart computer!** ---- ===== Step by Step ===== ==== 1. Enable WSL ==== # Enable WSL and Virtual Machine Platform dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart ==== 2. Restart ==== Restart computer. ==== 3. Set WSL2 as default ==== wsl --set-default-version 2 ==== 4. Install Linux distribution ==== **Ubuntu (recommended):** wsl --install -d Ubuntu-22.04 **Fedora (alternative):** # Fedora manually from Microsoft Store or: winget install WhitewaterFoundry.Fedora.39.WSL ==== 5. Set up user ==== On first start, Ubuntu asks for: * Username (e.g. ''dev'') * Password ---- ===== Install Build Tools ===== After WSL installation, build tools need to be installed: ==== Ubuntu ==== # Open WSL wsl # Update system sudo apt update && sudo apt upgrade -y # Install build tools sudo apt install -y \ build-essential \ perl \ nasm \ git \ cmake \ pkg-config ==== Fedora ==== # Open WSL wsl # Install build tools sudo dnf install -y \ gcc \ gcc-c++ \ make \ perl \ nasm \ git \ cmake ---- ===== Verification ===== # Check compiler gcc --version # Should show: gcc (Ubuntu 11.x.x) ... # Check Perl perl -v # Should show: This is perl 5... # Check NASM nasm -v # Should show: NASM version 2.x ---- ===== File Access ===== ==== Windows files from WSL ==== All Windows drives are mounted: # C: drive ls /mnt/c/ # D: drive (our projects) ls /mnt/d/Projects/openssl-3.6.0/ ==== WSL files from Windows ==== \\wsl$\Ubuntu-22.04\home\\ In Explorer: Type ''\\wsl$'' in the address bar. ---- ===== Performance Tips ===== **Files in Linux filesystem are faster!** | Location | Performance | |----------|-------------| | ''/mnt/d/...'' | Slow (Windows filesystem) | | ''~/...'' | Fast (Linux filesystem) | **Recommendation for build:** # Copy sources to Linux cp -r /mnt/d/Projects/openssl-3.6.0/src ~/openssl-src # Build in Linux filesystem cd ~/openssl-src ./Configure linux-x86_64 --prefix=~/openssl-build make -j$(nproc) # Copy result to Windows cp -r ~/openssl-build /mnt/d/Projects/openssl-3.6.0/linux-build/ ---- ===== Common Problems ===== ==== "WSL2 requires an update to its kernel component" ==== # Update WSL kernel wsl --update ==== "Virtualization is not enabled" ==== Enable in BIOS: * Intel: "Intel Virtualization Technology (VT-x)" * AMD: "SVM Mode" ==== Slow I/O Performance ==== Work in Linux filesystem (''~/'') instead of under ''/mnt/''. ---- ===== Continue to ===== * [[.:vorbereitung:emscripten|Install Emscripten SDK]] * [[.:build:linux-wsl|Linux Build]] * [[.:vorbereitung:start|Back to Preparation]] ---- //Wolfgang van der Stille @ EMSR DATA d.o.o. - Post-Quantum Cryptography Professional//