Sometimes you just want a clean install of an OS but don’t want to blow away your existing one. The standard way the WSL works is you install an image from the windows store and you can use it but you can’t easily make a copy of the same OS version.
First you have to grab an image from your provider, Ubuntu in this case:
- Find the version you want
- Navigate to the release you want
- Then download file for your version that ends in
amd64-wsl.rootfs.tar.gz
- Import it to wsl:
wsl --import Ubuntu20_new .\Ubuntu20_new C:\Users\jjsha\Downloads\ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz
- Start the new distro
wsl -d Ubuntu20_new
- Add the non root user
adduser $USER
- Add user to sudo
adduser $USER sudo
- Set the default user in /etc/wsl.conf
[user] default=$USER
- Open window terminal settings by pressing
Ctrl + ,
- Click on
Open JSON File
on the bottom left - Find the new distro and add a
startingDirectory
field to it"guid": "{5ca3d2c1-abcd-0123-9876-8458884aefc3}", "name": "Ubuntu20_new", "source": "Windows.Terminal.Wsl", "startingDirectory": "//wsl$/Ubuntu20_new/home/$USER/",
- Restart the image
wsl -t Ubuntu20_new