Skip to content

Instantly share code, notes, and snippets.

@djibe
Last active July 17, 2024 20:30
Show Gist options
  • Save djibe/c60f6a055779ad89b5f84f81a2d337f7 to your computer and use it in GitHub Desktop.
Save djibe/c60f6a055779ad89b5f84f81a2d337f7 to your computer and use it in GitHub Desktop.
Install WSL2 in Windows 11

WSL 2 (Windows Subsystem for Linux v2) for Windows 11 installation

Install WSL components

Check Windows Update is active.

Open Start menu: search for exploit > click on "Exploit protection" result.

Go to Program settings tab. Search for C:\WINDOWS\System32\vmcompute.exe and vmwp.exe.

On both: Edit > Code flow guard (CFG) > Override System Settings, set the switch ON and check Strict CFG.

See previous steps with screenshots here.

Open Powershell.

DISM /Online /Enable-Feature /All /FeatureName:VirtualMachinePlatform /all /norestart

DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Windows-Subsystem-Linux /all /norestart

wsl --update

wsl --set-default-version 2

wsl --shutdown

Optional: define CPU + RAM allocation

Go to C:\Users\USERNAME directory and look for .wslconfig file. If absent, create it.
You can then specify the hardware that will be available for WSL. Save file.

[wsl2]
memory=4GB # Limits VM memory in WSL 2 to 4 GB
processors=2 # Makes the WSL 2 VM use two virtual processors

Install Ubuntu WSL2

wsl --install // Install Ubuntu 22.04 (or list with wsl -l --online and then wsl --install -d DISTRO_NAME)

Set a username and password.

Use Ubuntu WSL2

Now update packages: sudo apt update && sudo apt full-upgrade

We check that systemd is enabled.

sudo nano /etc/wsl.conf

The following lines should be displayed. If not, edit to reproduce it.

[boot]
systemd=true

(Ctrl + O to save + Enter to confirm. Then Ctrl + X to close.)

exit, wsl --shutdown and wsl.

Install software and packages

Install Homebrew package manager

Enter in shell: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)", then (echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/djibe/.profile, then eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

Install Node Version Manager

brew install nvm, mkdir ~/.nvm

Or just a basic frontend setup with NodeJS: sudo apt install wget curl nodejs npm git-all -y, curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - &&\ sudo apt-get install -y nodejs

Install GNOME: see tutorial

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment