Upgrading your Raspberry Pi from Jessie to Stretch

The Debian team released their latest version of their operating system, Debian 9.0 Stretch back in June of this year, so it took a few months their Raspberry Pi variant, Raspbian to be adapted for Stretch but as of last month it is finally out!
Now usually with a major version upgrade I usually like to just do a clean install of the OS but I was feeling kind of lazy so I just decided to upgrade.

Note: Always be sure that your Raspberry Pi is backed up before you do a major upgrade such as this.

To upgrade, make sure that your current version of Raspbian Jessie is up to date by either in the terminal or SSH typing:

  • sudo apt-get update
  • sudo apt-get upgrade

Once Jessie is up to date, you’ll need to add the new repository for Stretch. To add the repository, type: sudo sed -i 's/jessie/stretch/g' /etc/apt/sources.list

Now, refresh your repository mirrors again by typing: sudo apt-get update

It’s now time to perform the upgrade. Go ahead and type: sudo apt-get upgrade again. It will prompt you several times during the upgrades about package conflicts and what not, for most cases the default option should be fine.

It should take about 15-20 minutes for the upgrade to complete depending on your internet connection. Once it’s done, go ahead and reboot your Pi by typing: sudo shutdown -r now

That’s it! You have now successfully upgraded your Pi to Raspbian Stretch!

My Raspberry Pi Setup

I recently had to reconfigure my Raspberry Pi because I bought a bigger micro-sd card for it (128 gb, up from my 8 gb). I thought I’d post my process since typically I do a headless install, meaning getting it up and running without a monitor, mouse or keyboard.

Flashing and Enabling SSH

First since I’m on macOS, I use a script called Pi Filler to flash the sd card with Raspbian. I still use the Raspbian image from April 2017 since the July 2017 image has something funky that messes with the flash process.

To use Pi Filler:

After you have Raspbian onto the sd card, you’ll need to enable SSH to run on boot.

To do this, you’ll need to create a blank file with the file name “ssh” and copy it to the root directory of the partition labeled “boot” on the sd card.

What I do:

  • Open Terminal on your Mac
  • Type the command “vim ssh” followed by “:wq”. This will create the empty file “ssh” in your home directory.
  • Then you can go into Finder and simply drag the “ssh” file to the “boot” partition.
  • Eject the sd card and put it into your Raspberry Pi

Once you connect your Raspberry Pi to power and ethernet, it should now boot up Raspbian with SSH enabled.

Logging in and Post Install

You will need to figure out the ip address of your Raspberry Pi in order to SSH into it. For myself, the quickest way to do this is to login to my router and look at the DHCP client table. If you don’t have access to your router, you can use a script called Pi Finder.

Once you find the local ip address of your Raspberry Pi, you can now login to it. For macOS and Linux, you just need to open your Terminal and type:

ssh pi@xxx.xxx.xxx.xxx

Where “xxx.xxx.xxx.xxx” is the ip address of the Raspberry Pi and enter the default password “raspberry”.

If you’re on Windows, you can use Putty to SSH in.

You can either decide to leave your Raspberry Pi on DHCP which means it’s ip address will change over time or you can set either the ethernet or the wireless adapter to always use a static IP address. I somewhat cheat on this, I setup DHCP Reservation on my router so every time I rebuild my Raspberry Pi, my router automatically recognizes my Pi and gives the ethernet adapter the IP address of and gives the wireless adapter the IP address of

The very first command that you will want to give your Raspberry Pi once you get logged in via SSH is: sudo apt-get update

This will make sure that your Pi knows where to go look for the latest software updates.

Just because I’m me and can’t stand not having my favorite text editor, vim, I usually install that next by typing: sudo apt-get install vim

After that it comes time to run: sudo raspi-config

This is a utility developed within Raspbian to configure it for the Raspberry Pi. The first option that comes up is to change the default password for the “pi” user. I usually do that first.

Then I go into Boot Options and Desktop/CLI. I always use Console with Autologin. Since I don’t use a monitor or VNC with any of my Pi’s there’s no point in it wasting memory and processor usage on loading up the GUI.

Finally, I go down to Advanced and hit Expand Filesystem. This repartitions your sd card to use the entire free space on your card.

After all of that, when you quit raspi-config it should prompt you to restart but if it doesn’t, enter: sudo shutdown -r now to go ahead and reboot your Pi.

Finally, the last thing that I do after it comes back up is: sudo apt-get upgrade This will upgrade all of the packages on your Pi to the latest versions.

Optional: Setup Wireless

I usually always run my Raspberry Pi’s off of wi-fi just to be able to put them anywhere I want and out of the way.

To setup your Raspberry Pi to automatically connect to your wireless network, type in the following command in your SSH prompt: sudo vim /etc/wpasupplicant/wpasupplicant.conf

At the end of that file add:

ssid="Your wireless network name"
psk="Your wireless network password”

Once you do that, your Raspberry Pi will automatically connect to your wireless network the next time you reboot.

Optional: Setup External Hard Drive

I have a one terabyte external hard drive connected to my Raspberry Pi just to give me some extra space.

To add an external hard drive, firstly create the directory where you will want to access the drive. For myself, I usually use: /mnt/e so at your SSH prompt, type sudo mkdir /mnt/e

Then you’ll need to identify the device name for your drive. Typing: sudo fdisk -l will list all of the storage devices connected to your Raspberry Pi. You should be able to tell which device is your external drive based on capacity. But more than likely, if you only have one additional drive connected, it’s going to be /dev/sda1

If this is a new drive, you’ll want to format it to the Linux file system, ext4. To do this, at the SSH prompt, type: sudo mkfs.ext4 /dev/sda1

Lastly, you’re going to want to make that drive mount on boot, so type sudo vim /etc/fstab and at the end of that file, add the line: /dev/sda1 /mnt/e ext4 defaults 0 0

And there you have it! The next time your Raspberry Pi reboots, it will mount your drive on the directory /mnt/e!