Upgrade Raspbian Jessie to RaspbianStretch

Marco Franssen /
4 min read • 747 words

Very recently I have upgraded my Raspberry 3 to the new Raspbian OS, code named "Stretch". Due to some security issues in the chipset of the Raspberry Pi 3 and Raspberry zero, I decided to upgrade mine to Raspbian Stretch, which resolves these security issues.
Before you get yourself into any trouble make sure to have a backup of any important data and also please note I can't be responsible for any data loss. In this guide I also assume you know how to connect to your raspberry using ssh and how to use the commandline.
First check if you are running Raspbian Jessie release as following guide only is tested by upgrading from Jessie. You can check this using the following command.
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 8 (jessie)"
NAME="Raspbian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
In case you are not running Raspbian Jessie 8.0, I can't guarantee following guide will work. If you are brave enough to continue please let me and other readers know in the comments below if it also works for prior Jessie versions.. Once again make sure important data is backed up.
Before starting the upgrade I recommend to first make sure your current version Raspbian Jessie has all packages upgraded. You can do so by running following commands.
sudo apt update
sudo apt -y upgrade
Then before upgrading the Raspbian distro I also first did an upgrade of my raspberry firmware which can be done using following command. It upgrades the kernel VideoCore lib etc. A reboot is required after the firmware update.
sudo rpi-update
sudo reboot now
Now it is time to prepare for the distro upgrade to start using Raspbian Stretch. For that we have to change the apt sources to point to the Raspbian Stretch apt repositories. For that we have to change the following 2 files /etc/apt/sources.list
and /etc/apt/sources.list.d/raspi.list
by replacing jessie with the word stretch. You can do that manually using vim or use following command to get the text automatically replaced.
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
Now we have upgraded the apt repositories to Raspbian Stretch we are ready to run the upgrade. Please note this can take a while as it has to download all the new binaries which is a few hundred MB at least. Do note your input is required a few times during the installation process so do check every few minutes to keep the upgrade going. Also consider donating some CPU cycles using the widget on my sidebar while waiting for the upgrade, to support the hosting costs of my webpage.
sudo apt update
sudo apt -y dist-upgrade
According to resources on raspberryppi.org the bluetooth pulseaudio package in Raspbian Jessie was a bit clumsy. This has been improved by using the replacement bluez-alsa package in Raspbian Stretch.
Now with the upgrade done it is time to remove pulseaudio as this package is replaced with bluez-alsa package in Raspbian Stretch to make bluetooth audio work with ALSA. So unless you build your own stuff on top of pulseaudio we can remove this package using following command.
sudo apt-get -y purge "pulseaudio*"
Now it is time to reboot and say some prayers or do whatever you do at such moments (grabbing a coffee).
sudo reboot now
After rebooting the Pi I also recommend to do one more check for package updates and remove old packages running following commands. This saves some storage, plus I like to have my servers clean and tidy.
sudo apt update
sudo apt -y upgrade
sudo apt -y autoremove
sudo apt -y autoclean
That was all. You got your Raspberry fully updated now with latest security patches for the chipsets as well running latest stable Raspbian version. Please leave a comment below on your findings. Don't hesitate to ask any questions, and for the brave ones who ofcourse took that backup before jumping into the deep, please share your feedback if this guide also covers upgrading from earlier versions of Raspbian.
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"