raspbian os: upgrade to debian 11 (bullseye)

6 minute read published: 2021-11-19

upgrading any os may come with its own quicks and problems. that's a reason why nobody really wants to upgrade their servers to the latest and greatest version. but sticking to the second-latest version does impose a certain security risk. perhaps not today. perhaps not tomorrow. but you will forget that particular server and suddenly 6 months passed by...

i have several raspberries, that are used as servers for dns, printing and vpn in my household. they do their work quietly and efficently with really low overhead in maintainance. but sometimes there are upgrades to the latest version of raspbian os neccessary. all my raspberries run raspbian os with debian 10 (buster) and must be converted to debian 11 (bullseye). normally, upgrading debian is a joy. just change some words in the apt-config files and you are done. very low headache.

but with my last upgrade on my first raspberry 3, i run in some troubles. the raspi wouldn't come up and online after the upgrade. fortunately, i did a full image backup of the sd-card and could just write that back and start anew.

i upgraded the raspi gradually and spotted the problem: the culprit for me was the dhcpcd5 service under systemd. this service would not start up propperly. the problematic file under /etc/systemd/system tried to start a program that was no more available under bullseye! so the service unit failed and dhcpcd did not start. and without dhcpcd, there is no ip-address for my raspi. you spot the dilemma?!

to cut a long story short - here's a walkthrough showing the correct way from buster to bullseye under raspbian os.

the walkthrough

ssh to your raspi and become root:

$ sudo -i

bring buster to the latest state:

# apt update
# apt update --allow-releaseinfo-change
# apt-get upgrade && apt-get full-upgrade
# reboot

ssh to your raspi again.

become root:

$ sudo -i
# cd /etc/apt
#
# nano sources.list
# # replace all occurences of buster with bullseye
#
# cd sources.list.d
#
# nano raspi.list
# # replace all occurences of buster with bullseye
# # if the first line reads "deb http://archive.raspberrypi.org/debian/ bullseye main" without "ui" at the end then it's correct at least for raspi as server!

alternatively:

# sed -i 's/buster/bullseye/g' /etc/apt/sources.list

now the upgrade fun begins:

# apt update

first we performe a minimal system upgrade without new packages:

# apt upgrade --without-new-pkgs

during the process, you could be prompted "restart services during package upgrade without asking". enter "yes".

# reboot

again, ssh to your raspi. become root:

$ sudo -i
# apt upgrade dhcpcd

you will have to wait a really long time - at least on my raspi 2. raspi 3 was a tad faster. grab a cup of coffee.

now comes the fun part. dhcpcd.service won't start anymore. do not restart, yet!

# systemctl restart dhcpcd.service
# Job for dhcpcd.service failed because the control process exited with error code.
# See "systemctl status dhcpcd.service" and "journalctl -xe" for details.

let's see what's going on:

# systemctl status dhcpcd.service 
# ● dhcpcd.service - DHCP Client Daemon
#    Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
#   Drop-In: /etc/systemd/system/dhcpcd.service.d
#            └─wait.conf
#    Active: failed (Result: exit-code) since Sun 2021-11-14 21:28:32 CET; 3s ago
#      Docs: man:dhcpcd(8)
#   Process: 14018 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=203/EXEC)
#
# Nov 14 21:28:32 earth systemd[1]: dhcpcd.service: Service RestartSec=100ms expired, scheduling restart.
# Nov 14 21:28:32 earth systemd[1]: dhcpcd.service: Scheduled restart job, restart counter is at 5.
# Nov 14 21:28:32 earth systemd[1]: Stopped DHCP Client Daemon.
# Nov 14 21:28:32 earth systemd[1]: dhcpcd.service: Start request repeated too quickly.
# Nov 14 21:28:32 earth systemd[1]: dhcpcd.service: Failed with result 'exit-code'.
# Nov 14 21:28:32 earth systemd[1]: Failed to start DHCP Client Daemon.

okay, here is the culprit: ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w (code=exited, status=203/EXEC)

# systemctl cat dhcpcd.service 
# # /lib/systemd/system/dhcpcd.service
# [Unit]
# Description=DHCP Client Daemon
# Wants=network.target
# Before=network-online.target
# Documentation=man:dhcpcd(8)
#
# [Service]
# Type=forking
# ExecStart=/usr/sbin/dhcpcd -b
# Restart=always
#
# [Install]
# WantedBy=multi-user.target
#
# # /etc/systemd/system/dhcpcd.service.d/wait.conf
# [Service]
# ExecStart=
# ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -w

/usr/lib/dhcpcd5/dhcpcd does not exist on my system anymore:

# LC_ALL=C ls -al /usr/lib/dhcpcd5/dhcpcd
# ls: cannot access '/usr/lib/dhcpcd5/dhcpcd': No such file or directory

so we will substitute it with the existing dhcpcd executable in the service unit file:

# cd /etc/systemd/system/dhcpcd.service.d
# nano wait.conf
# # replace "/usr/lib/dhcpcd5/dhcpcd" with "/usr/sbin/dhcpcd"
#
# systemctl daemon-reload
# systemctl restart dhcpcd.service 
# systemctl status dhcpcd.service 
# ● dhcpcd.service - DHCP Client Daemon
#    Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
#   Drop-In: /etc/systemd/system/dhcpcd.service.d
#            └─wait.conf
#    Active: active (running) since Sun 2021-11-14 21:38:20 CET; 4s ago
#   Process: 14112 ExecStart=/usr/sbin/dhcpcd -q -w (code=exited, status=0/SUCCESS)

yeah! it's active and running again. now we can reboot the system once more for a test. keep fingers crossed ;-)

# reboot

once again, ssh to your raspi. become root:

$ sudo -i

perform the last part of our upgrade to bullseye on the raspi:

# apt update
# apt upgrade && apt full-upgrade

again, grab your beverage.

# reboot

for the last time, ssh to your raspi. become root:

$ sudo -i
# apt autoremove
# apt autoclean

mission accomplished. congrats, your raspi runs the latest version of raspian os based on debian 11 (bullseye).

addendum

on one of my raspis - a raspi 2 - i had to remove another package interfering with the new dhcpcd5 package. the old package dhcpcd/stable 1:3.2.3-11 armhf - DHCP client for automatically configuring IPv4 networking had some remains on the filesystem.

just do a quick

# apt purge dhcpcd

and all leftovers of the old package are gone.

there were no such problems during upgrade of my other raspis, though.


you'll find more generic information on how to upgrade debian on the website How to Upgrade Debian 10 (Buster) to Debian 11 (Bullseye)