Skip to content

Instantly share code, notes, and snippets.

@bramtechs
Last active February 19, 2025 15:56
Show Gist options
  • Save bramtechs/50d724a33d37278d7ca003c6119c8fea to your computer and use it in GitHub Desktop.
Save bramtechs/50d724a33d37278d7ca003c6119c8fea to your computer and use it in GitHub Desktop.
Add Debian 12 to 13 contribution

Upgrade Debian 9 (current WSL) to Debian 12 (bookworm testing)

Note: I do not maintain this gist anymore, but people report that it still works. Please check the comments for any revisions or extra things you should take into consideration.

As of writing, the Debian distro for WSL (Windows Subsystem for Linux) is quite old.

You can get more up-to-date package managers, text-editors and compilers by upgrading WSL to Debian 12 (current testing).

  • Root required
  • Use at your own risk, preferably on a fresh installation.
  • Choose 'yes' when Debian requests to restart services.
  1. Install and open Debian on WSL (if not already)
wsl --install -d debian
wsl -d debian
  1. Go into root
sudo -s
  1. Upgrade Debian 9 to 10
apt update -y && \
apt upgrade -y && \
echo "deb http://deb.debian.org/debian/ buster main
deb http://deb.debian.org/debian/ buster-updates main
deb http://security.debian.org/debian-security buster/updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y
  1. Upgrade Debian 10 to 11
echo "deb http://deb.debian.org/debian/ bullseye main
deb http://deb.debian.org/debian/ bullseye-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y
  1. Debian 11 to 12
echo "deb http://deb.debian.org/debian/ bookworm main
deb http://deb.debian.org/debian/ bookworm-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt autoremove -y && \
exit
  1. Debian 12 to 13 (provided by MarkusGnigler)
echo "deb http://deb.debian.org/debian/ trixie main
deb http://deb.debian.org/debian/ trixie-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt autoremove -y && \
exit
@ravensorrow
Copy link

worked great, however only in WSL2 mode. When it is WSL1, usrmerge fails. This can be fixed via wsl --set-version Debian 2 After the install you can change it back if you need WSL for some reason (serial ports for example)

Why are you switching back and forth between WSL.v1 and WSL.v2? Why not just commit to migrating your instance(s) to v2 and staying there?

  • Did you define the serial ports in your udev rules? If you did that in WSL.v1, then the migration to WSLv.2 should resolve any complications that arise out of those ports not working as intended from inside of your WSL.v2 container.

@trogper
Copy link

trogper commented Mar 23, 2024

worked great, however only in WSL2 mode. When it is WSL1, usrmerge fails. This can be fixed via wsl --set-version Debian 2 After the install you can change it back if you need WSL for some reason (serial ports for example)

You do not need to switch to WSL2. As zhangboyang described the issue here:

wsl --shutdown
wsl -u root
apt upgrade # or apt install usrmerge

@avecheria
Copy link

Upgrade still works fine, thanks!

@damienxp6
Copy link

I think adding the following line on step 5 is a good idea :
deb http://security.debian.org/debian-security bookworm-security main

@MarkusGnigler
Copy link

Debian 12 to 13:

echo "deb http://deb.debian.org/debian/ trixie main
deb http://deb.debian.org/debian/ trixie-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt autoremove -y && \
exit

@ravensorrow
Copy link

Debian 12 to 13:

echo "deb http://deb.debian.org/debian/ trixie main
deb http://deb.debian.org/debian/ trixie-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt autoremove -y && \
exit

This fails when it gets to processing triggers for systems and comes to a crashing halt.

Processing triggers for systemd (252.31-1~deb12u1) ...
Failed to retrieve unit state: Transport endpoint is not connected
Failed to try-restart systemd-binfmt.service: Transport endpoint is not connected
See system logs and 'systemctl status systemd-binfmt.service' for details.
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for tex-common (6.18) ...
Running mutexes. This may take some time... done.
Processing triggers for dbus (1.14.10-1~deb12u1) ...
Processing triggers for sgml-base (1.31) ...
Processing triggers for install-info (6.8-6+b1) ...
Processing triggers for base-files (13.6) ...
Processing triggers for fontconfig (2.14.1-4) ...
Processing triggers for desktop-file-utils (0.26-1) ...
Setting up docbook-xml (4.5-13) ...
Setting up docbook5-xml (5.0-4) ...
Setting up lintian (2.121.1) ...
Setting up docbook-to-man (1:2.0.0-47) ...
Setting up docbook-xsl (1.79.2+dfsg-7) ...
Setting up docbook-xsl-ns (1.79.2+dfsg-7) ...
Processing triggers for sgml-base (1.31) ...
Setting up docbook-website (2.5.0.0-10) ...
Setting up docbook-ebnf (1.2~cr1-8) ...
Processing triggers for ca-certificates (20241223) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
Processing triggers for sgml-base (1.31) ...
Processing triggers for ca-certificates-java (20240118) ...
done.
Errors were encountered while processing:
 dict-wn
Error: Timeout was reached
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@BOHEMUTH-II:/etc/apt/sources.list.d# 

@ravensorrow
Copy link

Debian 12 to 13:

echo "deb http://deb.debian.org/debian/ trixie main
deb http://deb.debian.org/debian/ trixie-updates main" > /etc/apt/sources.list && \
apt update -y && \
apt upgrade -y && \
apt dist-upgrade -y && \
apt autoremove -y && \
exit

This fails when it gets to processing triggers for systems and comes to a crashing halt.

nvm, I fixed it. Rebooted WSL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment