前提条件

当前系统为 Debian 12并且升级到最新,计划升级到 Debian 13。

注意事项

步骤 1:

apt list '?narrow(?installed, ?not(?origin(Debian)))'

筛选出非 Debian 源的包。如果有问题包,考虑移除或更新其源。

步骤 2:

sudo ls -l /etc/apt

检查 APT 配置目录的权限和文件列表。确认 sources.list 等文件是否存在且权限正确。

步骤 3:

sudo nano /etc/apt/sources.list

删掉所有内容,我习惯注释一下: # see debian.sources

步骤 4:

sudo nano /etc/apt/sources.list.d/debian.sources

并输入

Types: debURIs: https://deb.debian.org/debianSuites: trixie trixie-updatesComponents: main non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpgTypes: debURIs: https://security.debian.org/debian-securitySuites: trixie-securityComponents: main non-free-firmwareSigned-By: /usr/share/keyrings/debian-archive-keyring.gpg

用官方源。需要用其他源可以自行替换。

步骤 5:

/etc/apt/sources.list.d/ 下的其他源的内容先注释掉。因为很多源没有更新 trixie,改了报错不好看。

步骤 6(可选,一般不用):

sudo mount -o remount,rw /mountpoint

如果系统挂载点(如根分区)为只读模式,运行此命令使其可写。替换 /mountpoint 为实际挂载点。

步骤 7:

sudo apt update

从新源刷新可用软件包列表。如果有错误,检查源配置。

步骤 8:

sudo apt upgrade --without-new-pkgs

执行安全升级,仅更新现有包而不引入新依赖。最小化风险,避免因新包导致的冲突。

步骤 9:

sudo apt full-upgrade

完全升级系统,包括安装新包、移除冲突包。

步骤 10:

sudo apt autoremove

清理不再需要的依赖包。

步骤 11:

apt list '~o'

列出所有过时的(obsolete)软件包,这些包在新版本中可能已不可用。检查列表,决定是否需要手动处理。

步骤 12:

sudo apt purge '~o'

彻底移除过时包及其配置文件。使用 '~o' 模式匹配所有过时包。确认后执行。

步骤 13:

lsb_release -a

确认已升级到 Debian 13。

步骤 14:

/etc/apt/sources.list.d/ 里之前注释的内容取消注释,并把里面所有的 bookworm 改成 trixie。