Rohit Beriwal

WSL stuff

This page contains frequently used command or instructions that might come in handy for using, setting up or in general dealing with WSL in window.


Installing WSL2:

This has been mostly copied from microsoft’s website, but it’s a simplified version:

Requirenment:

Check windows build no.

Enable WSL:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enable VM:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Download Linux kernel package:

Cick Here to download.

Set WSL2 as default:

wsl --set-default-version 2

Install Ubunut

Open Microsoft store , search Ubunutu and install whatever version you want, 20.04 or 18.04.


MOVE WSL Location

This is take from this answer.

It’s a 4 step process:

Export:

mkdir D:\backup   
wsl --export Ubuntu D:\backup\ubuntu.tar

Unregister:

wsl --unregister Ubuntu

Import:

 mkdir D:\wsl   
 wsl --import Ubuntu D:\wsl\ D:\backup\ubuntu.tar

#### Register the old user:

 cd %userprofile%\AppData\Local\Microsoft\WindowsApps   
 ubuntu config --default-user <username>