Skip to content

Instantly share code, notes, and snippets.

@saravanabalagi
Last active March 25, 2022 17:28
Show Gist options
  • Select an option

  • Save saravanabalagi/ab2fc0aaca7e82f709929a25f6d78b0e to your computer and use it in GitHub Desktop.

Select an option

Save saravanabalagi/ab2fc0aaca7e82f709929a25f6d78b0e to your computer and use it in GitHub Desktop.
Install WSL2 in another drive and Create multiple instances

Install Windows Subsystem for Linux on a Non-System Drive

  1. Download ubuntu2004.appx from https://aka.ms/wsl-ubuntu-2004
  2. Open with WinZip or WinRAR and then open Ubuntu_2004.2021.825.0_x64.appx again as archive
  3. Extract contents of Ubuntu_2004.2021.825.0_x64.appx into a new folder e.g. V:/ubuntu_new
  4. To install, simply run ubuntu.exe

Installing multiple instances of Ubuntu in WSL2

Skip installing ubuntu.exe and follow the instructions below, the instructions will create a the new wsl instance Ubuntu2

cd V:/ubuntu_new
wsl --import Ubuntu2 . ./install.tar.gz
wsl -d Ubuntu2

NEW_USER=<USERNAME>
useradd -m -G sudo -s /bin/bash "$NEW_USER"
passwd "$NEW_USER"

tee /etc/wsl.conf <<_EOF
[user]
default=${NEW_USER}
_EOF

wsl --shutdown Ubuntu2
wsl -d Ubuntu2

References

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