Manually upgrade Debian from Buster to Bullseye

Intro

This simple tutorial displays how to upgrade your stable Debian OS to testing. The procedure displayed here is based on an upgrade from Debian Buster to Debian Bullseye, which is an upgrade from stable to testing at the time of writing.
Despite that, this tutorial most likely can be used in the future just as well, as the only things that should change are the code names for the at the time current stable and testing distributions.

Step By Step

1. Get the current OS information for reference

head -1 /etc/os-release

This should have the following output: PRETTY_NAME="Debian GNU/Linux 10 (buster)"

2. Find the right repositories

  1. Visit https://www.debian.org/mirror/list
  2. CTRL+F your country or area.
  3. Pick an appropriate mirror.

Almost all mirrors should be fine, if you are on a generic computer. If you are using an embedded device or something else special, be careful that you select a mirror that supports your requested architecture.

3. Upgrade the repository list

Open up your /etc/apt/sources.list:

sudo -s
apt edit-sources

Then comment out the existing entries by prepending each non-empty line with a pound key:

#deb http://deb.debian.org/debian buster main
#deb http://deb.debian.org/debian buster-updates main
#deb http://security.debian.org/debian-security/ buster/updates main
#deb http://ftp.debian.org/debian buster-backports main

You can remove the pound key later, if you made a mistake and want to retrieve to the initial starting point.

Now add the new URLs, mainly replacing buster with bullseye in this example:

deb http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://security.debian.org/debian-security bullseye-security main
deb http://ftp.debian.org/debian bullseye-backports main contrib non-free

Test if the sources.list configuration is correct:

apt update

If you don't see any errors, you upgraded the list correctly.

4. Perform a backup

It is extremely important to never rely that an upgrade of any sorts will go fine.

Therefore, issuing a Backup of the entire OS is strongly recommended, before proceeding.

5. Upgrade the system

Now, only after you performed a full system backup, upgrade your system:

apt update
apt full-upgrade && \
echo FINE || \
echo FAIL

If everything went fine, proceed with the next step.

6. Check the reference made in step 1

Compare the output of the command from step 1 with its output now:

head -1 /etc/os-release

Should now result in: PRETTY_NAME="Debian GNU/Linux bullseye/sid"

 

Troubleshooting

1. If you encounter an error that resembles the following output:

apt full-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Error!
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libc6-dev : Breaks: libgcc-8-dev (< 8.4.0-2~) but 8.3.0-6+rpi1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

Then you need to do the following to fix it:

apt install gcc-8-base

Then, try apt full-upgrade again. It will work now.

2. If you encounter an error that resembles the following output:

Errors were encountered while processing:
 /tmp/apt-dpkg-install-bOwYmi/226-libjs-jquery_3.5.1+dfsg-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
....
....
....
....
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = "en_GB.UTF-8",
        LC_TIME = "en_GB.UTF-8",
        LC_CTYPE = "en_GB.UTF-8",
        LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
Setting up apt (2.1.7) ...
Installing new version of config file /etc/apt/apt.conf.d/01autoremove ...
Installing new version of config file /etc/cron.daily/apt-compat ...
apt-daily-upgrade.timer is a disabled or a static unit not running, not starting it.
apt-daily.timer is a disabled or a static unit not running, not starting it.
Setting up mime-support (3.64) ...
Installing new version of config file /etc/mime.types ...
Setting up libmpdec2:armhf (2.4.2-3) ...
Setting up libpython3.8-stdlib:armhf (3.8.5-1) ...
Setting up python3.8 (3.8.5-1) ...
Setting up libpython3-stdlib:armhf (3.8.2-3) ...
Setting up python3 (3.8.2-3) ...
running python rtupdate hooks for python3.8...
running python post-rtupdate hooks for python3.8...
Setting up distro-info-data (0.44) ...
Setting up lsb-release (11.1.0) ...
Setting up libsigsegv2:armhf (2.12-2) ...
(Reading database ... 107447 files and directories currently installed.)
Preparing to unpack .../libjs-jquery_3.5.1+dfsg-4_all.deb ...
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.min.js' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.min.map' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.js' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: directory '/usr/share/javascript/jquery' contains files not owned by package libjs-jquery:all, cannot switch to symlink
dpkg: error processing archive /var/cache/apt/archives/libjs-jquery_3.5.1+dfsg-4_all.deb (--unpack):
 new libjs-jquery package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libjs-jquery_3.5.1+dfsg-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then you need to do the following to fix it:

dpkg --configure -a

3. If you encounter an error that resembles the following output:

Setting up zfsutils-linux (0.8.4-2) ...
zfs-import-scan.service is a disabled or a static unit, not starting it.
Job for zfs-import-cache.service failed because the control process exited with error code.
See "systemctl status zfs-import-cache.service" and "journalctl -xe" for details.
zfs-import-scan.service is a disabled or a static unit, not starting it.
Job for zfs-import-cache.service failed because the control process exited with error code.
See "systemctl status zfs-import-cache.service" and "journalctl -xe" for details.
Job for zfs-mount.service failed because the control process exited with error code.
See "systemctl status zfs-mount.service" and "journalctl -xe" for details.
invoke-rc.d: initscript zfs-mount, action "start" failed.
● zfs-mount.service - Mount ZFS filesystems
     Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2020-08-01 22:02:15 CEST; 28ms ago
       Docs: man:zfs(8)
    Process: 23251 ExecStart=/sbin/zfs mount -a (code=exited, status=127)
   Main PID: 23251 (code=exited, status=127)
dpkg: error processing package zfsutils-linux (--configure):
 installed zfsutils-linux package post-installation script subprocess returned error exit status 1
Setting up udev (245.6-2) ...
Job for systemd-udevd.service failed because the control process exited with error code.
See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "restart" failed.
● systemd-udevd.service - udev Kernel Device Manager
     Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
     Active: activating (start) since Sat 2020-08-01 22:02:21 CEST; 24ms ago
TriggeredBy: ● systemd-udevd-kernel.socket
             ● systemd-udevd-control.socket
       Docs: man:systemd-udevd.service(8)
             man:udev(7)
   Main PID: 23358 (systemd-udevd)
      Tasks: 1
     Memory: 156.0K
     CGroup: /system.slice/systemd-udevd.service
             └─23358 [systemd-udevd]
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of udisks2:
 udisks2 depends on udev; however:
  Package udev is not configured yet.

dpkg: error processing package udisks2 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 zfsutils-linux
 udev
 udisks2
E: Sub-process /usr/bin/dpkg returned an error code (1)
....
....
....
....
dpkg --configure udev
Setting up udev (245.6-2) ...
Job for systemd-udevd.service failed because the control process exited with error code.
See "systemctl status systemd-udevd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript udev, action "restart" failed.
● systemd-udevd.service - udev Kernel Device Manager
     Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
     Active: activating (start) since Sun 2020-08-02 00:47:34 CEST; 25ms ago
TriggeredBy: ● systemd-udevd-kernel.socket
             ● systemd-udevd-control.socket
       Docs: man:systemd-udevd.service(8)
             man:udev(7)
   Main PID: 26603 (systemd-udevd)
      Tasks: 1
     Memory: 236.0K
     CGroup: /system.slice/systemd-udevd.service
             └─26603 [systemd-udevd]
dpkg: error processing package udev (--configure):
 installed udev package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 udev
 ....
 ....
 ....
 ....
 systemctl status systemd-udevd.service
● systemd-udevd.service - udev Kernel Device Manager
     Loaded: loaded (/lib/systemd/system/systemd-udevd.service; static; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2020-08-02 00:47:35 CEST; 1min 22s ago
TriggeredBy: ● systemd-udevd-kernel.socket
             ● systemd-udevd-control.socket
       Docs: man:systemd-udevd.service(8)
             man:udev(7)
    Process: 26611 ExecStart=/lib/systemd/systemd-udevd (code=exited, status=127)
   Main PID: 26611 (code=exited, status=127)
....
....
....
....
apt install -f zfsutils-linux
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  binfmt-support bsdmainutils calendar dh-python e2fslibs g++-6 gir1.2-glib-2.0 gnupg-agent libapt-inst2.0 libapt-pkg5.0 libatasmart4 libbind9-140
  libblockdev-fs2 libblockdev-loop2 libblockdev-part-err2 libblockdev-part2 libblockdev-swap2 libblockdev-utils2 libblockdev2 libcryptsetup4 libcwidget3v5
  libdbus-glib-1-2 libdns-export162 libdns162 libevent-extra-2.0-5 libevent-openssl-2.0-5 libevent-pthreads-2.0-5 libgdbm3 libgirepository-1.0-1
  libgudev-1.0-0 libhogweed4 libhttp-parser2.1 libicu64 libidn11 libip4tc0 libip6tc0 libiptc0 libisc-export160 libisc160 libisccc140 libisccfg140
  libllvm4.0 liblogging-stdlog0 liblwres141 libmagickcore-6.q16-3 libmagickwand-6.q16-3 libncursesw5 libncursesw5-dev libnettle6 libntfs-3g871
  libpam-systemd libparted-fs-resize0 libpcre16-3 libpcre3-dev libpcre32-3 libpcrecpp0v5 libperl5.24 libpolkit-agent-1-0 libpolkit-gobject-1-0 libprocps6
  libpython3.5 libpython3.5-dev libpython3.5-minimal libpython3.5-stdlib libreadline7 librpm3 librpmbuild3 librpmio3 librpmsign3 libruby2.3 libsodium18
  libstd-rust-1.24 libstdc++-6-dev libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libtinfo-dev libudisks2-0 libunistring0 libustr-1.0-1
  multiarch-support ncal netcat-traditional node-jquery perl-modules-5.24 python-gi python-gobject python3-mock python3-pbr python3-pyasn1 python3.5
  python3.5-dev python3.5-minimal ruby-did-you-mean ruby-trollop ruby2.3
Use 'apt autoremove' to remove them.
Suggested packages:
  samba-common-bin zfs-initramfs | zfs-dracut
Recommended packages:
  zfs-zed
The following NEW packages will be installed:
  zfsutils-linux
0 upgraded, 1 newly installed, 0 to remove and 39 not upgraded.
Need to get 0 B/375 kB of archives.
After this operation, 1,120 kB of additional disk space will be used.
Selecting previously unselected package zfsutils-linux.
(Reading database ... 107077 files and directories currently installed.)
Preparing to unpack .../zfsutils-linux_0.8.4-2_armhf.deb ...
Unpacking zfsutils-linux (0.8.4-2) ...
Setting up zfsutils-linux (0.8.4-2) ...
Created symlink /etc/systemd/system/zfs-import.target.wants/zfs-import-cache.service → /lib/systemd/system/zfs-import-cache.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-import.target → /lib/systemd/system/zfs-import.target.
Created symlink /etc/systemd/system/zfs-mount.service.wants/zfs-load-module.service → /lib/systemd/system/zfs-load-module.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-load-module.service → /lib/systemd/system/zfs-load-module.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-mount.service → /lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-share.service → /lib/systemd/system/zfs-share.service.
Created symlink /etc/systemd/system/zfs-volumes.target.wants/zfs-volume-wait.service → /lib/systemd/system/zfs-volume-wait.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-volumes.target → /lib/systemd/system/zfs-volumes.target.
Created symlink /etc/systemd/system/multi-user.target.wants/zfs.target → /lib/systemd/system/zfs.target.
zfs-import-scan.service is a disabled or a static unit, not starting it.
Failed to start zfs-import-cache.service: Unit systemd-udev-settle.service not found.
Failed to start zfs-load-module.service: Unit systemd-udev-settle.service not found.
zfs-import-scan.service is a disabled or a static unit, not starting it.
Failed to start zfs-import-cache.service: Unit systemd-udev-settle.service not found.
Failed to start zfs-load-module.service: Unit systemd-udev-settle.service not found.
Job for zfs-mount.service failed because the control process exited with error code.
See "systemctl status zfs-mount.service" and "journalctl -xe" for details.
invoke-rc.d: initscript zfs-mount, action "start" failed.
● zfs-mount.service - Mount ZFS filesystems
     Loaded: loaded (/lib/systemd/system/zfs-mount.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sun 2020-08-02 00:54:24 CEST; 32ms ago
       Docs: man:zfs(8)
    Process: 28429 ExecStart=/sbin/zfs mount -a (code=exited, status=127)
   Main PID: 28429 (code=exited, status=127)
dpkg: error processing package zfsutils-linux (--configure):
 installed zfsutils-linux package post-installation script subprocess returned error exit status 1
Processing triggers for man-db (2.9.3-2) ...
Processing triggers for systemd (245.6-2) ...
Errors were encountered while processing:
 zfsutils-linux
E: Sub-process /usr/bin/dpkg returned an error code (1)
....
....
....
....
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.min.js' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.min.map' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: file '/usr/share/javascript/jquery/jquery.js' not owned by package 'libjs-jquery:all'
dpkg-maintscript-helper: error: directory '/usr/share/javascript/jquery' contains files not owned by package libjs-jquery:all, cannot switch to symlink
dpkg: error processing archive /tmp/apt-dpkg-install-ax32qV/14-libjs-jquery_3.5.1+dfsg-4_all.deb (--unpack):
 new libjs-jquery package pre-installation script subprocess returned error exit status 1
Preparing to unpack .../15-linux-libc-dev_5.7.10-1_armhf.deb ...
Unpacking linux-libc-dev:armhf (5.7.10-1) over (5.7.6-1) ...
Errors were encountered while processing:
 /tmp/apt-dpkg-install-ax32qV/14-libjs-jquery_3.5.1+dfsg-4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Then you need to do the following to fix it:

apt purge udev zfsutils-linux
apt update
apt upgrade
apt install -f
apt upgrade
apt remove libjs-jquery:all
apt install libjs-jquery
apt update
apt upgrade
apt install -f
apt full-upgrade

Sources