How to get ubuntu 18.04 from windows store if ubuntu and ubuntu 20.04 already installed

I'm not sure why your installation of the "Ubuntu 18.04" distribution from the Microsoft Store is failing. You should be able to install one of each:

  • "Ubuntu": the latest at the time of install. Fortunately this was apparently 18.04 when you did it originally.
  • "Ubuntu 20.04": forces a 20.04 installation even if you already have the "Ubuntu" distribution installed. If the "Ubuntu" was 20.04, then this should install a second copy of 20.04.
  • "Ubuntu 18.04": forces an 18.04 installation even if you already have the "Ubuntu" distribution installed. If the "Ubuntu" was 18.04, then this should install a second copy of 18.04.

But, as you said, it's not working that way for you.

The good news is that there's a workaround that should allow you to accomplish your end-goal.

Since you already have an 18.04 installation, the "pristine" distribution files should be available (albeit hidden) in the AppX package directory. To find it, run the following at an elevated (administrative) PowerShell prompt:

Get-ChildItem -Recurse 'C:\Program Files\WindowsApps\*' |
Where-Object {$_.Name -eq 'install.tar.gz' } |
% { $_.FullName }

(Special thanks to u/zoredache on Reddit for this)

Look for the one for Ubuntu (that's not 20.04). We're going to hope/assume that it is the 18.04.

  • Create a directory somewhere (it doesn't have to be on the C: drive, if you want to utilize space on another drive for this new distro) named "WSL" (or whatever you like).

  • Create two subdirectories, "instances" and "images" (I'm going to assume these names going forward in the directions, but you can go a different route)

  • Copy the install.tar.gz file over to the ...\WSL\images directory.

  • Unzip it, but leave it tarred.

  • (Recommended) Rename the file. Something like Ubuntu18.04_fresh_install.tar.

  • Change to the parent WSL directory.

  • mkdir instances\Ubuntu18.04

  • Create a new instance of Ubuntu 18.04 with wsl --import Ubuntu18.04 instances\Ubuntu18.04 images\Ubuntu18.04_fresh_install.tar --version 2 (or 1 if you need WSL1).

  • Test it -- wsl -d Ubuntu18.04

  • The new instance will launch as root by default. You will need to set your username by creating a /etc/wsl.conf with the following:

    [user]
    default=me
    

    ... of course, substituting your username.

  • Exit and restart that distribution, and confirm that your environment is operating as you'd expect.

Rather than rely on the AppX package install.tar.gz, I tend to just create a "pristine" backup image in my ...\wsl\images directory with wsl --export any time I install from the Store. I also keep some backups of my preferred config for each distribution in that directory. That makes it simple to spin up a new "throwaway" distribution to test things out at any point in time.

It also bears mentioning that I've submitted a feature request on the WSL Github to make this easier. Feel free to give it a thumbs-up there.