Debian 12 Bookworm 升级 Debian 13 Trixie

本文将手把手指导如何升级 Debian 12 Bookworm 到 Debian 13 Trixie

不建议跨大版本升级,Debian 11 Bullseye 升级 Debian 12 Bookworm, 其他版本也是类似,如果机器配置足够低,推荐 Debian 10 养老

准备工作

操作前,重要数据先备份,默认使用 root 操作

  • 不支持 LXC
  • Debian 12
  • root 用户

更新系统

先更新系统,更新到最新版本

apt update
apt upgrade -y
apt autoclean
apt autoremove -y

升级系统

在升级前,先说一下镜像源文件的变化。

之前版本的 Debian 软件源配置文件使用传统的 One-Line-Style,路径为 /etc/apt/sources.list;但是从 Debian 12 的容器版本开始,以及 Debian 13 正式版后,其软件源配置文件变更为 DEB822 格式,路径为 /etc/apt/sources.list.d/debian.sources

推荐使用新的软件源配置文件 DEB822 格式, 然后安全的删除 /etc/apt/sources.list, 当然目前使用老格式也是没问题的。

源示例对比

两者保留其一即可

Debian 13 /etc/apt/sources.list

deb http://mirrors.tencent.com/debian/ trixie main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian/ trixie-updates main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian/ trixie-backports main contrib non-free non-free-firmware
deb http://mirrors.tencent.com/debian-security trixie-security main contrib non-free non-free-firmware

Debian 13 /etc/apt/sources.list.d/debian.sources

Types: deb
URIs: http://mirrors.tencent.com/debian
Suites: trixie trixie-updates trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: http://mirrors.tencent.com/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

升级系统

根据自己的实际情况,操作

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

如果有错误提示文件或目录不存在,忽略即可。

apt update
apt upgrade -y
apt full-upgrade -y
# 在升级完成没报错后执行,也可以在reboot后执行
apt autoclean
apt autoremove -y

reboot

更新过程中,用 Debian 都知道的

  • 更新过程种会提示一些软件是否需要自动重启,选 Yes 即可,以及一些软件的配置文件是否需要更新,按照自己的情况选择即可,默认回车即视为使用旧的配置文件
  • 另外有些软件会提示是否变更配置, 默认选择 keep the local version 即可

确定查看系统版本

root@service:~$ cat /etc/debian_version
13.0

确定查看系统版本

# 升级后重启前
root@service:~$ uname -a
Linux service 6.6.13+bpo-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.6.13-1~bpo12+1 (2024-02-15) x86_64 GNU/Linux
# 升级重启后
root@service:~$ uname -a
Linux service 6.12.38+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.38-1 (2025-07-16) x86_64 GNU/Linux

Chapters

Sponsor

Like this article? $1 reward

Comments