Skip to content

Instantly share code, notes, and snippets.

@bramtechs
Last active April 30, 2024 21:45
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
  • Save bramtechs/50d724a33d37278d7ca003c6119c8fea to your computer and use it in GitHub Desktop.
Save bramtechs/50d724a33d37278d7ca003c6119c8fea to your computer and use it in GitHub Desktop.
Upgrade Debian 9, (current WSL) to Debian 12 (bookworm testing)

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
@LamerManuel
Copy link

Thanks for sharing this post, worked out wonderfully.

@xemoe
Copy link

xemoe commented Jun 24, 2023

Thank you

@BeatTime
Copy link

I think we need to add a step to change the original /etc/apt/sources.list before step 3.

sudo sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list
sudo sed -i 's|security.debian.org|archive.debian.org/debian-security/|g' /etc/apt/sources.list
sudo sed -i '/stretch-updates/d' /etc/apt/sources.list 

Reference:
repository - Debian stretch repositories 404 Not Found - Stack Overflow

@bosattam
Copy link

thanks!

@ravensorrow
Copy link

ravensorrow commented Aug 22, 2023

I've done something like this as far as organizing versions

grunk@BOHEMUTH-II:~$ ls -lash /etc/apt/sources.list.d/
total 20K
4.0K drwxr-xr-x 2 root root 4.0K Aug 22 16:01 .
4.0K drwxr-xr-x 8 root root 4.0K Aug 22 15:58 ..
4.0K -rw-r--r-- 1 root root 167 Aug 22 16:01 10.buster_sources.list
4.0K -rw-r--r-- 1 root root 104 Aug 22 16:00 11.bullseye_sources.list
4.0K -rw-r--r-- 1 root root 104 Aug 22 15:56 12.bookworm_sources.list
grunk@BOHEMUTH-II:~$

@hchybz
Copy link

hchybz commented Sep 10, 2023

efficient, many thanks

@ef-klukacs
Copy link

Thanks for sharing this.. worked well for me

@cl0rm
Copy link

cl0rm commented Dec 16, 2023

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)

@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 zhangboyangdescribed the issue here:

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

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