Friday 18 August 2017

Raspbian Stretch

This post will show you how to install the Raspbian Stretch operating system onto a Raspberry Pi computer.

At the end of this post, we will have a Raspberry Pi running the Raspbian Stretch operating system, that can access the internet and be remotely controlled from a windows computer.


Install Raspbian Stretch onto Micro-SD Card:

First of all, we need to install Raspbian Stretch onto an Micro-SD Card. This is done using a Windows computer.

Note that older Raspberry Pis use SD Cards rather than Micro-SD Cards. For this blog I will refer to either of them as a Micro-SD Card.

Install Image Writer for Windows:

  • Download http://sourceforge.net/projects/win32diskimager/files/latest/download onto a Windows computer.

  • Double click on the downloaded executable file (in my case this is Win32DiskImager-1.0.0-install.exe).

  • A User Account Control message may now appear:

    • press the Yes button to run the program.

  • Setup - Win32DiskImager will now start:

    • Follow the instructions to install the program.

Write Raspbian Stretch onto Micro-SD Card

  • Download the latest version of Raspbian Stretch from https://www.raspberrypi.org/downloads/raspbian (press the Download ZIP button under RASPBIAN STRETCH WITH DESKTOP).

  • Open the downloaded zip file, and extract the downloaded image file (in my case this is 2017-08-16-raspbian-Stretch.img) onto your hard drive.

  • Insert the Micro-SD Card into the Micro-SD Card reader on the Windows Computer, and note the drive letter that is assigned to it.

    Note that ALL data that is currently on the Micro-SD Card will be lost, so ensure that any important data on it is saved elsewhere.

  • Right click the Win32DiskImager.exe program in windows explorer (the default installation puts this in C:\Program Files (x86)\ImageWriter), and click on Run as administrator in the popup menu that appears.

    Note that Run as administrator is necessary for Windows 7 and later. Users of earlier versions should just be able to double-click on the application to run it.

  • A User Account Control message may now appear:

    • press the Yes button to run the program.

  • A File Error message may now appear. If so, press the OK button.

  • Win32 Disk Imager will now start:
    • Press the Select a Disk Image button .

    • A Select a Disk Image window will appear:

      • Select the img file

      • Press the Open button

    • Select the drive that is assigned to the Micro-SD Card (in this case F:\) as the device:

    • Press the Write button.

    • A Confirm overwrite message will appear:

      • Press the Yes button.

    • Wait...

    • A message will pop up to confirm that the write is complete:


    • Close Win32 Disk Imager.

  • Now Eject and Remove the Micro-SD Card from your windows computer.


Start up the Raspberry Pi

  • Plug the following items into the Raspberry Pi (do NOT plug the power lead in yet):
    • USB Mouse
    • USB Keyboard
    • HDMI Lead (connected to a TV)
    • Micro-SD Card

    For older Raspberry Pi models (1 and 2) a WiFi dongle should also be connected to it now (a USB hub might need to be used for this).

  • Now plug the power lead in.

  • Switch on the TV (if it doesn't automatically) and select the Raspberry Pi input.

  • Wait for Raspbian Stretch to start.


Update Password

The default user for the Raspberry Pi is pi, with the password respberry.

For security reasons especially if you are going to connect to the internet, it is a good idea to change the password, which is what I will describe here.
  • Open the Applications Menu (at the top left of the screen), select Preferences, and click on Raspberry Pi Configuration in the menu that appears

  • A Raspberry Pi Configuration window will appear:

    • Select the System tab.

    • Press the Change Password... button.

    • A Change Password window will open:

      • Input a new password into both the Enter new password and Confirm new password input boxes.

      • Press the OK button.

    • A Password Changed message will appear:

      • Press the OK button.

    • Press the OK button to close the Raspberry Pi Configuration window.


Connect to WiFi

  • Click on the network icon at the top right of the screen and then on the WiFi name that you want to connect to.

  • The <wifi name> window will open:

    • Input the WiFi passcode into the Pre Shared Key input box.

    • Press the OK button.

  • Wait for the WiFi icon to stop flashing

Install a Firewall

  • Click on the Terminal icon at the top:


  • A Terminal window will open:

    • Input the following command at the terminal:
      sudo apt-get update
      This will update the list of available updates, and may take a minute or so to run.
      The pi@raspberrypi:~ $ prompt will appear once the command is finished.

    • Input the following command at the terminal:
      sudo apt-get install ufw
      This will install ufw (Uncomplicated Fire-wall), and may take a minute or so to run.
      The pi@raspberrypi:~ $ prompt will appear once the command is finished.

    • Input the following command at the terminal:
      sudo ufw enable
      This will activate ufw, the response will state that Firewall is active, and enabled on system startup.

    • Input the following command at the terminal:
      sudo ufw status
      The response will state that Status: active.


Control Raspberry Pi from a Windows Computer

Raspberry Pi Setup

  • Open the Applications Menu (at the top left of the screen), select Preferences, and click on Raspberry Pi Configuration in the menu that appears.

  • A Raspberry Pi Configuration window will appear:

    • Select the Interfaces tab.

    • Set VNC to Enabled.

    • Press the OK button to close the Raspberry Pi Configuration window.

  • A VNC icon will appear in the taskbar.

  • Click on the Terminal icon at the top:


  • A Terminal window will open:

    • Input the following command at the terminal:
      sudo ufw allow from any to any port 5900
      This will update the firewall (ufw, which we installed previously) to allow connections to the VNC server.

    • Input the following command at the terminal:
      exit
      This will close the terminal.

  • Click on the VNC icon in the taskbar (top right).

  • A VNC Server window will open:

    • Note the IP Address (e.g. 192.168.1.67) that is displayed under Connectivity.

Windows Setup

  • Download and install the VNC Viewer application from https://www.realvnc.com/en/connect/download/viewer.

  • Start the VNC Viewer application.

  • Input the IP Address that was got from the VNC Server window in the Raspberry Pi) into the Enter a VNC Server address or search input box, and press the return key.

  • An Identity Check (VNC Server Not Recognised) message might appear:

    • Press the Continue button.

  • An Authentication window will now appear:

    • Input pi as the Username input box (pi is the default user name on Raspbian Stretch).

    • Input your Raspberry Pi password (you changed this earlier) into the Password input box.

    • Press the OK button.

  • VNC viewer will now connect to the Raspberry Pi.


No comments:

Post a Comment