从 Debian 12 (Bookworm) 升级到 Debian 13 (Trixie) —— 服务器安全升级指南
Debian 13「Trixie」自2025年8月9日起作为稳定版本发布,首个小版本13.1于2025年9月6日发布。新版本在安全性、性能和软件包支持方面带来了重要改进。
准备工作:你事先需要做的事
顺利的升级始于几项检查,以避免出现故障。
备份: 通过我们的 Web 界面创建一份完整的服务器备份——简单又快捷。
更新系统: 将 Debian 12 更新到最新状态。
sudo apt update sudo apt full-upgrade -y sudo systemctl --failed解除软件包锁定: 被锁定(hold)的软件包可能会阻塞升级。
apt-mark showhold sudo apt-mark unhold <paketname> # 如有需要暂停第三方源: 将第三方软件源(例如 Docker、MariaDB)注释掉。
ls -1 /etc/apt/sources.list /etc/apt/sources.list.d/* 2>/dev/null grep -Rhs "deb " /etc/apt/sources.list{,.d/*} | nl控制台访问: 确保 SSH 访问可用(例如通过 IPMI)。使用 screen 以提高稳定性。
提示: 请规划一个维护窗口——需要重启系统。
分步指南:如何完成升级
通过以下步骤,你可以安全地切换到 Trixie。
调整 APT 源: 将「bookworm」替换为「trixie」。
sudo nano /etc/apt/sources.list示例内容:
deb http://deb.debian.org/debian/ trixie main non-free-firmware deb http://security.debian.org/debian-security trixie-security main non-free-firmware deb http://deb.debian.org/debian/ trixie-updates main non-free-firmware另一种方式(现代格式):
sudo nano /etc/apt/sources.list.d/debian.sources内容:
Types: deb URIs: http://deb.debian.org/debian/ Suites: trixie trixie-updates Components: main non-free-firmware Types: deb URIs: http://security.debian.org/debian-security Suites: trixie-security Components: main non-free-firmware更新软件包索引并执行最小化升级:
sudo apt update sudo apt upgrade --without-new-pkgs -y开始发行版升级:
sudo apt full-upgrade -y仔细检查配置提示(例如 sshd_config)。
重启并测试:
sudo reboot之后:
cat /etc/os-release uname -r systemctl --failed journalctl -p 3 -xb # 错误日志
后续工作:保持系统稳定
升级完成后,你需要确保系统的稳定性。
清理遗留文件:
sudo apt autoremove --purge -y sudo dpkg -l | awk '/^rc/{print $2}' | xargs -r sudo apt purge -y检查服务:
- Web 服务器:PHP-FPM、模块、配置文件。
- 数据库:MariaDB/PostgreSQL——是否需要升级?
- 容器:Docker/Podman、网络。
- 安全:fail2ban、nftables、unattended-upgrades。
重新启用第三方源: 仅启用与 Trixie 兼容的软件源,然后执行:
sudo apt update sudo apt full-upgrade -y
提示: 查看发行说明,了解已废弃的软件包(例如 fcitx4)。
常见问题与解决方法
- 第三方源冲突: 提前将其禁用。
- 被搁置(kept-back)的软件包: 使用以下命令分析:
sudo apt -o Debug::pkgProblemResolver=yes full-upgrade - 启动问题: 重新生成 GRUB/Initramfs:
sudo update-initramfs -u -k all sudo update-grub - 过时的软件包: 请查看发行说明中的列表。