Raspberry Pi – Raspbian-Update “Jessie” to “Stretch”
Since August 17,2017 the new Rasbian version “Stretch”based on Debian 9 is available for download. If you don’t want to wait long and want to benefit directly from new kernel and software versions, you can upgrade to Raspbian “Stretch” in a few easy steps. The upgrade process takes some time and therefore requires some patience.
Difficulty level:
Step 1: Check available disk space
In order to update to Raspbian Stretch, there must be enough space on the SD card. Therefore you should check the available and used disk space usage first:
$ df -h
Step 2: Check package status
You must also check that all packages are in a state that is suitable for upgrade. The following command displays all packages that have the status semi-installed or configuration failed, and those with error status:
$ sudo dpkg --audit $ sudo dpkg --get-selections | grep hold
Step 3: Update system
Before upgrading, the Raspbian should be completely updated:
$ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get dist-upgrade
Step 4: Modify Release
For upgrading to the new Raspbian version, the package lists must be adapted to the “Stretch” release. To do this, only the word “jessie” has to be replaced by “stretch”. In order not to overlook any position, we simply let the replacement be done by the following command:
$ sudo sed -i /deb/s/jessie/stretch/g /etc/apt/sources.list $ sudo sed -i /deb/s/jessie/stretch/g /etc/apt/sources.list.d/*.list
Step 5: Updating package lists
The new package lists must then be updated and imported:
$ sudo apt-get update
Step 6: Update to βStretchβ
Now we are ready to start the upgrade:
$ sudo apt-get upgrade $ sudo apt-get dist-upgrade
The upgrade process is carried out in two steps: First of all, there is a minimal upgrade to avoid conflicts and then a complete upgrade. The upgrade may take a while depending on your Internet connection. A certain amount of attention is required during the update process, as some configuration files are also updated. Therefore, Raspbian asks several times if you want to replace certain configuration files with a new one. If you have made changes to individual configuration files yourself in the past, you should press D (display differences) or N (not replace) depending on the file, otherwise Y (to replace the old configuration file with a new one).
Step 7: Clean up installation
Old, unnecessary packages are removed after the system update with the following commands:
$ sudo apt-get autoremove $ sudo apt-get autoclean
Finally the Raspberry Pi has to be restarted.
Great Article, that’s what i needed!
BTW On raspberry 3 those operations takes ages!
Thanks. Good instruction, for the non VI users you could add that after using D for differences you need to :q to get out of there.
Kind regards,
Ben
You can as well use ‘q’ to exit the diff(1) output, so you don’t need the vi(1) command. At least that works for me.
It worked perfect. Thank you very much
@ziomson Imagine what it’s like on a 1 B+ lol
Worked fine. Thank you.
Your “German flag” points to some facebook page and not to the german version of this howto. Is that correct?
Thanks for pointing that out, I just fixed it.
Worked a charm, thanks π
I wasn’t prompted to deal with local changes to /etc/sysctl.conf during the upgrade but otherwise everything went smoothly.
Great instructions, and you hit some thing people sometimes forget. I hope the upgrade to Buster is just as easy. And I hope it comes soon!
This worked perfectly.
Perhaps you could mention that it’s worth checking out “sudo apt-get install apt-transport-https” to make sure the new repository will be accessible.
Should the “/etc/os-release” file reflect the new Stretch version after this process, or is it left behind?
The process seems to have worked for me.
Thank you!
Can i do this upgrade remotely trough ssh?
Yes, you can (I always do). To avoid problems caused by disconnections, you should call “screen” first.
I used a RPi ZeroW to test the upgrade. It took me about 6 hours to complete. I did loose some time at the prompt interactions (forgot to look at the terminal window), and also got a error about xrdp service not initializing at the end, so I had to reboot, purge vnc-server code, reinstall xrdp, apt-get install -f and apt-get dist-upgrade after the last autoremove/autoclean and reboot again to fix it. I ended using tightvnc to test the rdp gui. But I, it did work. Excellent job.
Thanks a lot. It’s best.
Thank you for your tutorial. Worked like a charm.
One question though, if anyone can answer: what’s the “/deb” in the “sed” command?
I know -i means the outpus is the same as the read file, /s from substitute, /g for global regex pattern, but I am puzzled what “/deb” is doing. Wouldn’t “/s/jessie/stretch/g” suffice?
Thank you.
The ‘/deb/’ is to search for lines wich have the string “deb” in them. I would probably used ‘/^deb/’, as it will restrict to lines with starts with string “deb”.
You can look at man page for sed(1) or ed(1) or awk(1) or even vi(1) to see how the search works. At least that is what I do remember it to work π
There are a debug switch to sed(1) that will help you debug these regular search lines. If I do remember it right. Have to read the manual. π