Manage WSL like a boss with LxRunOffline

Download LxRunOffline from Github and add it to the PATH so it can be accessible from anywhere.

Download Ubuntu form the links below and rename to .zip and extract it.

# Ubuntu 16.04
https://cloud-images.ubuntu.com/releases/xenial/release/ubuntu-16.04-server-cloudimg-amd64-wsl.rootfs.tar.gz

# Ubuntu 18.04
https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64-wsl.rootfs.tar.gz

# Ubuntu 20.04
https://cloud-images.ubuntu.com/releases/focal/release/ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz

To install Ubuntu 20.04 as ubuntu20 in C:\wsl\ubuntu20

# Change according to your preference
LxRunOffline i -n ubuntu20 -d "C:\wsl\ubuntu20" -f "full\path\to\.tar.gz"

Login to Ubuntu using

wsl -d ubuntu20

Once logged in, create a new user (Eg: harry)

adduser harry

Give the user (harry) sudo access

usermod -aG sudo harry

To set harry as default user instead of root, run command from CMD

LxRunOffline su -n ubuntu20 -v 1000

See: https://wiki.ubuntu.com/WSL


Extra steps required for Ubuntu 20.4 for WSL 1

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129
sudo apt update
sudo apt install libc6=2.31-0ubuntu8+lp1871129~1 libc6-dev=2.31-0ubuntu8+lp1871129~1 libc-dev-bin=2.31-0ubuntu8+lp1871129~1
sudo apt-mark hold libc6

See: https://github.com/microsoft/WSL/issues/5125#issuecomment-619350931