I decided to upgrade my oldest Raspberry Pi to the latest Raspbian. Since I was two releases behind, I decided to do it step-by-step. Today I updated from 8 – 9. I plan. to perform similar steps to upgrade 9 – 10.
Following are the quick sequence of steps I followed to perform the upgrade. This is a Model B Rev 2 Pi, so was considerably slow to update and took me more than 4 hours to complete.
Step 1 – Prepare The System For Upgrade
Apply the latest updates to the system.
$ sudo apt update && sudo apt upgrade -y && sudo apt-get dist-upgrade -y
Next step is to search for packages which have been only partially installed on the system using dpkg -C
command.
$ sudo dpkg -C
The dpkg may indicate what needs to be done with these. I did not find anything under this category, which was good. In last, I ran apt-mark showhold
command to get a list of all packages which have been marked as hold.
$ sudo apt-mark showhold
While I did not get any packages in this list, but if there are any, we are expected to resolve this before proceedig to step 2.
Stpe 2 – Prepare the APT System for Upgrade
$ 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
$ echo 'deb http://archive.raspberrypi.org/debian/ stretch main' >> /etc/apt/sources.list
I am updating only the two files but if your system has any other source files, then you need to update them appropriately as well. A list of such files can be found using – grep -lnr jessie /etc/apt
In addition to this I also removed the package apt-listchange
which displays what changed in the new version of the Debian package as compared to the version currently installed on the system. This is expected to speed-up the entire process. This is not mandatory, so you can skip it.
# optional step
$ sudo apt-get remove apt-listchange
Step 3 – Perform The Upgrade and Cleanup
As a last step initiate the upgrade process. This is the time where you can just leave the system for few hours.
$ sudo apt update && sudo apt upgrade -y && sudo apt-get dist-upgrade -y
I faced issues with chromium-browser and at the last command (dist-upgrade
), the dpkg
bailed out with a message indicating archive corruption of chromium-browser package. Since I am at Run Level 3, and do not need chromium on the headless pi, I decided to remove the following three packages. In any case in the absence of chromium
, the debian system will automatically use update-alternatives and choose epiphany-browser
to satisfy gnome-www-browser requirement
.
$ sudo apt-get remove chromium-browser chromium-browser-l10n rpi-chromium-mods
After removing the chromium browser, I did another round of update, upgrade and dist-upgrade, just to make sure before initiating the cleanup as below –
$ sudo apt-get autoremove -y && sudo apt-get autoclean
The new OS version can be verified by
$ cat /etc/debian_version;cat /etc/os-release
I also took this opportunity to update the firmware of the raspberry pi by running the following command. Please note this step is absolutely optional and it is recomended also that do not perform this unless you know what you are doing or you are being asked by a support person.
$ sudo rpi-update