4. 从 Debian 12 (bookworm)升级

4.1. 升级前的准备

我们建议您在升级前阅读 trixie 中需要注意的问题 。它描述的潜在问题与升级过程没有直接联系,但您仍可能需要在开始前了解这些信息。

4.1.1. 备份数据和配置文件

Before upgrading your system, it is strongly recommended that you make a full backup, or at least back up any data or configuration information you can't afford to lose. The upgrade tools and process are quite reliable, but a hardware failure in the middle of an upgrade could result in a severely damaged system.

The main things you'll want to back up are the contents of /etc, /var/lib/dpkg, /var/lib/apt/extended_states and the output of:

$ dpkg --get-selections '*' # (the quotes are important)

If you use aptitude to manage packages on your system, you will also want to back up /var/lib/aptitude/pkgstates.

The upgrade process itself does not modify anything in the /home directory. However, some applications (e.g. parts of the Mozilla suite, and the GNOME and KDE desktop environments) are known to overwrite existing user settings with new defaults when a new version of the application is first started by a user. As a precaution, you may want to make a backup of the hidden files and directories ("dotfiles") in users' home directories. This backup may help to restore or recreate the old settings. You may also want to inform users about this.

Any package installation operation must be run with superuser privileges, so either log in as root or use su or sudo to gain the necessary access rights.

升级需要几个前提条件,您应当在实际升级前检查它们。

4.1.2. 提前告知用户

It's wise to inform all users in advance of any upgrades you're planning, although users accessing your system via an ssh connection should notice little during the upgrade, and should be able to continue working.

If you wish to take extra precautions, back up or unmount the /home partition before upgrading.

You will have to do a kernel upgrade when upgrading to trixie, so a reboot will be necessary. Typically, this will be done after the upgrade is finished.

4.1.3. 准备服务停机

系统提供的服务可能与升级包含的软件包相关联。如果存在这种情况,请注意,在升级期间,当相关软件包被更换和配置时,这些服务将被停止。在此期间,这些服务将无法使用。

The precise downtime for these services will vary depending on the number of packages being upgraded in the system, and it also includes the time the system administrator spends answering any configuration questions from package upgrades. Notice that if the upgrade process is left unattended and the system requests input during the upgrade there is a high possibility of services being unavailable 1 for a significant period of time.

If the system being upgraded provides critical services for your users or the network 2, you can reduce the downtime if you do a minimal system upgrade, as described in Minimal system upgrade, followed by a kernel upgrade and reboot, and then upgrade the packages associated with your critical services. Upgrade these packages prior to doing the full upgrade described in Upgrading the system. This way you can ensure that these critical services are running and available through the full upgrade process, and their downtime is reduced.

4.1.4. 准备故障恢复

Although Debian tries to ensure that your system stays bootable at all times, there is always a chance that you may experience problems rebooting your system after the upgrade. Known potential issues are documented in this and the next chapters of these Release Notes.

因此,当您的系统重启失败(或对于远程管理的系统来说,无法连接网络)时,请确保您能够将其恢复。

If you are upgrading remotely via an ssh link it is recommended that you take the necessary precautions to be able to access the server through a remote serial terminal. There is a chance that, after upgrading the kernel and rebooting, you will have to fix the system configuration through a local console. Also, if the system is rebooted accidentally in the middle of an upgrade there is a chance you will need to recover using a local console.

For emergency recovery we generally recommend using the rescue mode of the trixie Debian Installer. The advantage of using the installer is that you can choose between its many methods to find one that best suits your situation. For more information, please consult the section "Recovering a Broken System" in chapter 8 of the Installation Guide (at https://www.debian.org/releases/trixie/installmanual) and the Debian Installer FAQ.

如果上述步骤失败了,您需要采取替代方案来启动您的系统以便访问和修复它。其中一种选择是使用特制的急救或者 live install 镜像。以这些介质引导后,您应该可以挂载您的根文件系统并 chroot 到它里面来检查并修复问题。

4.1.4.1. initrd 引导时使用调试环境

The initramfs-tools package includes a debug shell 3 in the initrds it generates. If for example the initrd is unable to mount your root file system, you will be dropped into this debug shell which has basic commands available to help trace the problem and possibly fix it.

Basic things to check are: presence of correct device files in /dev; what modules are loaded (cat /proc/modules); output of dmesg for errors loading drivers. The output of dmesg will also show what device files have been assigned to which disks; you should check that against the output of echo $ROOT to make sure that the root file system is on the expected device.

If you do manage to fix the problem, typing exit will quit the debug shell and continue the boot process at the point it failed. Of course you will also need to fix the underlying problem and regenerate the initrd so the next boot won't fail again.

4.1.4.2. systemd 引导时使用调试 shell

If the boot fails under systemd, it is possible to obtain a debug root shell by changing the kernel command line. If the basic boot succeeds, but some services fail to start, it may be useful to add systemd.unit=rescue.target to the kernel parameters.

Otherwise, the kernel parameter systemd.unit=emergency.target will provide you with a root shell at the earliest possible point. However, this is done before mounting the root file system with read-write permissions. You will have to do that manually with:

# mount -o remount,rw /

Another approach is to enable the systemd "early debug shell" via the debug-shell.service. On the next boot this service opens a root login shell on tty9 very early in the boot process. It can be enabled with the kernel boot parameter systemd.debug-shell=1, or made persistent with systemctl enable debug-shell (in which case it should be disabled again when debugging is completed).

More information on debugging a broken boot under systemd can be found in the Freedesktop.org Diagnosing Boot Problems article.

4.1.5. 为升级准备安全环境

重要

If you are using some VPN services (such as tinc) consider that they might not be available throughout the upgrade process. Please see Prepare for downtime on services.

In order to gain extra safety margin when upgrading remotely, we suggest that you run upgrade processes in the virtual console provided by the screen program, which enables safe reconnection and ensures the upgrade process is not interrupted even if the remote connection process temporarily fails.

使用由 micro-evtd 提供的 watchdog 守护程序的用户应该在升级前停止守护进程并禁用 watchdog timer,以避免在升级过程中发生不必要的重启:

# service micro-evtd stop
# /usr/sbin/microapl -a system_set_watchdog off

4.2. Start from "pure" Debian

The upgrade process described in this chapter has been designed for "pure" Debian stable systems. APT controls what is installed on your system. If your APT configuration mentions additional sources besides bookworm, or if you have installed packages from other releases or from third parties, then to ensure a reliable upgrade process you may wish to begin by removing these complicating factors.

The main configuration file that APT uses to decide what sources it should download packages from is /etc/apt/sources.list, but it can also use files in the /etc/apt/sources.list.d/ directory - for details see sources.list(5). If your system is using multiple source-list files then you will need to ensure they stay consistent.

4.2.1. Upgrade to Debian 12 (bookworm)

Only upgrades from Debian 12 (bookworm) are supported. Display your Debian version with:

$ cat /etc/debian_version

Please follow the instructions in the Release Notes for Debian 12 at https://www.debian.org/releases/bookworm/releasenotes to upgrade to Debian 12 first if needed.

4.2.2. 升级至最新的小版本更新

This procedure assumes your system has been updated to the latest point release of bookworm. If you have not done this or are unsure, follow the instructions in 升级您的 bookworm 系统.

4.2.3. Debian Backports

Debian Backports allows users of Debian stable to run more up-to-date versions of packages (with some tradeoffs in testing and security support). The Debian Backports Team maintains a subset of packages from the next Debian release, adjusted and recompiled for usage on the current Debian stable release.

Packages from bookworm-backports have version numbers lower than the version in trixie, so they should upgrade normally to trixie in the same way as "pure" bookworm packages during the distribution upgrade. While there are no known potential issues, the upgrade paths from backports are less tested, and correspondingly incur more risk.

警告

While regular Debian Backports are supported, there is no clean upgrade path from sloppy backports (which use APT source-list entries referencing bookworm-backports-sloppy).

As with Unofficial sources, users are advised to remove "bookworm-backports" entries from their APT source-list files before the upgrade. After it is completed, they may consider adding "trixie-backports" (see https://backports.debian.org/Instructions/).

For more information, consult the Backports Wiki page.

4.2.4. 准备软件包数据库

在继续升级之前,还应确保软件包数据库已准备就绪。如果您是 aptitudesynaptic 等其他软件包管理器的用户,请查看任何待处理的操作。在包管理器中被计划安装或删除的软件包可能会干扰升级过程。请注意,仅当您的 APT source-list 文件仍指向 "bookworm" 而不是 "stable" 或 "trixie" 时,才能更正此项;请参阅 检查您的 APT source-list 文件

4.2.5. 移除过时的软件包

在升级前从您的系统中 移除过时的软件包 是一个好想法。未移除即升级可能会使升级过程复杂化,且它们因不再得到维护而可能带来安全风险。

4.2.6. 移除非 Debian 软件包

Below there are two methods for finding installed packages that did not come from Debian, using either apt or apt-forktracer. Please note that neither of them are 100% accurate (e.g. the apt example will list packages that were once provided by Debian but no longer are, such as old kernel packages).

$ apt list '?narrow(?installed, ?not(?origin(Debian)))'
$ apt-forktracer | sort

4.2.7. 清理配置文件残留

A previous upgrade may have left unused copies of configuration files; old versions of configuration files, versions supplied by the package maintainers, etc. Removing leftover files from previous upgrades can avoid confusion. Find such leftover files with:

# find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error'

4.2.8. non-free 和 non-free-firmware 区

If you have non-free firmware installed it is recommended to add non-free-firmware to your APT sources-list. For details see 软件仓库分区 and 非自由固件在仓库中被划分到了单独的分区.

4.2.9. proposed-updates 区

If you have listed the proposed-updates section in your APT source-list files, you should remove it before attempting to upgrade your system. This is a precaution to reduce the likelihood of conflicts.

4.2.10. 非官方源

If you have any non-Debian packages on your system, you should be aware that these may be removed during the upgrade because of conflicting dependencies. If these packages were installed by adding an extra package archive in your APT source-list files, you should check if that archive also offers packages compiled for trixie and change the source item accordingly at the same time as your source items for Debian packages.

Some users may have unofficial backported "newer" versions of packages that are in Debian installed on their bookworm system. Such packages are most likely to cause problems during an upgrade as they may result in file conflicts 4. Possible issues during upgrade has some information on how to deal with file conflicts if they should occur.

4.2.11. 禁用 APT pinning

如果您已经设置 APT 从一个非 stable(如 testing)版安装特定的软件包,您可能必须改变 APT pinning 设置(保存在 /etc/apt/preferences/etc/apt/preferences.d/ 中),以允许将软件包升级至新的 stable 中的版本。如需更多有关 APT pinning 的信息,请参阅 apt_preferences(5)

4.2.12. 检查 gpgv 是否已安装

APT 需要 gpgv 版本 2 或更高,以验证给 trixie 发布版本签名的密钥。鉴于 gpgv1 在技术上满足了依赖关系,但仅能在一些特殊情况下使用,您可能想要使用以下命令确保已经安装了正确的版本:

# apt install gpgv

4.2.13. 检查包状态

不管用什么方法升级,我们都建议您先检查所有软件包的状态,并验证所有包都处于可升级状态。以下命令会显示任何半安装或是配置失败的包,还有那些有任何错误状态的包。

$ dpkg --audit

您也可以用 aptitude 来检查系统中的所有软件包的状态,也可以使用如下命令

$ dpkg -l | pager

或是

# dpkg --get-selections '*' > ~/curr-pkgs.txt

或者您也可以使用 apt

# apt list --installed > ~/curr-pkgs.txt

在升级前移除所有的 hold 状态是很有必要的。如果有任何对升级而言有重大影响的包处于 hold 状态,升级会失败。

$ apt-mark showhold

如果您在本地更改并重新编译了一个包,且并未重命名它,或是在版本号中放入新的纪元号(epoch),您就必须将它设为 hold 状态,以防止它被升级。

apt 中的 "hold" 状态的包可以使用以下命令修改:

# apt-mark hold package_name

unhold 代替 hold 即可清除 "hold" 状态。

如果有任何需要修复的东西,最好确保您的 APT source-list 文件仍然指向 bookworm,就像 检查您的 APT source-list 文件 中所解释的那样。

4.3. 准备 APT source-list 文件

在开始升级之前,您必须重新配置 APT 的 source-list 文件(/etc/apt/sources.list 以及 /etc/apt/sources.list.d/ 下的文件)以添加用于 trixie 的源以及在通常情况下移除用于 bookworm 的源。

APT 将考虑所有已配置的源中包含的所有软件包,并安装具有最高版本号的软件包,优先考虑文件中的第一个条目。 因此,如果您有多个镜像位置,请将本地硬盘放在第一位,然后是 CD-ROM,最后是远程镜像。

一个发行版通常既能通过它的代号(如:"bookworm","trixie")引用,也可以用它的状态名引用(如:"oldstable","stable","testing","unstable")。引用发行版的代号的好处在于,您绝对不会因为新版本的发布而感到惊讶,因此本文使用这种方法。当然,这也意味着您不得不自己关注新版的发行公告。如果转而使用状态名,一旦有新版发行,您将只会看到一堆可用的软件包的更新。

Debian 提供了两个公告邮件列表,以帮助您及时了解与 Debian 发布相关的信息:

4.3.1. 添加互联网 APT 源

在新版安装中,APT 默认使用 Debian APT CDN 服务,该服务确保软件包自动从网络上离您较近的一个服务器下载。由于这是一项相对较新的服务,旧版安装的配置可能仍然指向 Debian Internet 主服务器之一或其中一个镜像。如果您尚未这样做,建议在 APT 配置中切换为使用 CDN 服务。

要使用 CDN 服务,请在 APT 源配置中添加这样一行(假设您在使用 maincontrib):

deb https://deb.debian.org/debian trixie main contrib

添加新源后,通过在以前存在的 "deb" 行前放置一个井号(#)来禁用它们。

不过,如果您通过使用在网络上更接近您的特定的镜像得到了更好的结果,您仍然可以继续这么做。

Debian 镜像地址可以在 https://www.debian.org/distrib/ftplist 找到(参见 "list of Debian mirrors" 一节)。

例如,假设离您最近的 Debian 镜像是 http://mirrors.kernel.org。 如果使用网络浏览器检查该镜像,您会注意到主目录的组织方式如下:

http://mirrors.kernel.org/debian/dists/trixie/main/...
http://mirrors.kernel.org/debian/dists/trixie/contrib/...

要使用给定的镜像配置 APT,请添加类似如下的一行(同样,假设您正在使用 main and contrib):

deb http://mirrors.kernel.org/debian trixie main contrib

注意"dists"会隐式添加,而版本名称后的参数则用于将路径扩展到多个目录。

同样,添加新源后,禁用以前存在的软件源条目。

4.3.2. 添加本地镜像 APT 源

您可能希望修改 APT source-list 文件以使用本地磁盘上的镜像(可能挂载在 NFS 上),而不是使用远程软件包镜像。

例如,您的软件包镜像可能位于 /var/local/debian/ 下,并且具有如下的目录结构:

/var/local/debian/dists/trixie/main/...
/var/local/debian/dists/trixie/contrib/...

要让 apt 使用它,需要把这一行添加至 sources.list 文件:

deb file:/var/local/debian trixie main contrib

注意"dists"会隐式添加,而版本名称后的参数则用于将路径扩展到多个目录。

添加新源后,通过在 APT source-list 文件中以前存在的软件源条目前放置一个井号(#)来禁用它们。

4.3.3. 从光学介质中添加 APT 源

如果您 想使用 DVD(或 CD 或蓝光光盘),请在所有 APT source-list 文件中注释掉现有条目,方法是在它们前面放置一个井号(#)。

确保在 /etc/fstab 中有一行允许您挂载 CD-ROM 于 /media/cdrom 挂载点。例如,假设 /dev/sr0 就是您的 CD-ROM,/etc/fstab 中应该带有一行:

/dev/sr0 /media/cdrom auto noauto,ro 0 0

注意在第四列 noauto,ro 之间必须 没有空格

要验证设置是否有效,插入一片 CD,尝试运行

# mount /media/cdrom    # this will mount the CD to the mount point
# ls -alF /media/cdrom  # this should show the CD's root directory
# umount /media/cdrom   # this will unmount the CD

下一步,运行:

# apt-cdrom add

每片您所拥有的 Debian 二进制 CD-ROM 都要这么做,以便将每片 CD 的数据添加至 APT 的数据库。

4.4. 升级软件包

从以前的 Debian 版本升级的推荐方法是使用包管理工具 apt

注解

apt 被设计用于交互式使用,故不应在脚本中使用。 在脚本中,应该使用 apt-get,它具有更适合进行文本处理的稳定输出。

不要忘记挂载所有必需的分区(尤其是根分区和 /usr 分区)为可读写状态,用以下命令:

# mount -o remount,rw /mountpoint

接下来,您应该仔细检查确认 APT 源条目(在 /etc/apt/sources.list 以及 /etc/apt/sources.list.d/ 下的文件)要么指向 "trixie",要么指向 "stable"。 不应该有任何源条目指向 bookworm。

注解

CD-ROM 的源有时会指向 "unstable"。尽管这令人困惑,但您 不应该 改变它。

4.4.1. 记录会话

强烈推荐您使用 /usr/bin/script 程序来记录升级会话中的交互信息。这样如果有问题了,您就有一份日志,而且需要的话,它也可以在缺陷报告中提供准确的信息。要开始记录,输入:

# script -t 2>~/upgrade-trixie-step.time -a ~/upgrade-trixie-step.script

or similar. If you have to rerun the typescript (e.g. if you have to reboot the system) use different step values to indicate which step of the upgrade you are logging. Do not put the typescript file in a temporary directory such as /tmp or /var/tmp (files in those directories may be deleted during the upgrade or during any restart).

The typescript will also allow you to review information that has scrolled off-screen. If you are at the system's console, just switch to VT2 (using Alt+F2) and, after logging in, use

# less -R ~root/upgrade-trixie.script

to view the file.

在完成升级后,您可以在提示符下输入 exit 停止 script

apt 也会把软件包的状态变更记录在 /var/log/apt/history.log,并把终端输出记录在 /var/log/apt/term.logdpkg 会额外地把软件包的状态变更记录在 /var/log/dpkg.log。如果您使用 aptitude, 它也会把软件包的状态变更记录在 /var/log/aptitude

如果已经对 script 使用了 -t 选项,您就可以用 scriptplay 程序来回放整个过程:

# scriptreplay ~/upgrade-trixie-step.time ~/upgrade-trixie-step.script

4.4.2. 更新软件包列表

首先,需要获取新发行版的可用包列表。执行:

# apt update

注解

apt-secure 的用户可能会在使用 aptitudeapt-get 时遇到问题。对于 apt-get,您可以使用 apt-get update --allow-releaseinfo-change

4.4.3. 确保您有足够的空间升级

You have to make sure before upgrading your system that you will have sufficient hard disk space when you start the full system upgrade described in Upgrading the system. First, any package needed for installation that is fetched from the network is stored in /var/cache/apt/archives (and the partial/ subdirectory, during download), so you must make sure you have enough space on the file system partition that holds /var/ to temporarily download the packages that will be installed in your system. After the download, you will probably need more space in other file system partitions in order to both install upgraded packages (which might contain bigger binaries or more data) and new packages that will be pulled in for the upgrade. If your system does not have sufficient space you might end up with an incomplete upgrade that is difficult to recover from.

apt 可以显示有关安装所需磁盘空间的详细信息。 在执行升级之前,您可以通过运行以下命令来查看此估计:

# apt -o APT::Get::Trivial-Only=true full-upgrade
[ ... ]
XXX upgraded, XXX newly installed, XXX to remove and XXX not upgraded.
Need to get xx.xMB of archives.
After this operation, AAAMB of additional disk space will be used.

注解

Running this command at the beginning of the upgrade process may give an error, for the reasons described in the next sections. In that case you will need to wait until you've done the minimal system upgrade as in Minimal system upgrade before running this command to estimate the disk space.

如果您没有足够的空间进行升级, apt 将通过类似这样的消息警告您:

E: You don't have enough free space in /var/cache/apt/archives/.

在这种情况下,请确保事先释放空间。您可以:

  • 删除以前安装时下载的软件包(位于 /var/cache/apt/archives)。 通过运行 apt clean 来清理软件包缓存,这将会删除所有以前下载过的软件包文件。

  • 删除被遗忘的软件包。 如果您曾用 aptitudeapt 手动在 bookworm 中安装过包,它将会保存手动安装的记录,并且对于由依赖关系拉入的包,在主包删除时能自动识别为不再需要的并标记为冗余。不会将您手动安装的包标记为删除。要删除自动安装的、不再使用的软件包,请运行:

    # apt autoremove
    

    您可以用其它的工具来找出多余的包,例如 deborphandebfostercruft。不要盲目地移除那些工具找到的包,尤其是当您使用了激进的非默认的选项时,很容易产生假阳性结果。强烈推荐您在移除它们之前,手工核查那些建议移除的包(例如:它们的内容、大小以及描述信息)。

  • Remove packages that take up too much space and are not currently needed (you can always reinstall them after the upgrade). If you have popularity-contest installed, you can use popcon-largest-unused to list the packages you do not use that occupy the most space. You can find the packages that just take up the most disk space with dpigs (available in the debian-goodies package) or with wajig (running wajig size). They can also be found with aptitude. Start aptitude in full-terminal mode, select Views > New Flat Package List, press l and enter ~i, then press S and enter ~installsize. This will give you a handy list to work with.

  • 如果不需要的话可以从系统中移除翻译和本地化文件。您可以安装并配置 localepurge 软件包,这样只有一小部分指定的 locale 被保留在系统中。这将减少 /usr/share/locale 所使用的磁盘空间。

  • /var/log/ 下的系统日志临时放到其它系统,或是永久删除。

  • 使用临时的 /var/cache/apt/archives:您可以使用其他文件系统中的临时缓存目录(USB 存储设备,临时硬盘,已在使用的文件系统等等)。

    注解

    不要使用 NFS,这是因为网络连接可能在升级期间断开。

    例如,假设您将 USB 驱动器挂在 /media/usbkey 下:

    1. 删除以前安装时下载的包:

      # apt clean
      
    2. /var/cache/apt/archives 目录复制到 USB 驱动器:

      # cp -ax /var/cache/apt/archives /media/usbkey/
      
    3. 将临时缓存目录挂载至当前使用的目录:

      # mount --bind /media/usbkey/archives /var/cache/apt/archives
      
    4. 升级后,还原 /var/cache/apt/archives 目录:

      # umount /var/cache/apt/archives
      
    5. 删除留下的 /media/usbkey/archives

    您可以在挂载于系统中的任何文件系统上创建临时缓存目录。

  • Do a minimal upgrade of the system (see Minimal system upgrade) or partial upgrades of the system followed by a full upgrade. This will make it possible to upgrade the system partially, and allow you to clean the package cache before the full upgrade.

请注意,为了安全地删除软件包,建议将 APT source-list 文件切换回 bookworm,如 检查您的 APT source-list 文件 中所述。

4.4.4. 停止监控系统

因为 apt 可能需要暂时停止您的计算机上运行的服务,所以可能有必要在升级期间停止有可能重启其他被停止的服务的监控服务。Debian 中的 monit 就是这种服务的一个例子。

4.4.5. 最小系统升级

In some cases, doing the full upgrade (as described below) directly might remove large numbers of packages that you will want to keep. We therefore recommend a two-part upgrade process: first a minimal upgrade to overcome these conflicts, then a full upgrade as described in Upgrading the system.

要开始,请运行:

# apt upgrade --without-new-pkgs

这会升级那些不需要删除或安装其它任何包的软件。

当系统空间紧张,并且由于空间限制而无法运行完整升级时,最小的系统升级也将非常有用。

If the apt-listchanges package is installed, it will (in its default configuration) show important information about upgraded packages in a pager after downloading the packages. Press q after reading to exit the pager and continue the upgrade.

4.4.6. 升级系统

一旦您完成了上述步骤,您就可以继续进行升级的主要部分。请执行:

# apt full-upgrade

这将对系统进行一次全面的升级,安装所有包的最新可用版本,解决不同发行版本的软件包之间的所有潜在的依赖关系变化。如有必要,它会安装一些新包(通常是新版本的库,或是被重命名的软件包),并删除任何存在冲突的过时包。

当从一组 CD/DVD/BD 升级时,您会在升级期间的某些时刻被要求插入指定的盘片。 您可能不得不多次插入相同的盘片,这是因为互相依赖的包已经被散布到整个盘片组中去了。

无法在不改变其他软件包的安装状态的情况下升级的已安装软件包将停留在当前版本(显示为"未被升级")。这个问题可以通过使用 aptitude 选择这些包来安装或是用 apt install 软件包 来解决。

4.5. 升级期间可能遇到的问题

以下部分描述升级到 trixie 期间已知可能会出现的问题。

4.5.1. Full-upgrade 失败,显示"无法立即配置"

在某些情况下,下载软件包后,apt full-upgrade 步骤可能会失败:

E: Could not perform immediate configuration on 'package'.  Please see man 5 apt.conf under APT::Immediate-Configure for details.

如果发生这种情况,运行 apt full-upgrade -o APT::Immediate-Configure=0 应该可以使升级继续。

此问题的另一个可能解决方法是临时将 bookworm 和 trixie 源都添加到您的 APT source-list 文件中,并运行 apt update

4.5.2. 预期的删除

The upgrade process to trixie might ask for the removal of packages on the system. The precise list of packages will vary depending on the set of packages that you have installed. These release notes give general advice on these removals, but if in doubt, it is recommended that you examine the package removals proposed by each method before proceeding. For more information about packages obsoleted in trixie, see Obsolete packages.

4.5.3. 冲突或预依赖循环

有时有必要在 APT 中开启 APT::Force-LoopBreak 选项使之能够临时移除一个重要的包,这是由于冲突或是预依赖循环。 apt 会警告您这一点并中止升级。 您可以通过在 apt 命令行中指定 -o APT::Force-LoopBreak=1 选项来解决这个问题。

有时一个系统的依赖关系太乱了以至于需要手工干预。 通常这意味着使用 apt

# dpkg --remove package_name

来消除某些引起问题的包,或是

# apt -f install
# dpkg --configure --pending

在极端情况下,您可能不得不用类似下面的命令强制重新安装某个包

# dpkg --install /path/to/package_name.deb

4.5.4. 文件冲突

如果您从"纯净的" bookworm 系统升级就不会出现文件冲突,但如果您装有非官方的向后移植的软件包就可能出现冲突。文件冲突会导致类似以下这样的错误:

Unpacking <package-foo> (from <package-foo-file>) ...
dpkg: error processing <package-foo> (--install):
trying to overwrite `<some-file-name>',
which is also in package <package-bar>
dpkg-deb: subprocess paste killed by signal (Broken pipe)
Errors were encountered while processing:
<package-foo>

您可以尝试强制删除错误信息中的*最后*一行提到的软件包来解决文件冲突:

# dpkg -r --force-depends package_name

在修复这些问题后,您应该可以通过重复前述的 apt 命令来继续升级。

4.5.5. 配置文件变化

升级期间,您将会被询问有关配置或是重新配置一些软件包的问题。如果您被问到是否用软件包维护者的版本替换 /etc/init.d/etc/manpath.config 下的文件时,通常有必要回答 "yes" 来确保系统一致性。您总是可以恢复老版本的配置文件,因为它们会被保存为带有 .dpkg-old 后缀名的文件。

如果您不确定该做什么,那就记下软件包或文件的名称,以后再妥善处理这些问题。您可以通过在 typescript 文件中搜索来查看升级期间显示在屏幕上的信息。

4.5.6. 将会话切换到控制台

如果您使用系统的本地控制台升级,则可能会发现在升级过程中的某些时候,控制台切换到了不同的视图,并且您无法看到升级过程。例如,在含有图形界面的系统中,当显示管理器重新启动时,就可能发生这种情况。

To recover the console where the upgrade was running you will have to use Ctrl+Alt+F1 (if in the graphical startup screen) or Alt+F1 (if in the local text-mode console) to switch back to the virtual terminal 1. Replace F1 with the function key with the same number as the virtual terminal the upgrade was running in. You can also use Alt+Left Arrow or Alt+Right Arrow to switch between the different text-mode terminals.

4.7. 为下个发布版本做准备

升级完成后,您可以为下一个发布版本做些准备工作。

4.7.1. 清理已删除的软件包

通常建议清理已删除的软件包。如果这些软件包已经在之前的版本升级(例如升级到 bookworm)过程中被删除,或者它们是由第三方供应商提供的,则尤其如此。特别地,已知旧的 init.d 脚本会导致问题。

警告

清理软件包通常也会清除其日志文件,因此您可能希望先备份它们。

以下命令显示所有已删除、但可能在系统上留下配置文件的软件包的列表(如果有的话):

$ apt list '~c'

可以使用 apt purge 删除这些软件包。 假设您想一次性清除它们,可以使用以下命令:

# apt purge '~c'

4.8. 过时的软件包

引进新软件包的同时,trixie 也清除了一些曾位于 bookworm 的旧软件包。 它不提供对这些过时包的升级。 虽然没有什么可以阻止您继续使用过时的软件包,但 Debian 项目通常会在 trixie 发布一年后停止对它的安全更新 5,并且在此期间通常不会提供其他支持。 如果有的话,建议用可用的替代品替换它们。

软件包被从发行版中移除有很多原因,如:它们不再被上游作者维护了;没有 Debian 开发者对维护这个包感兴趣;这些包提供的功能被不同的软件(或新版本)替代了;或者由于它们自身的缺陷,使得它们被认为不适用于 trixie。最后一种情况下,这些包有可能仍然位于 "unstable" 版之下。

以下命令可以列出并清除"过时的和在本地创建的软件包":

$ apt list '~o'
# apt purge '~o'

Debian 缺陷跟踪系统 通常会提供有关这个包为什么会被移除的额外信息。您应该既查看此包自身的归档缺陷报告,同时也要查看 ftp.debian.org 伪软件包 的归档缺陷报告。

要获得 trixie 的过时包列表,请参阅 值得注意的过时软件包

4.8.1. 过渡哑包

来自 bookworm 的一些软件包可能已在 trixie 中被过渡哑包(transitional dummy package)替换,这些软件包是用于简化升级的空占位符。例如,如果以前单个包的应用程序已被拆分为多个,则可以提供与旧包具有相同名称的过渡包,并设置合适的依赖以使新的包被安装。发生这种情况后,可以安全地移除冗余哑包。

绝大多数过渡哑包的描述信息会显示它们的用途。但哑包的描述信息并不统一;特别是,一些 "哑" 包被设计为保持安装,以便引入完整的软件套件或跟踪某些程序的当前最新版本。您也可以使用 deborphan 命令的 --guess-* 选项(例如 --guess-dummy)来检测系统上的过渡哑包。

1

如果 debconf 优先级被设置为非常高的级别,则可能不会弹出配置提示,但如果默认应答不适用于您的系统,依赖于此的服务将无法启动。

2

例如:DNS 或 DHCP 服务,特别是当没有冗余或故障转移时。以 DHCP 为例,如果租用时间低于升级过程完成所需的时间,终端用户可能会断开网络连接。

3

此功能可以通过在您的启动参数中添加参数 panic=0 来禁用。

4

Debian 的包管理系统正常情况下不允许一个软件包移除或是替换另一个软件包所拥有的文件,除非已经被设定为替换那个包。

5

或者,直到这段时间内有另一个版本发布为止。在任意时刻,一般仅对两个 stable 版本提供支持。