如何升级到 Debian 13 Trixie
这几天正好赶上 Debian 13 Trixie 版本发行,为了尝试一下新版本的一些新功能,便在此记录一下升级的流程。
不建议生产环境升级 Trixie,截至文章撰写时间还是测试版(testing)
升级前准备工作
备份重要数据
# 备份重要配置文件
sudo cp -r /etc /root/backup-etc-$(date +%Y%m%d)
sudo cp -r /home /root/backup-home-$(date +%Y%m%d)
# 备份包列表
dpkg --get-selections > /root/packages-backup-$(date +%Y%m%d).txt
以上命令仅做举例,需要按照实际备份。如宝塔面板的网站目录/www/wwwroot
等等
检查当前系统状态
# 确认当前是 Debian 12
cat /etc/debian_version
lsb_release -a
# 更新当前系统到最新状态
sudo apt update && sudo apt upgrade -y
sudo apt autoremove -y
请确保当前系统是 Debian 12,若不是,请先升级到 Debian 12 再进行下一步升级
检查剩余空间
df -h
# 确保根分区至少有 5GB 以上空闲空间
开始升级
修改软件源
备份当前源列表:
若使用传统格式(
/etc/apt/sources.list
):bash sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup sudo cp -r /etc/apt/sources.list.d /etc/apt/sources.list.d.backup
若使用DEB822 格式(
/etc/apt/sources.list.d/debian.sources
):bash sudo cp /etc/apt/sources.list.d/debian.sources /etc/apt/sources.list.d/debian.sources.backup
在此,为了以后更好的兼容性我使用DEB822格式
- 更新源列表:
这里我使用清华源替换,在此为了加快更新速度,我启用源码源、使用非自由软件源并强制安全更新使用镜像。
不过,一般来说,为了更及时地获得安全更新,不推荐使用镜像站安全更新软件源,因为镜像站往往有同步延迟。
参考 https://www.debian.org/security/faq.en.html#mirror
> The purpose of security.debian.org is to make security updates available as quickly and easily as possible. > > Encouraging the use of unofficial mirrors would add extra complexity that is usually not needed and that can cause frustration if these mirrors are not kept up to date.
使用 nano
编辑源列表:
sudo nano /etc/apt/sources.list.d/debian.sources
将内容替换为:
Types: deb
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian
Suites: trixie trixie-updates trixie-backports
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
Types: deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/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: https://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb-src
URIs: https://mirrors.tuna.tsinghua.edu.cn/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
上面的源地址可能会有变更,请不要直接复制,而是参考debian | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror以获得最新更新。
执行升级
- 更新包索引:
sudo apt update
- 最小化升级:
sudo apt upgrade --without-new-pkgs -y
- 完整系统升级:
sudo apt full-upgrade -y
在升级过程中,可能会遇到配置文件冲突的提示,建议:
- 对于系统配置文件,选择保留当前版本 (N)
- 对于应用程序配置文件,可以查看差异后决定
重启系统
sudo reboot
验证升级结果
- 检查系统版本:
# 检查系统版本
cat /etc/debian_version
lsb_release -a
应输出:
➜ ~ cat /etc/debian_version
13.0
➜ ~ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 13 (trixie)
Release: 13
Codename: trixie
- 检查内核版本:
# 检查内核版本
uname -r
应输出:
➜ ~ uname -r
6.12.41+deb13-amd64
- 检查服务状态:
# 检查服务状态
sudo systemctl status
应输出:
➜ ~ sudo systemctl status
● C20250729201234
State: running
Units: 268 loaded (incl. loaded aliases)
Jobs: 0 queued
Failed: 0 units
Since: Sat 2025-08-30 10:08:53 CST; 42min ago
systemd: 257.7-1
以上输出是以我的机器举例,不能完全参考,类似即可
系统清理
清理不需要的包:
sudo apt autoremove -y
sudo apt autoclean
完成
至此已经成功升级到 Debian 13,可以用fastfetch
查看系统信息:
➜ ~ fastfetch
_,met$$$$$gg. root@C20250729201234
,g$$$$$$$$$$$$$$$P. --------------------
,g$$P"" """Y$$.". OS: Debian GNU/Linux 13 (trixie) x86_64
,$$P' `$$$. Host: KVM (RHEL 7.6.0 PC (i440FX + PIIX, 1996))
',$$P ,ggs. `$$b: Kernel: Linux 6.12.41+deb13-amd64
`d$$' ,$P"' . $$$ Uptime: 8 hours, 42 mins
$$P d$' , $$P Packages: 528 (dpkg)
$$: $$. - ,d$$' Shell: zsh 5.9
$$; Y$b._ _,d$P' Display (VGA-1): 1024x768 [External]
Y$$. `.`"Y$$$$P"' Terminal: /dev/pts/0
`$$b "-.__ CPU: Intel(R) Xeon(R) E5-2680 v4 (2) @ 2.40 GHz
`Y$$b GPU: Cirrus Logic GD 5446
`Y$$. Memory: 2.47 GiB / 3.83 GiB (65%)
`$$b. Swap: Disabled
`Y$$b. Disk (/): 10.05 GiB / 29.94 GiB (34%) - xfs
`"Y$b._ Local IP (eth0):
`"""" Locale: en_US.UTF-8
可以看到OS
已经变为Debian GNU/Linux 13 (trixie)
,Kernel
已经变为Linux 6.12.41