Upgrade your Raspbian Pi

Preparing the Sources

To point apt-get at the new Raspbian version, you need to modify the file for package lists. Open /etc/apt/sources.list in a text editor like vi, Nano (Figure 2), or Joe. Put a # in front of the Wheezy source to disable it, and add a new line as shown in Listing 1 that points to the Jessie source. Save the changes and quit the text editor.

Listing 1

Adding a Jessie Source

deb http://mirrordirector.raspbian.org/
  raspbian/ jessie main contrib non-free rpi
Figure 2: This is a terminal window on an Ubuntu machine. I've logged in to my Raspbian Pi via SSH, started the screen program, and opened /etc/apt/sources.list in Nano.

On a standard Raspbian system, you need to deal with two more package lists:

root@raspbi:~# ls /etc/apt/sources.list.d
collabora.list  raspi.list

Both files contain addresses to other Raspbian mirrors. While I was writing this article, no Jessie packages were available for the collabora source, so I opened /etc/apt/sources.list.d/collabora.list in an editor and put a # in front of the line starting with deb to deactivate it. The raspi source was working fine, so I changed it to Jessie. The file /etc/apt/sources.list.d/raspi.list should look like this:

deb http://archive.raspberrypi.org/debian/ \
  jessie main

With the following command, fetch the list of available packages for the new release:

root@raspbi:~# apt-get update
Get:1 http://mirrordirector.raspbian.org \
  jessie Release.gpg [490 B]
Get:2 http://mirrordirector.raspbian.org \
  jessie Release [14,4 kB]
Get:3 http://mirrordirector.raspbian.org \
  jessie/main armhf Packages [8.962 kB]

Step by Step

Because a full upgrade might remove a large number of packages that you might want to keep, it is recommended that you first do a minimal upgrade and then the full distribution upgrade. For the minimal system upgrade, type

sudo apt-get upgrade

The package manager is now getting new versions for those packages that can be upgraded without requiring any other packages to be removed or installed (Listing 2).

Listing 2

apt-get upgrade

root@raspbi:~# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
417 upgraded, 0 newly installed, 0 to
  remove and 296 not upgraded.
Need to get 155 MB of archives.
After this operation, 11.4 MB of additional
  disk space will be used.
Do you want to continue? [Y/n]

Hit return and let APT do its magic. During the installation process, you will see questions regarding the restart of existing services (Figure 3). Debconf, the configuration management tool, will also ask about the configuration or re-configuration of several packages. You can keep your existing configuration file or replace it with the package maintainer's version. To ensure system consistency it is normally a good idea to accept the new version. You can always revert to your own configuration later – the old file is still there and marked with the .dpkg-old extension.

Figure 3: It's up to you – decide whether you want the services to be restarted automatically or not.

Once the minimal upgrade process has finished, you're ready to continue with the main part of the upgrade:

apt-get dist-upgrade

As with the previous command, you will see a list of packages that can be upgraded or removed. Sometimes the package manager needs to install new packages (usually new library versions or renamed packages) to resolve dependency issues. On my test machine, it also wanted to remove 13 packages that were no longer needed.

As soon as no more packages are listed to be updated, you should clean up by running

apt-get autoremove

to get rid of packages that were automatically installed as dependencies for some other components that are no longer needed.

Now it's time to reboot and check out that new Raspbian Jessie system.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content