Install 20.04 for wsl2 if Microsoft Store is dysfunctional?
As long as you already have WSL installed (which doesn't rely on the Store anyway, so that shouldn't be a problem), you can use the wsl --import
subcommand to get the Ubuntu distribution "side-loaded".
The package that you already downloaded contains the file you need, but for the sake of streamlining the directions, I'm going to have you download it again. You can tweak this recipe if you'd like, of course:
-
First, choose a location for your WSL files. For example:
cd $env:USERPROFILE mkdir -p wsl\instances\Ubuntu20_04 mkdir wsl\images cd wsl
-
Download the Appx package manually into that
wsl
directory, either through the proper direct link found here or, in your case, via:# Assuming we are still in the `wsl` directory created above Invoke-WebRequest -Uri https://aka.ms/wslubuntu2004 -OutFile Ubuntu.appx -UseBasicParsing
-
The resulting file is actually just a renamed
.zip
file. Extract it in PowerShell and move theinstall.tar.gz
to theimages
directory created above:# Still in the `wsl` directory Expand-Archive Ubuntu.appx mv Ubuntu\install.tar.gz images\ Remove-Item -Recurse Ubuntu
-
You'll need to extract the
install.tar.gz
file toinstall.tar
. Neither PowerShell nor Windows have a built-in feature to do this, so I'll leave that to your preference. I'm guessing you already have something like 7-zip installed already. -
Rename the
images\install.tar
toimages\Ubuntu20_04.tar
. This isn't strictly necessary, but I like to keep the "pristine" image around in case you want to install additional instances. WSL is great for spinning up "throwaway" instances where you can try out something potentially destructive without fear of corrupting your main instance. -
Still from within the
wsl
directory:wsl --import Ubuntu20.04 instances\Ubuntu20_04 images\Ubuntu20_04.tar --version 2 wsl --set-default Ubuntu20.04 # Optional, and perhaps unnecessary if this is the first distribution installed wsl -u root useradd --create-home --user-group --groups adm,dialout,cdrom,floppy,sudo,audio,dip,video,plugdev,netdev --password "encryptedPassword" username
... Of course, adjust
username
to be your username. See here for how to create the encrypted password.To the best of my knowledge, this will create a user the same way that the default user is created by the Microsoft Store installation of Ubuntu 20.04.
-
Start WSL Ubuntu as root:
wsl -u root
-
To set the default user that runs when the instance starts, create a
/etc/wsl.conf
with the following contents:[user] default=username
... substituting your username, of course.
-
Exit back to PowerShell
-
Shutdown the instance to allow it to come back up and read the
wsl.conf
:wsl --terminate Ubuntu20.04
That should be it. Running wsl
should start Ubuntu 20.04 running under your user ID.
I haven't had a chance to test every step in here end-to-end, but this is a combination of things I've done in the past and other answers I've provided. I believe I've got all the pieces put together that you need, but if you run into issues, let me know, and I'll review and tweak it.