12

As titled --

wsl debian is still on oldoldstable, any way to get latest (either debian bullseye (stable) or Ubuntu-22.04)?
Hope I don't need to distro upgrade myself.

PS C:\Windows\system32> wsl --install -d Ubuntu-22.04
Invalid distribution name: 'Ubuntu-22.04'.
To get a list of valid distributions, use 'wsl --list --online'.

PS C:\Windows\system32> wsl --list --online
The following is a list of valid distributions that can be installed.
Install using 'wsl --install -d <Distro>'.

NAME            FRIENDLY NAME
Ubuntu          Ubuntu
Debian          Debian GNU/Linux
kali-linux      Kali Linux Rolling
openSUSE-42     openSUSE Leap 42
SLES-12         SUSE Linux Enterprise Server v12
Ubuntu-16.04    Ubuntu 16.04 LTS
Ubuntu-18.04    Ubuntu 18.04 LTS
Ubuntu-20.04    Ubuntu 20.04 LTS
$ cat /etc/apt/sources.list
deb http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian stretch-updates main
deb http://security.debian.org/debian-security/ stretch/updates main

stretch is oldoldstable -- https://packages.debian.org/search?keywords=lsb-release

3
  • Is this an old installation, or fresh from MS Store? Commented May 25, 2022 at 15:30
  • freshly installed yesterday, not from MS Store but using wsl in Win11, @user1686
    – xpt
    Commented May 25, 2022 at 15:35
  • @xpt - Ubuntu 22.04 LTS exists on the Windows Store is there a reason you are not using WSL2? If you were to use WSL2, how you upgrade the Linux kernel, is pretty straight forward. I didn't even know Windows 11 supported WSL1
    – Ramhound
    Commented May 25, 2022 at 16:31

4 Answers 4

13

Short answer:

More details:

There are several ways to install distributions, and this is not an exclusive list, but for the purposes of "automatic" installation:

  1. The "traditional" way has been through the Microsoft Store. In the Store, each distribution maintainer creates and updates their own WSL packages. You will typically find the latest distribution from the maintainer in the Store.

  2. Then, for a while, Microsoft provided a list of URL's for several distribution's rootfs packages that you could download and wsl --import. That list does not appear to exist any longer, but the download location seems to be what is used by wsl --install.

  3. Now, Microsoft provides a list of Appx package links on the page I mentioned above.

Now here's the frustrating thing -- All three of those methods can result in a different version being installed. They are, unfortunately, not linked, synced, or coordinated.

For instance:

  • Installing Debian via (1) or (3) will result in a Bullseye installation, but installing via wsl --install, as you point out, uses a drastically outdated rootfs resulting in Stretch.

  • Installing Kali via (1) results in the latest. However, (2) and (3) both install 2019.02. This release is so ancient that the keys have expired and there is no easy way to even update the distribution after installation.

I just ran through each of these scenarios on a fresh Windows 11/WSL installation to confirm that it is still the case.

So, for Debian, at least, you can install via method (1) or (3) and obtain Bullseye.

2

Even an upgraded version exists in the Microsoft Store and we already have a prior version installed, the upgraded version will not upgrade the installed one, but only appear the open option on the button. Strangely, the installed version will show the same version, e.g. Debian version 1.14.00 but actually is the VERSION="9 (Stretch)". The solution is uninstall from the Installed applications first and then reinstall from the Microsoft Store. After doing this we will have the same version Debian version 1.14.00, but with the VERSION="11 (bullseye)". It seems that Microsoft Store doesn't properly upgrade to the VERSION_CODENAME, but only the information of the latest project version without upgrade it, unfortunately.

Edit: As stated by @NotTheDr01ds this will remove all the data, so only do this if it isn't necessary to keep them.

5
  • Welcome SU @BDisp :) It's weird if one have to uninstall first. Doing so, are customisations kept?
    – gildux
    Commented Feb 3, 2023 at 0:14
  • 3
    Use caution - Uninstalling some older WSL distributions from the Store will also remove the files inside the distribution (and from your answer, it sounds like the older Debian is). Newer WSL distributions have changed the uninstaller to no longer remove the files, so this won't work in all cases. But in general you don't want to remove all your files just to upgrade. See my answer to a similar question on Ask Ubuntu for why upgrading the Store version doesn't also upgrade the distribution (this is by design). Commented Feb 3, 2023 at 14:16
  • 2
    Also this answer - It comes up quite often. Commented Feb 3, 2023 at 14:16
  • Thanks @gildux. No I haven't, sorry.
    – BDisp
    Commented Feb 3, 2023 at 17:39
  • 1
    Thanks for the clarification @NotTheDr01ds and for show me there are another ways to resolve this. I edited my post to alert for the consequences by uninstall and install.
    – BDisp
    Commented Feb 3, 2023 at 17:42
0

the instruction to update a stand alone Debian 11 to 12 work in WSL too: https://www.cyberciti.biz/faq/update-upgrade-debian-11-to-debian-12-bookworm/ just tested

0

I've always upgraded my WSL distros the same way I upgrade them on regular installs, following more or less the official debian upgrade docs (taking some shortcuts as I know I can skip some bits in my specific case).

One caveat though, when upgrading a WSL1 distro from bullseye to bookworm, I ran into an issue with the usrmerge package that merges directories between / and /usr. WSL1 runs as a Linux implementation on top of the NT microkernel (which was designed from the beginning to be OS-agnostic), and so the files live on the native NTFS filesystem and Linux processes runs as native NT (but not Win32) processes.

Just like it's often impossible to rename open files on Windows, replacing /lib with a symlink to /usr/lib failed with a Permission Denied error. See for example:

https://github.com/microsoft/WSL/issues/8927 https://github.com/microsoft/WSL/issues/4279#issuecomment-1846822075

Luckily I had the error only with the /lib directory, which means it only failed to move away /lib to replace it with a symlink to /usr/lib.

The steps I used to fix it are as follow. Note that for Windows commands you shouldn't need an admin cmd prompt, but on Linux you will need to use sudo or a root shell.

  1. Ensure you can start a new shell to Debian. Just start a new shell without closing the current one; the next steps involve shutting down WSL so if this fails you likely won't be able to resume the install after that.

  2. From Debian, create a symlink to /usr/lib with a different name (creating files from windows doesn't set UNIX attributes, but moving them is OK so we'll move it from Windows later).

    sudo ln -s /usr/lib /lib-new
    
  3. Close all shells and processes that may be running on Debian.

  4. From Windows command prompt, ensure WSL1 is shutdown using the following command; it should not list your distribution (if it keeps running after a couple minutes, try shutting it down using the wsl tool or reboot the computer).

    wsl -l --running
    
  5. Go to your distro root, the path should be something like %LOCALAPPDATA%\Packages\TheDebianProject.DebianGNULinux_<RANDOM_STRING>\LocalState\rootfs

  6. Using dir you should see lib and lib-new. Swap them around.

    ren lib lib-old
    ren lib-new lib
    
  7. Restart the Debian shell

  8. From Debian, re-run apt upgrade (or full-upgrade, in my case it happened in the first pass, a normal upgrade).

    sudo apt upgrade
    
  9. You can do this before step 8 or later, you will have to clean-up the lib-old directory.

    sudo rm -rf /lib-old
    

The same steps should work for other directories too. For files, if any fail, a simple move should do, although it may be best checking /usr/lib/usrmerge/convert-usrmerge and see what it was trying to do first (In my case I made a copy to /tmp which I modified, adding more debug output to ensure I got a good understanding of the error).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .