Categories
Informatique

How to Upgrade Debian 12 to Debian 13 (Trixie) – Step-by-Step Guide

Looking to upgrade your system from Debian 12 Bookworm to the latest Debian 13 Trixie? This step-by-step tutorial will guide you through a safe and efficient upgrade process. Perfect for servers and desktop environments, this guide ensures minimal downtime and maximum system stability.

At the end of the post, we are providing you with a script that does the heavy lifting for you.

⚠️ Prerequisites Before You Upgrade Debian 12 to Debian 13

  • Ensure your system is fully updated on Debian 12.
  • Backup all critical data and configuration files to an independent storage system
  • Make sure to have enough free space on your drive
  • Have root (sudo) access to the system.
  • Check if your software and services are compatible with Debian 13.

🛠 Step 1: Update Current Debian 12 Packages

First, make sure your system is fully up to date before upgrading Debian 12 to Debian 13

sudo apt update && sudo apt upgrade -y
sudo apt full-upgrade -y
sudo apt autoremove --purge -y

🧰 Step 2: Update APT Sources to Debian 13 (Trixie)

Replace all mentions of bookworm with trixie in your APT sources.

sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list

If you’re using additional APT repositories (e.g., Docker, NodeSource), update those as well.

📦 Step 3: Update Package Lists and Start Upgrade

Now update the package index to fetch Debian 13 packages:

sudo apt update

Begin the minimal upgrade process first:

sudo apt upgrade --without-new-pkgs

Then complete the full system upgrade:

sudo apt full-upgrade

🔁 Step 4: Reboot Into Debian 13

Once the upgrade is done, reboot your system to apply changes:

sudo reboot

✅ Step 5: Verify Debian Version

After rebooting, confirm you are now running Debian 13:

cat /etc/os-release

You should see something like which means you’ve finished your upgrade from Debian 12 to Debian 13.

PRETTY_NAME="Debian GNU/Linux 13 (trixie)"

🔒 Optional: Clean Up Old Packages

Remove any unused dependencies or leftover configuration files:

sudo apt autoremove --purge
sudo apt clean

🚨 Troubleshooting Tips

  • If the upgrade fails, check /var/log/apt/term.log for errors.
  • Make sure you have enough disk space before upgrading.
  • Use apt list --upgradable to identify remaining outdated packages.

📌 Final Thoughts

Upgrading from Debian 12 to Debian 13 is a straightforward process if you follow best practices. Always back up your system, review APT source files carefully, and verify software compatibility before proceeding.

For advanced users, you can also automate this process using Ansible or scripts especially useful in managing multiple Debian systems.

Have questions or encountered issues? Drop a comment below or join the Debian community forums for support!

The script

#!/bin/bash

set -e

echo "🟡 Upgrading Debian 12 to Debian 13 (Trixie)"

# 1. Check for root privileges
if [ "$(id -u)" -ne 0 ]; then
  echo "❌ This script must be run as root."
  exit 1
fi

# 2. Show current version
echo "📦 Current OS version:"
cat /etc/os-release

# 3. Fully upgrade Debian 12 first
echo "🔄 Updating current Debian 12 system..."
apt update && apt upgrade -y && apt full-upgrade -y
apt autoremove --purge -y

# 4. Backup sources.list
echo "💾 Backing up /etc/apt/sources.list"
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 5. Replace 'bookworm' with 'trixie' in APT sources
echo "✏️ Updating APT sources to Debian 13 (Trixie)"
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list

# 6. Update package list
echo "🆕 Updating package list (Trixie)..."
apt update

# 7. Remove docker-compose-plugin to avoid conflict
if dpkg -l | grep -q docker-compose-plugin; then
  echo "🚫 Removing docker-compose-plugin (known conflict)"
  dpkg --remove docker-compose-plugin || true
fi

# 8. Minimal upgrade to prevent crashes
echo "🧩 Performing partial upgrade without new packages..."
apt upgrade --without-new-pkgs -y

# 9. Full upgrade
echo "⚙️ Performing full upgrade..."
apt full-upgrade -y

# 10. Cleanup and fix broken dependencies
echo "🧼 Cleaning up..."
apt -f install -y
apt autoremove --purge -y
apt clean

# 11. Show final version
echo "✅ OS version after upgrade:"
cat /etc/os-release

# 12. Reboot prompt
read -p "🔁 Reboot now? [y/N] " REBOOT
if [[ "$REBOOT" =~ ^[Yy]$ ]]; then
  reboot
else
  echo "ℹ️ Please reboot manually later."
fi

Is it safe to upgrade from Debian 12 to Debian 13?

Yes, as long as you fully update your system, back up your data, and follow the upgrade steps, upgrading to Debian 13 (Trixie) is safe and stable.

What command upgrades Debian 12 to Debian 13?

You must replace ‘bookworm’ with ‘trixie’ in /etc/apt/sources.list, then run: apt update && apt full-upgrade. A reboot is required afterwards.

What if APT is broken after editing sources.list?

If you see symbol lookup errors or APT fails to fetch updates, manually install the required .deb libraries using dpkg and then run apt -f install to fix dependencies.

Do I need to reboot after upgrading to Debian 13?

Yes, a reboot is required to load the new kernel and finalize the upgrade process.

How long does the upgrade from Debian 12 to 13 take?

On average, the full upgrade takes 10 to 30 minutes depending on your system and connection speed.

Leave a Reply