跳转到内容

从 Debian 12 (Bookworm) 升级到 Debian 13 (Trixie)

教程与指南  ·   ·   ·  更新于  ·  2 分钟 阅读时间

从 Debian 12 (Bookworm) 升级到 Debian 13 (Trixie) —— 服务器安全升级指南

Debian 13「Trixie」自2025年8月9日起作为稳定版本发布,首个小版本13.1于2025年9月6日发布。新版本在安全性、性能和软件包支持方面带来了重要改进。

准备工作:你事先需要做的事

顺利的升级始于几项检查,以避免出现故障。

  1. 备份: 通过我们的 Web 界面创建一份完整的服务器备份——简单又快捷。

  2. 更新系统: 将 Debian 12 更新到最新状态。

    sudo apt update
    sudo apt full-upgrade -y
    sudo systemctl --failed
    
  3. 解除软件包锁定: 被锁定(hold)的软件包可能会阻塞升级。

    apt-mark showhold
    sudo apt-mark unhold <paketname>  # 如有需要
    
  4. 暂停第三方源: 将第三方软件源(例如 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
    
  5. 控制台访问: 确保 SSH 访问可用(例如通过 IPMI)。使用 screen 以提高稳定性。

提示: 请规划一个维护窗口——需要重启系统。


分步指南:如何完成升级

通过以下步骤,你可以安全地切换到 Trixie。

  1. 调整 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
    
  2. 更新软件包索引并执行最小化升级:

    sudo apt update
    sudo apt upgrade --without-new-pkgs -y
    
  3. 开始发行版升级:

    sudo apt full-upgrade -y
    

    仔细检查配置提示(例如 sshd_config)。

  4. 重启并测试:

    sudo reboot
    

    之后:

    cat /etc/os-release
    uname -r
    systemctl --failed
    journalctl -p 3 -xb  # 错误日志
    

后续工作:保持系统稳定

升级完成后,你需要确保系统的稳定性。

  1. 清理遗留文件:

    sudo apt autoremove --purge -y
    sudo dpkg -l | awk '/^rc/{print $2}' | xargs -r sudo apt purge -y
    
  2. 检查服务:

    • Web 服务器:PHP-FPM、模块、配置文件。
    • 数据库:MariaDB/PostgreSQL——是否需要升级?
    • 容器:Docker/Podman、网络。
    • 安全:fail2ban、nftables、unattended-upgrades。
  3. 重新启用第三方源: 仅启用与 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
    
  • 过时的软件包: 请查看发行说明中的列表。

常见问题

Debian 13「Trixie」是什么时候发布的?
Debian 13「Trixie」自2025年8月9日起作为稳定版本发布,首个小版本13.1于2025年9月6日发布。
升级前需要做哪些准备?
创建完整的服务器备份、将 Debian 12 更新到最新状态、解除被锁定(hold)的软件包、暂停第三方软件源,并确保有可用的控制台访问(例如通过 IPMI)。
升级完成后应该检查什么?
清理遗留的软件包,检查 Web 服务器、数据库、容器以及 fail2ban、nftables 等安全服务是否正常运行,并重新启用与 Trixie 兼容的第三方软件源。
Prepaid-Host.com 本身即为服务器、虚拟主机与域名服务商,在此报道的正是自己所处的市场。我们如何处理这一点,见利益披露说明