Skip to content

Instantly share code, notes, and snippets.

@yorickdowne
Last active April 25, 2025 02:04
Show Gist options
  • Save yorickdowne/3cecc7b424ce241b173510e36754af47 to your computer and use it in GitHub Desktop.
Save yorickdowne/3cecc7b424ce241b173510e36754af47 to your computer and use it in GitHub Desktop.
Debian 13 trixie upgrade

Debian 13

This is a placeholder for instructions when Debian 13 is released in August 2025

To start, read the official release notes.

If your install fits into "vanilla Debian plus maybe a handful of 3rd-party repos", then this guide for a simple upgrade to Debian 13 "trixie" from Debian 12 "bookworm" can be helpful. 3rd-party repos are handled with a find command.

Note upgrade is only supported from Debian 12 to Debian 13. If you are on Debian 11, upgrade to Debian 12 first. Then once on Debian 12, you can upgrade to Debian 13.

  • Check free disk space

df -h

5 GiB free is a conservative amount. sudo apt clean and sudo apt autoremove can be used to free some disk space.

On a server with only docker installed, even 1 GiB free was sufficient. Do err on the side of caution here, however.

  • Identify any 3rd-party repos that may need to be updated. They'll be changed with a find command, below.

ls /etc/apt/sources.list.d

  • Update current distribution

sudo apt-get update && sudo apt-get dist-upgrade --autoremove -y

If this brought in a new kernel, sudo reboot - otherwise continue

  • Change repo to trixie, from bookworm.
sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list
  • Change all 3rd-party repos

This assumes the repos have trixie versions, which should be the case after trixie release. If you're updating to trixie before release, run sudo apt-get update after changing everything to trixie with the below, then manually revert repos to bookworm that do not have a trixie release yet

sudo find /etc/apt/sources.list.d -type f -exec sed -i 's/bookworm/trixie/g' {} \;
  • Update Debian

For the following, say Yes to restarting services, and keep existing config files when prompted.

sudo apt-get update && sudo apt-get dist-upgrade --autoremove -y

And finally, reboot

sudo reboot

  • Modernize Debian sources

Optional but recommended: Switch to deb822 format for the sources.list. This will write /etc/apt/sources.list.d/debian.sources and /etc/apt/sources.list.d/debian-backports.sources

sudo apt modernize-sources

Caveat that trixie-backports won't have a Signed-By until trixie has been released. You can fix this by manually setting Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg in /etc/apt/sources.list.d/debian-backports.sources

Automated by Ansible

Config ansible.cfg:

[defaults]
interpreter_python = /usr/bin/python3

Playbook trixie.yml:

---
- name: Upgrade to Debian trixie
  hosts: all
  serial: 1
  gather_facts: false
  roles:
    - base/upgrade_trixie

Role base/upgrade_trixie/tasks/main.yml:

---
- name: Get distribution version
  setup:
    filter: ansible_distribution*
- name: Skip if not Debian 12
  meta: end_host
  when: ansible_distribution != 'Debian' or ansible_distribution_major_version != '12'
- name: apt clean
  apt:
    clean: yes
  become: yes
- name: Get filesystem facts
  setup:
    filter: ansible_mounts
- name: Fail if free space on / is below 5 GiB
  ansible.builtin.assert:
    that:
      - item.size_available > (5 * 1024 * 1024 * 1024)
    fail_msg: "Free disk space on {{ item.mount }} is below 5 GiB"
  loop: "{{ ansible_mounts }}"
  when: item.mount == "/"
- name: All apt packages up to date
  apt:
    upgrade: dist
    update_cache: yes
  become: yes
- name: apt autoremove
  apt:
    autoremove: yes
  become: yes
- name: apt clean
  apt:
    clean: yes
  become: yes
- name: Check if reboot required
  ansible.builtin.stat:
    path: /run/reboot-required
    get_checksum: no
  register: reboot_required_file
- name: Reboot if required
  ansible.builtin.reboot:
    msg: "Reboot initiated by Ansible"
    connect_timeout: 5
    reboot_timeout: 600
    pre_reboot_delay: 0
    post_reboot_delay: 60
    test_command: whoami
  when: reboot_required_file.stat.exists
  become: true
- name: Switch OS from bookworm to trixie
  ansible.builtin.replace:
    path: /etc/apt/sources.list
    regexp: 'bookworm'
    replace: 'trixie'
  become: yes
- name: Find all 3rd-party repos
  ansible.builtin.find:
    paths: /etc/apt/sources.list.d
    patterns: '*'
    recurse: no
  register: third_party_repos
- name: Switch 3rd-party repos from bookworm to trixie
  ansible.builtin.replace:
    path: "{{ item.path }}"
    regexp: 'bookworm'
    replace: 'trixie'
  loop: "{{ third_party_repos.files }}"
  loop_control:
    label: "{{ item.path }}"
  become: yes 
- name: Use apt to move to trixie
  apt:
    upgrade: dist
    update_cache: yes
  become: yes
- name: Get distribution version
  setup:
    filter: ansible_distribution*
- name: Fail if not Debian 13
  assert:
    that:
      - ansible_distribution_major_version == '13'
    fail_msg: "Upgrade to Debian 13 failed"
- name: apt autoremove
  apt:
    autoremove: yes
  become: yes
- name: apt clean
  apt:
    clean: yes
  become: yes
- name: Reboot on trixie
  ansible.builtin.reboot:
    msg: "Reboot initiated by Ansible"
    connect_timeout: 5
    reboot_timeout: 600
    pre_reboot_delay: 0
    post_reboot_delay: 60
    test_command: whoami
  become: yes
- name: Modernize apt sources
  ansible.builtin.command:
    cmd: apt -y modernize-sources
  become: yes
- name: Pause for 5 minutes for staggered upgrades
  pause:
    minutes: 5
@Lumipyry
Copy link

Lumipyry commented Oct 9, 2024

I can confirm that these instructions work. Thank you, @yorickdowne.

neofetch

The shell is zsh with oh-my-zsh framework and pokemon-colorscripts - if someone wonders.

I have also fully working Hyprland desktop - Installed with this wonderful automated script

@earthwlove
Copy link

Thank you!

@earthwlove
Copy link

In addition, PPA users must remove their PPA repositories before the update, or It will never happen xDD

@GhostInRags
Copy link

Good insight about PPA, earther. Trixie method 100% works, running 2 Chromebooks on her from this guide. Like a champ. I "upgraded" my media center from full blown Win 11 PC to my little HP Chromebook. A few Linux apps, Kodi, some emulators... don\t need much. And Trix does seem to make an actual difference you can "feel". Great job OP, you rock.

@yorickdowne
Copy link
Author

You guys are adventurous :). 3rd-party PPAs will work, but they might not have trixie versions yet. You can test that with sudo apt-get update, and then manually revert those repos that don't have trixie yet, back to bookworm. They should work on trixie regardless.

For example, as of today, docker-ce does not have a trixie version, yet. Some of my other PPAs do.

@yorickdowne
Copy link
Author

yorickdowne commented Feb 20, 2025

A note about locales: Some versions of the pre-release trixie updater may leave you without locales files. That's a bug. To fix this:

sudo apt-get purge locales
sudo apt install locales
sudo dpkg-reconfigure locales

And tell it to recreate all locales files.

That resolves complaints that locales files are missing.

@Louisbuitton
Copy link

I cant update now. Can you help?
https://imgur.com/a/DdV8ZE5

@yorickdowne
Copy link
Author

It tells you what’s going on: It’s a read only file system. This can happen with hardware issues or file system corruption, for example. Nothing to do with updating; fix your file system. If you’re unsure how, find a Debian support group.

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