Upgrading Raspbian from Jessie to Stretch

raspberry-pi-logo

I noticed that it’s been a while since I upgraded my Raspberry Pi systems. I have updated Raspberry Pi firmware on all of them recently enough, but now decided to upgrade distro. Since Raspbian OS is based on Debian released, it meant I would have to upgrade Raspbian from Jessie base to Stretch.

Step 1: Update/upgrade existing distribution

This simply means we want to upgrade all existing packages before we’ll be moving to the next releast.

Refresh package info:

greys@s7:~ $ sudo apt-get update

Upgrade all the Raspbian OS packages

greys@s7:~ $ sudo apt-get upgrade
...
greys@s7:~ $ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... The following packages were automatically installed and are no longer required:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
Use 'apt-get autoremove' to remove them.
Done
The following NEW packages will be installed:
bc coinor-libipopt1 colord colord-data cups cups-browsed cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers cups-ppdc
cups-server-common ghostscript libcolorhug2 libcupscgi1 libcupsmime1 libcupsppdc1 libfile-copy-recursive-perl libfontembed1 libgmime-2.6-0 libgs9
libgs9-common libgusb2 libgutenprint2 libieee1284-3 libijs-0.35 libinput-bin libinput10 libjbig2dec0 libllvm3.9 libmumps-seq-4.10.0 liboauth0
libopenjp2-7 libpam-chksshpwd libpaper-utils libpaper1 libqpdf13 libqt5concurrent5 libqt5core5a libqt5dbus5 libqt5gui5 libqt5network5
libqt5opengl5 libqt5printsupport5 libqt5svg5 libqt5widgets5 libraw10 libsane libsane-common libsane-extras libsane-extras-common libwacom-bin
libwacom-common libwacom2 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xkb1 libxkbcommon-x11-0
printer-driver-gutenprint python-cffi python-cryptography python-ply python-pycparser python3-cffi python3-cryptography python3-ply
python3-pycparser qpdf qttranslations5-l10n rpd-icons rpd-plym-splash rpd-wallpaper sane-utils ssl-cert update-inetd wolframscript
xserver-xorg-input-libinput
The following packages will be upgraded:
alacarte apt apt-utils bash bind9-host binutils bluez-firmware ca-certificates chromium-browser cpp-4.9 cron cups-bsd cups-client cups-common curl
dbus dbus-x11 debconf debconf-i18n debconf-utils e2fslibs e2fsprogs file firmware-atheros firmware-brcm80211 firmware-libertas firmware-ralink
firmware-realtek fuse g++-4.9 gcc-4.9 gcc-4.9-base gir1.2-gdkpixbuf-2.0 git git-core git-man gnupg gnupg-agent gnupg2 gpgv gpicview
gstreamer0.10-alsa gstreamer0.10-plugins-base gstreamer1.0-alsa gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good
gstreamer1.0-x gtk2-engines-pixbuf idle-python2.7 idle-python3.4 initramfs-tools isc-dhcp-client isc-dhcp-common libapt-inst1.5 libapt-pkg4.12
libarchive13 libasan1 libasound2 libasound2-data libatomic1 libaudiofile1 libavcodec56 libavformat56 libavresample2 libavutil54 libbind9-90
libblas-common libblas3 libbluray1 libc-ares2 libc-bin libc-dev-bin libc6 libc6-dbg libc6-dev libcaca0 libcairo-gobject2 libcairo2 libcomerr2
libcups2 libcupsfilters1 libcupsimage2 libcurl3 libcurl3-gnutls libdb5.3 libdbus-1-3 libdns-export100 libdns100 libdrm-amdgpu1 libdrm-freedreno1
libdrm-nouveau2 libdrm-radeon1 libdrm2 libdvdnav4 libegl1-mesa libelf1 libevent-2.0-5 libexpat1 libexpat1-dev libfaad2 libfcgi-perl libffi6
libfm-data libfm-extra4 libfm-gtk-data libfm-gtk4 libfm-modules libfm4 libfuse2 libgbm1 libgcc-4.9-dev libgcc1 libgcrypt20 libgd3
libgdk-pixbuf2.0-0 libgdk-pixbuf2.0-common libgfortran3 libgl1-mesa-dri libgl1-mesa-glx libglapi-mesa libgles1-mesa libgles2-mesa libgme0
libgnutls-deb0-28 libgnutls-openssl27 libgomp1 libgraphite2-3 libgssapi-krb5-2 libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base0.10-0
libgstreamer-plugins-base1.0-0 libgstreamer1.0-0 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libgudev-1.0-0 libhogweed2 libicu52 libidn11
libio-socket-ssl-perl libirs-export91 libisc-export95 libisc95 libisccc90 libisccfg-export90 libisccfg90 libjasper1 libjpeg62-turbo libjs-jquery
libk5crypto3 libkrb5-3 libkrb5support0 liblapack3 liblcms2-2 libldap-2.4-2 libldb1 liblwres90 libmad0 libmagic1 libmp3lame0 libmpg123-0
libmwaw-0.3-3 libmysqlclient18 libncurses5 libncursesw5 libnettle4 libnss3 libobrender29 libobt2 libopencv-calib3d2.4 libopencv-contrib2.4
libopencv-core2.4 libopencv-features2d2.4 libopencv-flann2.4 libopencv-highgui2.4 libopencv-imgproc2.4 libopencv-legacy2.4 libopencv-ml2.4
libopencv-objdetect2.4 libopencv-video2.4 libpam-modules libpam-modules-bin libpam-runtime libpam-systemd libpam0g libpng12-0 libpng12-dev
libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libpoppler46 libprocps3 libpython2.7 libpython2.7-minimal libpython2.7-stdlib
libpython3.4 libpython3.4-dev libpython3.4-minimal libpython3.4-stdlib libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0
librtmp1 libruby2.1 libsdl-image1.2 libsmbclient libsndfile1 libsoundtouch0 libsoup-gnome2.4-1 libsoup2.4-1 libsqlite3-0 libss2 libssh-4 libssh2-1
libssl-dev libssl-doc libssl1.0.0 libstdc++-4.9-dev libstdc++6 libswscale3 libsystemd0 libtag1-vanilla libtag1c2a libtasn1-6 libtevent0 libtiff5
libtinfo5 libtirpc1 libubsan0 libudev1 libva1 libvorbis0a libvorbisenc2 libvorbisfile3 libwayland-client0 libwayland-cursor0 libwayland-egl1-mesa
libwayland-server0 libwbclient0 libwpd-0.10-10 libx11-6 libx11-data libx11-xcb1 libxcursor1 libxfixes3 libxfont1 libxi6 libxml2 libxpm4 libxrandr2
libxslt1.1 libxtst6 libxv1 locales login lxpanel lxpanel-data man-db multiarch-support mysql-common ncurses-base ncurses-bin ncurses-term nodered
nuscratch openbox openssh-client openssh-server openssh-sftp-server openssl passwd patch pcmanfm perl perl-base perl-modules pi-bluetooth
pi-greeter piclone pigpio pipanel pishutdown pix-icons pix-plym-splash pixel-wallpaper policykit-1 poppler-utils pprompt procps python-gpiozero
python-lxml python-openssl python-picamera python-picraft python-pigpio python-werkzeug python2.7 python2.7-minimal python3-gpiozero
python3-openssl python3-picamera python3-picraft python3-pigpio python3-werkzeug python3.4 python3.4-dev python3.4-minimal raspberrypi-bootloader
raspberrypi-kernel raspberrypi-sys-mods raspberrypi-ui-mods raspi-config raspi-gpio rc-gui realvnc-vnc-server realvnc-vnc-viewer rpcbind
rpi-chromium-mods rsync ruby2.1 samba-common samba-libs sed sensible-utils sonic-pi ssh sudo systemd systemd-sysv tar tzdata udev unzip
va-driver-all wget wireless-regdb wiringpi wolfram-engine wpasupplicant x11-common xarchiver xdg-utils xserver-common xserver-xorg
xserver-xorg-core xserver-xorg-input-all xserver-xorg-input-evdev xserver-xorg-input-synaptics xserver-xorg-video-fbdev xserver-xorg-video-fbturbo
352 upgraded, 80 newly installed, 0 to remove and 0 not upgraded.
Need to get 363 MB/729 MB of archives.
After this operation, 245 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Double-check Upgrade Was Complete

If we re-run the same command, there should be no more updates pending:

greys@s7:~ $ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... The following packages were automatically installed and are no longer required:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
Use 'apt-get autoremove' to remove them.
Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Perfect! Just a few packages to be tidied up with apt-get autoremove.

Tidy Up with apt-get autoremove

greys@s7:~ $ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
libcwiid1 libjs-prettify libllvm3.7 libqscintilla2-11 libqscintilla2-l10n libqt4-network libqt4-xmlpatterns libqtwebkit4 libruby1.9.1
libruby1.9.1-dbg libtcl8.5 libtcltk-ruby1.9.1 libtk8.5 pix-icons pix-plym-splash pixel-wallpaper ri1.9.1 ruby1.9.1 ruby1.9.1-dev
ruby1.9.1-examples ruby1.9.1-full ruby1.9.3 supercollider supercollider-common supercollider-ide supercollider-language supercollider-supernova
tcl8.5 tk8.5
0 upgraded, 0 newly installed, 29 to remove and 0 not upgraded.
After this operation, 129 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 138805 files and directories currently installed.)
Removing supercollider (1:3.6.6~repack-2-1) ...
Removing supercollider-ide (1:3.6.6~repack-2-1) ...
Removing supercollider-language (1:3.6.6~repack-2-1) ...
Removing libcwiid1 (0.6.00+svn201-3.1) ...
Removing supercollider-common (1:3.6.6~repack-2-1) ...
Removing libjs-prettify (2013.03.04+dfsg-4) ...
Removing libllvm3.7:armhf (1:3.7-4~bpo8+1) ...
Removing libqscintilla2-11 (2.8.4+dfsg-1) ...
Removing libqscintilla2-l10n (2.8.4+dfsg-1) ...
Removing libqtwebkit4:armhf (2.3.4.dfsg-3) ...
Removing libqt4-xmlpatterns:armhf (4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1+rpi1) ...
Removing libqt4-network:armhf (4:4.8.6+git64-g5dc8b2b+dfsg-3+deb8u1+rpi1) ...
Removing ruby1.9.1-full (1.9.3.484-2) ...
Removing ruby1.9.1-dev (1.9.3.484-2) ...
Removing ruby1.9.3 (1.9.3.484-2) ...
Removing libruby1.9.1-dbg (1.9.3.484-2) ...
Removing libtcltk-ruby1.9.1 (1.9.3.484-2) ...
Removing tk8.5 (8.5.17-1) ...
Removing tcl8.5 (8.5.17-1) ...
Removing libtk8.5:armhf (8.5.17-1) ...
Removing pix-icons (0.8) ...
Removing pix-plym-splash (0.11) ...
Removing pixel-wallpaper (0.4) ...
Removing ri1.9.1 (1.9.3.484-2) ...
Removing ruby1.9.1-examples (1.9.3.484-2) ...
Removing supercollider-supernova (1:3.6.6~repack-2-1) ...
Removing libtcl8.5:armhf (8.5.17-1) ...
Removing ruby1.9.1 (1.9.3.484-2) ...
Removing libruby1.9.1 (1.9.3.484-2) ...
Processing triggers for gnome-menus (3.13.3-6) ...
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for man-db (2.7.5-1~bpo8+1) ...
Processing triggers for libc-bin (2.19-18+deb8u10) ...
Processing triggers for ruby (1:2.1.5+deb8u2) ...

All clean now!

Step 2: Upgrade Raspbian OS to the next Release

You need to do pretty much the same steps as in previous section, but AFTER you update apt sources links to use the next Raspbian OS release.

As you know, Raspbian OS is based on Debian so it uses Debian’s naming conventions.

Meaning my old release was this:

jessie

… and next one (the one I’m upgrading to) is

stretch

Update apt sources.lst with new release name

So let’s update /etc/apt/sources.list file to reference stretch, which is the Debian release we want:

greys@s7:~ $ sudo vi /etc/apt/sources.list

edit this line:

deb http://raspbian.raspberrypi.org/raspbian/ jessie main contrib non-free rpi

so it looks like this:

deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi

Refresh apt information

greys@s7:~ $ sudo apt-get update

Upgrade all the packages once again

This time they’ll be upgraded to the latest versions available for the next Raspbian OS release:

greys@s7:~ $ sudo apt-get upgrade
...
greys@s7:~ $ sudo apt dist-upgrade

That should be it. Now let’s reboot and Raspberry Pi should come back online sporting a brand new Raspbian OS release:

greys@s7:~ $ sudo shutdown -r now

Took around 1 minute for it to reboot… Then:

greys@s7:~ $ cat /etc/debian_version 
9.9

See Also