Debian 13 Tutorial / Upgrade Debian 12 to 13 and Verify Reboot, SSH and Service Data
When upgrading from Debian 12 to 13, switch the repository to trixie and then execute the minimal upgrade and full upgrade in order. Completion is determined not only by the APT termination messages but also by checking the boot of the new kernel, new SSH connections, network and service data, and the operation of temporary files and kernel settings.
Prepare Access and a Persistent Terminal Session
This targets an amd64 Debian 12 server that has completed pre-upgrade checks and recovery preparations . If backup restoration, console login, or proper reboot have not yet been verified, complete preparations first. For environments with external repositories, other architectures, or database/mail servers, additionally review the transition guidelines for those products.
The verification environment was a separate VirtualBox VM running Debian 12.15, kernel 6.1.0-55-amd64, 3 GiB memory, and a 30 GiB virtual disk. We performed the two-stage installation and reboots. The Python service code and data were backed up and HTTP responses were recorded as baselines, and this environment was not used to test a major version upgrade of a running database.
If tmux is not installed in bookworm, install sudo apt install tmux before switching the repository. With a separate console open, create the following session and start recording. Logs can contain sensitive configuration; keep them private. tmux preserves a terminal session across network disconnects, while script records the terminal output.
Check whether the transcript path already exists before starting: script -a appends to an existing file. Choose a new task-specific filename if needed so unrelated runs are not mixed. Run subsequent upgrade commands inside the shell opened by script.
tmux new-session -s debian13-upgrade
umask 077
script -a -f "$HOME/debian13-upgrade.typescript"
Once the SSH connection is disconnected, you can reconnect and return to tmux attach-session -t debian13-upgrade. First, check if APT is running, and do not execute the same upgrade redundantly. tmux is a tool to prepare for SSH disconnection and does not guarantee that a task will survive a reboot or power failure.
Check Repositories and Write the Complete deb822 Configuration
This example is for a practice server where the official bookworm entry exists only in one file, /etc/apt/sources.list, and sources.list.d contains no files at all. First, read the actual file and separately handle existing external repositories, backports, and pin settings. If the prerequisites below are not met, modify according to the actual repository configuration instead of performing a bulk string replacement.
sudo cat /etc/apt/sources.list
sudo find /etc/apt/sources.list.d -maxdepth 1 -type f -print
sudo bash <<'ROOT'
set -euo pipefail
. /etc/os-release
test "$VERSION_ID" = 12
test -z "$(dpkg --audit)"
test -z "$(find /etc/apt/sources.list.d -maxdepth 1 -type f -print -quit)"
test -f /usr/share/keyrings/debian-archive-keyring.gpg
dest=/var/backups/debian13-upgrade
test ! -e "$dest"
install -d -m 700 "$dest"
cp -a /etc/apt/sources.list "$dest/sources.list.bookworm"
mv /etc/apt/sources.list "$dest/sources.list.disabled"
cat > /etc/apt/sources.list.d/debian.sources <<'SOURCES'
Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie trixie-updates
Components: main non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
Types: deb
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg
SOURCES
ROOT
sudo apt update
apt-cache policy apt systemd linux-image-amd64 openssh-server
main non-free-firmware is the configuration used on this VM. If the existing server requires contrib or non-free, review the packages and policies and add the components. Development environments requiring deb-src should also be considered separately. Signed-By points to the actual Debian archive keyring, and you should not add an option to ignore signature errors. deb822 uses field-based stanzas separated by blank lines; .sources files use this format. The format can be found in Debian sources.list manual.
If the guarded root block fails, stop before apt update and inspect which files were moved or created. Do not assume a multi-command example automatically reverses partial changes. After a successful update, stop on repository or signature errors rather than installing with stale or untrusted metadata.
Make sure that the list update completes without errors and that the candidate version comes from the Trixie series. At this point, since Debian 13 packages have not yet been installed, if you discover an incorrect repository selection, you can deactivate the new file and restore the archived Bookworm file to update again. After starting the installation, do not assume that simply reverting the repository will fully restore the system.
Complete the Minimal Upgrade and Review Full-upgrade Changes
apt -s upgrade --without-new-pkgs
sudo apt upgrade --without-new-pkgs
sudo dpkg --audit
apt -s full-upgrade
The first step is to update what is possible without installing new packages or removing existing ones. Having remaining packages does not immediately constitute a failure. On the verification VM, 222 items were updated in the minimal step, and there were no new installations or deletions. Library replacements required by the full step will be handled in the next step.
Compare the names of packages scheduled for deletion in the simulation with their replacement packages. For example, on this VM, 25 items such as libssl3 appeared as candidates for deletion, and subsequent packages like libssl3t64 were newly installed. This does not automatically justify all deletions. If packages supporting SSH, network, storage, or applications disappear without replacements, stop the procedure. As explained in the APT manual , a full-upgrade can involve deletions.
Review includes not only the removal list but also download size, additional space after installation, pending packages, and external dependencies. If another APT operation is running, wait until it finishes; do not remove the lock file or forcibly terminate the package process.
Run the Full Upgrade and Review Configuration-file Choices
sudo apt full-upgrade
sudo dpkg --audit
sudo apt-get check
sudo /usr/sbin/sshd -t
systemctl --failed --no-pager
Read and approve whether the actual summary of changes matches the reviewed list. If apt-listchanges guidance opens, read the content and close it to continue installation. When dpkg or ucf asks how to handle modified configuration files, first check which files they are and what changes you made yourself.
| Selection Situation | Judgment and Subsequent Verification |
|---|---|
| There are intended local changes such as authentication, ports, or network | Check the differences and preserve the necessary changes. Verify whether the preserved syntax is valid in the new version as well. |
| You have not changed the distribution default settings or there are essential changes in the new version | Review the package guide and new defaults. Do not automatically treat preserving existing files as the correct answer. |
| Cannot determine differences in important settings | Check explanations and diffs while keeping the console and backup. Do not rush to reboot. |
| Automated installation environment | Test selection policies in advance. A single non-interactive variable does not resolve all questions and compatibility. |
The verification VM for this course saved logs and exit codes in a separate tmux session and set a policy to preserve existing custom settings based on a minimal server configuration without changes. The reader procedure above is an interactive execution where you read questions and make selections. It does not guide applying the automatic approval option of the exercises directly to the entire production server.
If installation ends with an error, first check logs, disk space, and package status. Review changes suggested by sudo dpkg --configure -a or sudo apt --fix-broken install only if there are no ongoing APT operations and the cause has been resolved. Do not use mid-installation reboots or mass removal/forced overwrite as a general solution.
Check the Kernel, Network Interface and SSH Before Reboot
dpkg-query -W linux-image-amd64 'linux-image-*'
ls -l /vmlinuz /initrd.img
sudo ls -lh /boot
sudo /usr/sbin/sshd -t
ip -brief link
sudo udevadm test-builtin net_setup_link /sys/class/net/enp0s3
sudo efibootmgr -v
enp0s3 is the interface of the verification VM. Change it to the actual name and compare it with ID_NET_NAME and the current network settings interface. On some hardware, the name may change, so a console is required. BIOS systems check the boot method and GRUB installation status instead of using efibootmgr.
Even if a new kernel and initramfs are installed, the current uname -r shows the pre-reboot kernel. Open a new SSH window to actually verify authentication and sudo access, and do not assume everything is fine with just one open connection. The verification VM’s interface name has not changed, and the new SSH connection before reboot was successful.
sudo reboot
If booting is delayed, check on the console to see which step it is in: bootloader, kernel, or services. Instead of immediately powering off or disabling host key verification, check the actual boot status and the original fingerprint.
Verify services and data on the new operating system
cat /etc/os-release
uname -r
sudo dpkg --audit
sudo apt-get check
ip -brief address
ip route
getent ahostsv4 deb.debian.org
systemctl --failed --no-pager
sudo /usr/sbin/sshd -t
On the reconnected VM, Debian 13.7 and kernel 6.12.117+deb13-amd64 were confirmed. Existing services were enabled and active, HTTP content was compared with the preset reference values, and SHA-256 of programs and data were identical. On your own services, verify as follows with actual names, addresses, and files. Use read-only checks against the correct service and baseline files; do not delete or overwrite production data while adapting the sample.
systemctl is-enabled lf-upgrade33.service
systemctl is-active lf-upgrade33.service
curl --noproxy '*' -fsS http://127.0.0.1:8080/
sudo sha256sum -c /var/backups/lf-debian13-upgrade33/service-files-before.sha256
The above service exists only on the verification VM for pre-checks. On a regular server, the status, ports, read responses, and database connections of the actual service are compared. For services with write functionality, the write and re-query are also checked using isolated test data before resuming actual writes.
Check /tmp and sysctl configuration changes
findmnt --target /tmp -o TARGET,SOURCE,FSTYPE,OPTIONS
df -hT /tmp
sudo /usr/lib/systemd/systemd-sysctl --cat-config
sysctl kernel.printk_ratelimit
After rebooting, the verification VM changed /tmp to tmpfs. The size limit of tmpfs does not mean that this much memory is reserved in advance. Files that were in /tmp on the previous root file system may be hidden under the new mount. If you need to find the previous files, create a temporary empty mount point and use a regular bind mount to see only the root. Do not use --rbind, which would also reproduce submounts such as the covering tmpfs.
sudo bash <<'ROOT'
set -euo pipefail
view=$(mktemp -d /mnt/old-root-view.XXXXXX)
trap 'mountpoint -q "$view" && umount "$view"; rmdir "$view"' EXIT
mount --bind / "$view"
find "$view/tmp" -mindepth 1 -maxdepth 2 -printf '%p\n'
umount "$view"
rmdir "$view"
trap - EXIT
ROOT
This command only shows a list. On an actual server, do not delete the entire temporary directory at once; instead, judge the owner and necessity of the files. Previous markers on the verification VM were not visible even when viewing the root, and the presence immediately after the last boot before the upgrade was not recorded, so file loss was not attributed to the upgrade. The hiding principle itself was confirmed in a small practice directory with a separate mount namespace where tmpfs covered existing files, and in a regular root bind view, the files were visible. That controlled visibility test is separate from tracking a pre-upgrade marker through the real release upgrade.
Debian 13's systemd-sysctl does not directly read /etc/sysctl.conf. Manage local settings in individual /etc/sysctl.d/ files and compare their intended values with the actual runtime values. In practice, it was confirmed that kernel.printk_ratelimit=7 of a separate drop-in was applied even after a new kernel boot, and after verification, only the dedicated lab drop-in was removed, and the original runtime value was explicitly restored. If the entire settings are carelessly reapplied, it can affect other values such as the network, so define the scope of application. The systemd-sysctl manual explains file selection and application methods.
Finish Validation and Decide Whether Recovery Is Needed
After validation, type exit to close the script recording shell and check that the transcript has been saved. Close or detach the tmux session only after confirming no package task is still running.
If there were monitoring, scheduled tasks, or APT timers that were interrupted, restore them to their originally recorded states. In the verification VM, the two APT timers were returned to enabled and active states. Unnecessary packages are reviewed in apt -s autoremove after the full verification, and do not hastily remove previous kernels or service dependencies required for normal boot.
If service or data verification fails, logs and evidence of the failure are preserved without resuming new writes. If the package has already been replaced, recovery is not achieved simply by switching to the bookworm repository. Use the backup of the full pre-verified state and service to determine the repair scope, and if there is new data after the switch, plan for separate preservation and reapplication. Check Official Debian Upgrade Procedure and Known Changes in trixie along with the transition documentation for the relevant service.




