RSS

Upgrade existing Debian Jessie to Buster, Bullseye without re-image

Upgrade existing Debian Jessie to Buster, Bullseye without re-image on Raspberry Pi, there is no data loss during upgrade with in-place upgrade.

How to do in-place upgrade without data loss

I have a old Raspberry Pi 3 running for many years, it still running on jessie and everything goes well, except I want to install some software which does not exist on jessie.

Since jessie, there are two major releases stretch and buster. It is time to upgrade to my Raspberry Pi OS to keep it up to date.

The official recommendation for major release is re-image.

As this is a major version upgrade, we recommend using a clean image.

However I do not want to re-image SD card since I have exist service running and it take me a lot of time tweak exist system configuration. I do not want to re-configure everything…

Since Raspberry Pi OS is based on Debian, Debian support in-place major release upgrade. This is also mentioned in Raspberry Pi blog raspbian-stretch

Upgrading an existing Jessie image is possible, but is not guaranteed to work in every circumstance. If you wish to try upgrading a Jessie image to Stretch, we strongly recommend taking a backup first – we can accept no responsibility for loss of data from a failed update.

I will take the risk to try this in-place upgrade.

Since there are two major releases, I need upgrade to stretch, then upgrade to buster.

Preparation

  1. Backup the important data is always a good idea in case upgrade failure and can not boot system.
  2. Check free disk space (df -h) before upgrade, OS upgrade normally need extra disk space. Remove unused packages to reduce disk space usage.

jessie to stretch in place upgrade without data loss

Replace jessie with stretch in /etc/apt/sources.list and /etc/apt/sources.list.d/raspi.list:

$ sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list
$ sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list.d/raspi.list
$ sudo apt-get update
$ sudo apt-get -y dist-upgrade

Answer yes or no to prompts based your settings.

After dist-upgrade, you may optional install font to fix missing Chinese and Japanese fonts:

$ sudo apt-get install -y fonts-droid-fallback

If you are not using PulseAudio for anything other than Bluetooth audio, remove it from the image by entering

$ sudo apt-get -y purge "pulseaudio*"

The last step is clean apt, remove un-used packages and reboot:

$ sudo apt-get autoremove
$ sudo reboot

stretch to buster in place upgrade without data loss

Similar with jessie to buster, I need replace apt source:

$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/raspi.list

Then update:

$ sudo apt-get update
$ sudo apt-get -y dist-upgrade

However I got following error this time:

Errors were encountered while processing:
 /tmp/apt-dpkg-install-pxzIiX/152-firmware-misc-nonfree_1%3a20190114-1+rpt4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I re-run sudo apt-get -y dist-upgrade and got following errors:

$ sudo apt-get -y dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 firmware-ralink : Depends: firmware-misc-nonfree but it is not installed
N: Ignoring file '50unattended-upgrades.ucftmp' in directory '/etc/apt/apt.conf.d/' as it has an invalid filename extension
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Follow the instruction, I hope apt --fix-broken install can fix problem:

$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  firmware-misc-nonfree firmware-ralink g++-6 gnupg-agent libaio1 libbabeltrace-ctf1 libbind9-140 libboost-filesystem1.62.0 libboost-iostreams1.62.0 libboost-system1.62.0
  libcdio13 libcomerr2 libdns-export162 libdns162 libdrm-freedreno1 libevent-2.0-5 libfile-copy-recursive-perl libglew2.0 libhiredis0.13 libicu57 libisc-export160 libisc160
  libisccc140 libisccfg140 libiso9660-8 libjim0.76 liblwres141 libmpfr4 libperl5.24 libprocps6 libpython3.5 libpython3.5-dev libpython3.5-minimal libpython3.5-stdlib libssl1.0.2
  libstdc++-6-dev libtxc-dxtn-s2tc0 libunistring0 libva-x11-1 libwebpmux2 lynx-cur python-apt python3-pyasn1 python3.5 python3.5-dev python3.5-minimal python3.5-venv rename
  rsync sgml-base xml-core
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  firmware-misc-nonfree
The following NEW packages will be installed:
  firmware-misc-nonfree
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.

Looks good, then I re-run sudo apt-get -y dist-upgrade again, everything goes well this time.

After dist-upgrade success, clean apt and reboot:

$ sudo apt-get autoremove
$ sudo reboot

After reboot, check the release info, you got buster:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Raspbian
Description:	Raspbian GNU/Linux 10 (buster)
Release:	10
Codename:	buster

Continue upgrade to Bullseye

Debian 11.2 (Codenamed: Bullseye) was released on December 18th, 2021. To continue upgrade from Buster to Bullseye, similar with jessie to buster, I need replace apt source:

$ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
$ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/raspi.list

Then update:

$ sudo apt-get update   # Update the Bullseye software repositories.
$ sudo apt-get -y dist-upgrade

After dist-upgrade success, clean apt and reboot:

$ sudo apt-get autoremove
$ sudo reboot

After reboot, check the release info, you should have the latest Debian release Bullseye.

FAQ

Do I need upgrade firmware in OS upgrade?

rpi-update is a tool to get the latest bleeding-edge firmware and kernel for your Raspberry Pi.

The question is should I also upgrade firmware when do OS upgrade?

The short answer is NO.

You should only use rpi-update with a good reason.

This gets you the latest bleeding edge kernel/firmware. There is always the possibility of regressions.

Bug fixes and improvements will eventually make their way into new Raspberry Pi OS releases and apt-get when they are considered sufficiently well tested.

A good reason for using this would be if you like to help with the testing effort, and are happy to risk breakages and submit bug reports. These testers are welcome.

Also if you are suffering from a bug in current firmware (perhaps as one of the reporters of the bug on github or forum) and a fix has been pushed out for testing, then using rpi-update is the right way to get the fix until it makes its way into new Raspberry Pi OS images and apt-get.

Even rpi-update itself not recommend use it as prt of a regular update process. When you run pi-update you got following warning:

$ sudo rpi-update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** Performing self-update
 *** Relaunching after update
 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Backing up firmware
 *** Backing up modules 5.10.63-v7+
#############################################################
WARNING: This update bumps to rpi-5.10.y linux tree
See: https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=288234
'rpi-update' should only be used if there is a specific
reason to do so - for example, a request by a Raspberry Pi
engineer or if you want to help the testing effort
and are comfortable with restoring if there are regressions.

DO NOT use 'rpi-update' as part of a regular update process.

##############################################################
Would you like to proceed? (y/N)

If you really want to continue upgrade firmware, backing up before updating is always advisable.

References

OmniLock - Block / Hide App on iOS

Block distractive apps from appearing on the Home Screen and App Library, enhance your focus and reduce screen time.

DNS Firewall for iOS and Mac OS

Encrypted your DNS to protect your privacy and firewall to block phishing, malicious domains, block ads in all browsers and apps

Ad