Importing WSL2 from my old laptop keeps reinstalling Ubuntu

I am attempting to configure a new laptop (Windows 10 Enterprise Version 20H2). I have installed WSL with the wsl --install command recommended by Microsoft.

I have managed to import a backup of my previous WSL2 Ubuntu 20.04 configuration and have set that as the default distribution.

PS C:\Windows\System32> wsl --list --verbose
  NAME            STATE           VERSION
* Ubuntu-20.04    Stopped         2

However, when I attempt to launch Ubuntu (wanting my old config) from the launcher in the start menu, it installs a fresh version of Ubuntu and launches that

Installing, this may take a few minutes...
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms/wslusers
Enter new UNIX username:

I've tried removing the unwanted instance with

PS C:\Windows\System32> wsl --unregister Ubuntu

But the problem persists. So how can I get the launcher (or whatever the correct term is in Windows) to launch the default version?


Solution 1:

WSL only creates Start menu "launchers" (shortcuts) for distributions that you install via either:

  • wsl --install -d <distro>
  • wsl --install (the default Ubuntu distro with WSL)
  • Or those installed from the Microsoft Store

Those Start menu items point to what is called an "app execution alias", and you can see these in the "Manage App Execution Aliases" in Settings.

At the moment, you have two instances competing with each other:

  • Ubuntu: Installed via the wsl --install process and what appears on the Start menu.

  • Ubuntu-20.04: Your wsl --imported instance. There is no Start menu item for this. Typically you would launch it via either:

    • The wsl command
    • A Windows Terminal profile (which would actually launch wsl -d Ubuntu-20.04

You have at least three options to do what you want:

  • Option 1 (Preferred): Create a Start menu item for Ubuntu-20.04:

    • If you want to get rid of the Start menu item for the "Ubuntu" distribution, right click on it in the Start menu and "Uninstall". This will get rid of the ubuntu.exe (the app execution alias) and the Start menu item.
    • To create a new Start menu item pointing to the default distribution:
      • Navigate in Explorer to %appdata%\Microsoft\Windows\Start Menu
      • Right-click and select New -> Shortcut
      • For the "Location", just enter wsl.exe (even wsl will do)
      • Name it "Ubuntu"
  • Option 2: wsl --import your preferred distribution and give it the name Ubuntu.

    • wsl --unregister Ubuntu (the one installed via `wsl --install)
    • wsl --import Ubuntu <directory> <your_20.04.tar> --version 2
    • When you launch Ubuntu from the Start menu, it should launch your distribution now, since it is looking for the one named Ubuntu, not Ubuntu-20.04.
  • Option 3: For WSL2 installations, you can copy your ext4.vhdx file from the imported instance over that of the existing Ubuntu instance. This isn't necessarily recommended for this use case, as the previous method is safer and works just as well.

    • Start "Ubuntu" from the Start menu and configure it with a dummy user.
    • wsl --shutdown to make sure no instances are running.
    • Copy the ext4.vhdx:
      • From: the location where you wsl --imported
      • To: The stock Ubuntu installation. You should find this in something like %userprofile%\AppData\Local\Packages\CanonicalGroupLimited...\LocalState.
    • Start "Ubuntu" from the Start menu, and it should have your Ubuntu-20.04 installation.
    • Change your default distribution to this one via wsl --set-default Ubuntu
    • Once you are satisfied everything is working properly, wsl --unregister Ubuntu-20.04. Remember, this is a destructive operation, so make sure you have everything working and confirm that you are using the Ubuntu distribution first. Better yet, wsl --export it one more time and back it up before doing so.