IoT

Upgrading Raspbian Stretch to Raspbian Buster

In this blog I want to note down in the shortest way possible how to upgrade your Raspberry Pi from Raspbian Stretch to Raspbian Buster.

Raspbian

First check your current version of Raspbian is Raspbian Stretch. The easiest way to do this is enter the following in your terminal.

1
2
3
4
5
6
7
8
9
10
$ 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"

In case it states version 8 (jessie) you can check out following blog first to upgrade first to Raspbian Stretch from Jessie. In case your output is version 9 (stretch) please continue below.

First I ensure at least all patches are installed on my current version. I always do this to reduce risks which might be caused due to very outdated packages.

1
sudo apt update && sudo apt upgrade

Next I will update my apt sources to use the new buster repos. You could do this manually by replacing stretch with buster in your /etc/apt/sources.list.d/* files, or you simply use below command that replaces it in an very simple straight forward way using sed. With cat you can validate the outcome of the file, just for the sake of your peace of mind.

1
2
3
4
5
6
$ 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
$ cat /etc/apt/sources.list.d/raspi.list
deb http://archive.raspberrypi.org/debian/ buster main ui staging
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ buster main ui

Now you can start to do the upgrade. This might take a couple of hours depending on your network speed. So make sure you have the time to continue on next steps. You will have to confirm and make a choice a couple of times. In my case I also got a broken package which I fixed using the apt --fix-broken install. You might not face this issue and therefore not require to execute this command.

1
2
3
sudo apt upgrade
sudo apt --fix-broken install #only if you got a broken package install in previous step
sudo apt upgrade-dist

Last but not least as recommended by the guys from Raspberry you can remove the following packages which are installed with Buster, but can’t be used on your Raspberry Pi. I also always clean up apt see the second and third command. As we did a distribution update I also give it a reboot.

1
2
3
4
sudo apt purge timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk clipit usermode gucharmap gnome-system-tools pavucontrol
sudo apt autoclean
sudo apt autoremove
sudo reboot

Last but not least you can now verify your os release, which should now state version 10 (buster).

1
2
3
4
5
6
7
8
9
10
11
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
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"

Summary

Summarized it boils down to the following set of commands to upgrade your Raspberry Pi to Raspbian Buster. To do this fully unattended I have added the -y flag on all commands.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$ 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"
$ sudo apt update && sudo apt upgrade -y
$ 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
$ sudo apt update && sudo apt upgrade -y
$ sudo apt --fix-broken install #only if you got a broken package install in previous step
$ sudo apt dist-upgrade -y
$ sudo apt purge -y timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk clipit usermode gucharmap gnome-system-tools $ pavucontrol
$ sudo apt autoclean -y
$ sudo apt autoremove -y
$ sudo reboot

Once rebooted you can verify once more your os version, which should now state version 10 (buster).

1
2
3
4
5
6
7
8
9
10
11
$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
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"

References:

Thanks for reading, please share with your friends.

Share