29.3. Performing the Release Upgrade
The upgrade itself is a short sequence made safe by the preparation behind it. Record what happens, keep an independent administrative path open, change the source suite only after the old release is current, follow the release notes' two-stage package upgrade, answer configuration prompts deliberately, and reboot into the new kernel before declaring the release change complete.
The Debian 12 to 13 transition below is exercised in a debootstrapped Debian 12
root filesystem under /srv/upgrade-lab, so that the package stages can be
recorded without a second host. That root filesystem has no running services
and no boot loader of its own; the kernel-installation and reboot stages that a
full host adds were exercised by the point-release upgrade in Section 29.2.2.
29.3.1. Recording the Session and Protecting Remote Access
A terminal recording turns an ambiguous failure into a timeline. Run the
upgrade commands inside script --append
~/debian-handbook/lifecycle/upgrade-session.log. The script utility starts a
subshell and copies everything displayed in it to the named file, including
prompts and error messages; it prints a short banner naming the file, and the
recording ends when you leave the subshell with exit. --append adds the
session to an existing log instead of replacing it. A terminal recording is not
a substitute for the journal: it records what the administrator saw, while the
journal records what the system did, including messages from services that were
not attached to the terminal.
Before changing packages, verify the SSH daemon configuration and the effective
policy. A syntax error in sshd_config combined with a restart can remove the
only remote path. On life2, in a root shell:
# sshd -t
No output means the configuration parses. The effective policy is inspected without restarting the daemon:
# sshd -T | grep -E '^(permitrootlogin|passwordauthentication|pubkeyauthentication)'
permitrootlogin without-password
pubkeyauthentication yes
passwordauthentication no
The values shown are this host's policy, not universal Debian defaults.
permitrootlogin without-password permits root only with a key,
pubkeyauthentication yes permits key authentication, and
passwordauthentication no disables password logins. The exact values come from
the installed configuration and its includes; sshd -T prints the effective
result after includes and match blocks are applied. If the policy differs from
what you expect, correct it and re-run sshd -t before restarting SSH. The
commands and options are covered in Chapter 20.
Keep the current SSH session open while testing a new one. A new login proves that the daemon, the network path, and the account still work; the old session is the recovery path if the new one fails. For a host with a console or a virtual machine console, confirm that the console is reachable before the reboot as well. A serial console is useful but not required for this book's procedures; a virtual machine console or provider console serves the same purpose.
29.3.2. Updating Debian Sources and Handling Third-Party Repositories
Build the disposable Debian 12 root filesystem first, so the starting point is explicit rather than assumed. On life1, in a root shell - the first two stages of the compound command reset the lab directory if it exists:
# rm -rf /srv/upgrade-lab && install -d /srv/upgrade-lab/rootfs && debootstrap --variant=minbase --arch=amd64 bookworm /srv/upgrade-lab/rootfs http://deb.debian.org/debian
I: Target architecture can be executed
I: Retrieving InRelease
I: Checking Release signature
I: Valid Release signature (key id 4D64FEC119C2029067D6E791F8D2585B8783D481)
I: Retrieving Packages
I: Validating Packages
I: Resolving dependencies of required packages...
I: Resolving dependencies of base packages...
I: Checking component main on http://deb.debian.org/debian...
I: Retrieving adduser 3.134
I: Validating adduser 3.134
I: Retrieving apt 2.6.1
I: Validating apt 2.6.1
[...]
Selected output; debootstrap validates each package against the signed
release index and reports the archive key that vouched for it. Confirm the
starting release and the sources it configured:
# chroot /srv/upgrade-lab/rootfs cat /etc/debian_version
12.15
# cat /srv/upgrade-lab/rootfs/etc/apt/sources.list
deb http://deb.debian.org/debian bookworm main
This is the supported starting point: Debian 12 at its current point release,
fully updated by construction. A real host reaches the same state through
Section 29.2.2's procedure. Copy the host's resolver configuration into the
chroot with cp /etc/resolv.conf /srv/upgrade-lab/rootfs/etc/resolv.conf so
APT can resolve names, then change the Debian suite. Change the suite, not
every line in every source file; on a host whose sources are deb822 .sources
files under /etc/apt/sources.list.d/, edit the Suites: field there instead.
Keep a copy of the file before changing it:
# sed -i 's/bookworm/trixie/g' /srv/upgrade-lab/rootfs/etc/apt/sources.list
The replacement is silent. Read the file back:
# cat /srv/upgrade-lab/rootfs/etc/apt/sources.list
deb http://deb.debian.org/debian trixie main
Changing bookworm to trixie in a URL or comment that contains the word for
another reason would be a mistake. Read the file before and after the edit, and
change only the suite component. If the host uses a local mirror, confirm that
the mirror carries trixie before the maintenance window; a mirror that lags
behind the release produces confusing "file not found" errors.
Third-party repositories are a separate decision. A repository built for Debian 12 may contain binaries linked against libraries that Debian 13 renamed or removed. During the release upgrade, disable the repository so that its packages cannot satisfy dependencies with the old library set. Move the source file out of the directory that APT reads - on life1, as john:
$ sudo mv /etc/apt/sources.list.d/handbook.list /etc/apt/sources.list.d/handbook.list.disabled
The move is silent. Refresh the indexes without the repository:
$ sudo apt-get update
Hit:1 https://security.debian.org/debian-security trixie-security InRelease
Hit:2 https://deb.debian.org/debian trixie InRelease
Hit:3 https://deb.debian.org/debian trixie-updates InRelease
Hit:4 https://deb.debian.org/debian trixie-backports InRelease
Reading package lists...
The update no longer fetches the local repository. The installed practice package remains installed but has no candidate from the disabled archive:
$ apt-cache policy handbook-agent
handbook-agent:
Installed: 1.0
Candidate: 1.0
Version table:
*** 1.0 100
100 /var/lib/dpkg/status
The installed package is still present, and its status priority of 100 is enough to keep it selected when no archive offers a newer version. This is the desired state during the Debian upgrade: the package does not block the base system, and it can be reviewed after the new release is running. A package that is required by a service must remain installed; disabling its repository does not remove it. After the upgrade, re-enable the repository only after confirming that it publishes packages for the new release and that its signing key is still trusted. Section 29.4.4 does that for the practice repository.
If a third-party package must be upgraded as part of the release change, build or obtain a version for the new release and test it in the clone. Do not point a Debian 12 package repository at a Debian 13 system and hope that dependency resolution chooses a compatible set. The package manager can verify signatures and dependencies, but it cannot know that a binary built against an old application binary interface will behave correctly.
29.3.3. Following the Release Notes' Staged Package Upgrade
With the sources changed and third-party archives disabled, refresh the package indexes inside the target root. On life1, in a root shell:
# chroot /srv/upgrade-lab/rootfs apt-get update
Get:1 http://deb.debian.org/debian trixie InRelease [140 kB]
Get:2 http://deb.debian.org/debian trixie/main amd64 Packages [9679 kB]
Get:3 http://deb.debian.org/debian trixie/main Translation-en [6486 kB]
Fetched 16.3 MB in 2s (7873 kB/s)
Reading package lists...
The Get lines confirm that the new suite's indexes were fetched, not the old
one's. The first stage upgrades packages that can be upgraded without
installing new packages or removing installed ones. It is the step that brings
the core utilities, libraries, and package manager into the new release while
keeping the old dependency graph intact:
# chroot /srv/upgrade-lab/rootfs apt-get upgrade --without-new-pkgs
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages have been kept back:
adduser apt coreutils e2fsprogs gcc-12-base libgcc-s1 libidn2-0
libpam-modules libpam-modules-bin libpam-runtime libstdc++6 login passwd
util-linux util-linux-extra
The following packages will be upgraded:
base-files base-passwd bash bsdutils dash debconf debian-archive-keyring
debianutils diffutils dpkg findutils gpgv grep gzip hostname
init-system-helpers libacl1 libattr1 libaudit-common libaudit1 libblkid1
libbz2-1.0 libc-bin libc6 libcap-ng0 libcap2 libcom-err2 libcrypt1
libdebconfclient0 libffi8 libgcrypt20 libgmp10 libgpg-error0 liblz4-1
liblzma5 libmd0 libmount1 libp11-kit0 libpam0g libpcre2-8-0 libseccomp2
libselinux1 libsemanage-common libsemanage2 libsepol2 libsmartcols1 libss2
libsystemd0 libtasn1-6 libtinfo6 libudev1 libuuid1 libxxhash0 libzstd1
logsave mawk mount ncurses-base ncurses-bin perl-base sed sysvinit-utils tar
tzdata usr-is-merged zlib1g
66 upgraded, 0 newly installed, 0 to remove and 15 not upgraded.
Need to get 19.0 MB of archives.
After this operation, 2278 kB of additional disk space will be used.
Selected output; the download and unpack progress follows. The 15 kept-back packages are the ones that need new dependencies or a coordinated transition; the second stage handles them. The first stage is not optional. Without it, the second stage may try to remove a library that the running old package manager still uses. The chroot has no running services, but a production host does, and the staged sequence keeps the package manager and its dependencies usable between the two commands.
The second stage permits new packages and removals:
# chroot /srv/upgrade-lab/rootfs apt-get full-upgrade
Reading package lists...
Building dependency tree...
Reading state information...
Calculating upgrade...
The following packages will be REMOVED:
libdb5.3 libext2fs2 libhogweed6 libnettle8
The following NEW packages will be installed:
gcc-14-base libapt-pkg7.0 libbsd0 libdb5.3t64 libext2fs2t64 libhogweed6t64
liblastlog2-2 libnettle8t64 libsqlite3-0 libssl3t64 libunistring5 login.defs
openssl-provider-legacy sqv
The following packages will be upgraded:
adduser apt coreutils e2fsprogs gcc-12-base libgcc-s1 libidn2-0
libpam-modules libpam-modules-bin libpam-runtime libstdc++6 login passwd
util-linux util-linux-extra
15 upgraded, 14 newly installed, 4 to remove and 0 not upgraded.
Need to get 17.5 MB of archives.
After this operation, 21.0 MB of additional disk space will be used.
Selected output. Read the removal list before confirming: the four removed
libraries are replaced by their t64 successors, exactly the transition
described in Section 29.2.5. A locally built application that links to
libdb5.3 must be rebuilt against libdb5.3t64; this is the kind of change
that a package count alone does not reveal.
On a production host, the same two commands run without the chroot wrapper:
$ sudo apt-get upgrade --without-new-pkgs
After that stage completes and its summary has been reviewed, run the second:
$ sudo apt-get full-upgrade
They are shown separately because they are separate stages and because apt asks
for confirmation at each one. Do not combine them with && in an interactive
upgrade; if the first stage reports a problem, the second should not start. The
apt command accepts the same operations (apt upgrade, apt full-upgrade)
and provides a progress display, but the release notes and this chapter use
apt-get because its output is stable and its behavior is easier to script and
record.
The options that matter during a staged upgrade:
| Option | Description |
|---|---|
--without-new-pkgs |
Keep the existing dependency set and install only upgrades that do not require new packages. |
--no-remove |
Abort if the operation would remove an installed package; useful as a safety check. |
--download-only |
Fetch archives without unpacking them; useful for staging a disconnected upgrade. |
-o Dpkg::Options::="--force-confdef" |
Use the default action for conffile prompts when automating a reviewed run. |
-o Dpkg::Options::="--force-confold" |
Keep the old conffile when automating a reviewed run. |
--allow-downgrades |
Permit a downgrade where apt would otherwise refuse; not a general rollback. |
The force-confdef and force-confold options are appropriate only when the
configuration policy has already been decided. On an interactive host, read the
prompt. Section 29.3.4 explains the choices.
29.3.4. Resolving Configuration Prompts and Package Transitions
During a release upgrade, dpkg may stop at a conffile prompt. The package
ships a new default configuration file, and the local file has been modified
since the old package was installed. The prompt offers to keep the old file,
install the new one, show the difference, or start a shell. The safe choice
depends on the file. A vendor default that the administrator never edited should
usually be replaced; a file containing site-specific paths, credentials, or
tuning should be merged by hand. apt-listchanges shows the package changelog
before the upgrade when it is installed, and debconf prompts ask for values
that the package needs.
Do not answer an unfamiliar prompt with the default just to make the upgrade
continue. Open another terminal, read the package's documentation and the
release notes, and compare the files. The old file remains available as
<file>.dpkg-old after a replacement, and the new file may be left as
<file>.dpkg-new when the old one is kept. Chapter 6
covers ucf, dpkg --force-confdef, and the configuration-file state machine
in detail.
After the package operation, check the dpkg database rather than assuming that every maintainer script succeeded. On life1, in a root shell:
# chroot /srv/upgrade-lab/rootfs dpkg --audit
No output means no package is half-configured. If the command prints a package, the package's post-installation or configuration step failed; Section 29.5.1 shows the repair sequence. Also verify that APT can still resolve the installed set:
# chroot /srv/upgrade-lab/rootfs apt-get check
Reading package lists...
Building dependency tree...
Reading state information...
A successful apt-get check prints the index and dependency lines and returns
zero. It is a consistency check, not a service test. A package can be installed
and its dependencies satisfied while its daemon fails to start because of a
configuration change.
Package transitions also change unit files and service dependencies. A new
package may install a unit with a different name, a new ConditionPathExists,
or a new default sandbox setting. Compare the failed units and the journal after
the reboot, not only the package exit status. The needrestart package, when
installed, reports services that are still using an old library after a package
upgrade and can restart them during the upgrade; review its list before letting
it restart a database or a network-facing daemon. Chapter 8
covers unit changes and restart policy.
29.3.5. Rebooting into the New Kernel and Userspace
A release upgrade usually installs a new kernel and a new C library. The running
kernel remains the old one until the host reboots, and some services continue to
use the old library until they are restarted. Some Debian installations record
a reboot hint in /var/run/reboot-required; treat it as exactly that, a hint.
On life1, as john:
$ sudo cat /var/run/reboot-required
On this host the command printed nothing and exited zero: the marker existed
but was empty, because nothing on the base installation is obliged to maintain
it. On other installations the file does not exist at all and cat fails with
"No such file or directory", which is equally inconclusive. Decide from the
kernels instead: list the installed kernel images with ls /boot/vmlinuz-* and
compare the newest with the running kernel from uname -r. The boot history
shown by last lists the kernel of each boot, which is how Section 29.6.1
reads it. When the installed and running kernels differ after an upgrade,
reboot.
A reboot interrupts every service and every SSH session. Warn users, drain or disable the service at the load balancer, and confirm that the console or out-of-band path works. Then reboot:
$ sudo systemctl reboot
The command normally closes the session without printing a final message. The host may take several minutes to return. Reconnect through the management network, not through a service address that may still be down, and check the running kernel - on life1 after the point-release upgrade this confirmed the switch to the new kernel:
$ uname -r
6.12.118+deb13-amd64
Check the services that must return:
$ systemctl is-active nginx ssh
active
active
Two active lines confirm that the web server and SSH are running. They do not
confirm that the web server serves the right content or that SSH accepts the
intended users; Section 29.4 tests those separately. If the host does not return,
use the console, select the previous kernel in the boot menu - the point-release
upgrade in Section 29.2.2 deliberately left the previous kernel installed - and
follow Section 29.5.2. Do not repeatedly power-cycle a host that is still
booting; the boot may be rebuilding an initramfs or waiting for a storage
device.