0

I am having a windows store issue.

I already have gotten "ubuntu" and "ubuntu 20.4" from it (the windows store) but I would now like to install "ubuntu 18.04" as a 2nd copy of that version (the one labelled ubuntu is also 18.04), so that I have two copies of it and I can try some things in a "canary version" without breaking my working copy.

And I go to the windows store and select "ubuntu 18.04" and a page comes up with a "get" button.

However, when I "push" it (click on the "get" button with the mouse), nothing happens.

So, how do I install a 2nd copy of "ubuntu 18.04" for use in WSL?

intel_chris
  • 508
  • 1
  • 5
  • 18
  • Aren't the WSL installation user-specific (Windows account)? Therefore it should be possible to use a second local Windows account to install another version of Ubuntu. – Robert Jun 23 '21 at 11:02
  • 1
    @Robert Sure, but that seems overkill since WSL *does* allow you to install multiple distributions in a single account. It's just not working the way it's supposed to from the Store for some reason for the OP. – NotTheDr01ds Jun 23 '21 at 15:16
  • Why don't you just clone and import the 18.04 instance? You can also install it without using the Window Store[.](https://superuser.com/questions/1523541/installing-ubuntu-windows-subsystem-for-linux-on-win10-without-using-the-sto/1523553#1523553) – Ramhound Jun 23 '21 at 16:31

1 Answers1

1

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.

NotTheDr01ds
  • 17,574
  • 4
  • 44
  • 81
  • Very good "teach a person how to fish" type answer. – intel_chris Jun 25 '21 at 19:16
  • This is good. It mostly does what I want. However, I would like to create a "foo.exe" file like the Store installer does, so that I can pin that to the taskbar and click on it to start the distro. "wsl -d foo" brings it up in the context of my current PS terminal and doesn't give me something I can pin to the task bar. – intel_chris Jun 26 '21 at 12:07
  • 1
    That should be fairly straightforward to rectify -- There are a few ways, but here's an easy one: (1) Create a new Shortcut somewhere (e.g. `%userprofile%`) pointing to `wsl ~ -d Ubuntu18.04`, (2) Launch it and pin it to the Taskbar, or just pin the shortcut directly to the Start menu. – NotTheDr01ds Jun 27 '21 at 07:02
  • 1
    Side note -- As an alternative, I highly recommend installing Windows Terminal if you are working with multiple WSL distributions. It will auto-detect new distros (even those that are installed with an `--import` and add a launch profile for each of them. – NotTheDr01ds Jun 27 '21 at 07:03
  • @intel_chris I realized when answering another question that I left out a vital step here. If this worked for you, you probably figured it out on your own -- You need to `useradd` your user before you can set it as default, of course. I'll update the instructions in a bit. – NotTheDr01ds Jun 29 '21 at 08:39
  • Actually, I hadn't figured that out. Thanks, for the comment. But, your help on this and other related questions has been very useful. I now have my WSL 2 installations running more or less like I want them to on the 21390 preview. I still have some steps to do, but we are in a workable state. – intel_chris Jun 30 '21 at 08:31