Installing Raspbian on the Pi

8Mar - by Simon - 0 - In SysAdmin

These instructions accompany the series of Techno Babble articles covering Hadoop on the Pimicrosd card but should be useful for any minimal Pi builds using Raspbian Jessie Lite.

You will need a PC or a Mac to download the Raspbian image, with an SD slot to copy the operating system image onto a MicroSD card suitable for the Pi.

Note: Debian – the Linux distribution on which Raspbian is based – has a number of versions of which “Jessie” is current at the time of writing. Jessie is otherwise known as Debian 8 and the variant on the RaspberryPi.org website is specially compiled to work on the Raspberry Pi processor (which comes from a family known as ARM). Future versions of Debian will likely be ported to Pi / ARM-based systems and will be available at the same location. Planned Debian versions after Jessie include “Stretch” (Debian 9), “Buster” (10) and “Bullseye” (11) but no release dates have been published at the time of writing. So, you may see Jessie replaced by Stretch in the near future. These instructions should still apply but you can always get help and guidance on the RaspberryPi.org website.

Quick Checklist

The basic steps, described in more detail below, are:

  1. Download Raspbian Lite from the RaspberryPi.org website
  2. Unzip to extract the .img file
  3. Prepare and Write the .img file to the SD card
  4. Configure the Pi with raspi-config
  5. optionally Update firmware using rpi-update
  6. Update software using apt-get
  7. Reboot and confirm operation

 

Download Raspbian

It is worth going to the RaspberryPi main site to grab the latest, zipped image. This can be considered the definitive ‘source’ and safer than using other sites. https://downloads.raspberrypi.org/raspbian_lite_latest

Note: For the Hadoop project, we are interested in the Lite version only. These instructions partially apply for the full version which includes a full graphical user interface (typically either the GNOME or PIXEL interfaces are bundled with Raspbian).

Once on the page, select the ZIP version of the Raspbian Lite and this will trigger a download to your machine. You should see a file named 2017-01-11-raspbian-jessie-lite.zip or similar.

Note: you can verify that the downloaded file is complete and untampered using the SHA1 digest provided on the download page. Find out how to do this here for Windows, or here for Mac.

Unzip the image

Open the downloaded file with your unzipping package (typically double-click on the file in Windows Explorer or OSX Finder and it will be done for you) and this will extract the image file – same name but with a .img extension instead of .zip. This is the file you need to write to the SD card to be used in your Pi.

Note: if you do need an unzipping utility then these can be downloaded free. Try 7Zip (for Windows) or The Unarchiver (Macintosh).

Write the .img file to the SD card

Preparing and writing to an SD card is relatively straightforward. Technically, you use a MicroSD card for the Pi – usually provided with a large SD card adapter into which the miniature card sits, and can be inserted into a standard SD slot on your PC or Mac, or into a USB adaptor or card reader.

micro SD card with adapter

Writing the image file to the card requires command line knowledge or the use of a (free) piece of software. Rather than repeat it here, check out the clear and simple instructions on the RaspberryPi.org site.

When complete, you can remove the card from the PC or Mac and insert into the target Pi board (remove the MicroSD card from the adapter and insert to the Pi board, label facing down, with the metal contacts towards the board and inserted first). Connect up a screen and keyboard and you are ready to boot and build the Pi.

Configure the Pi with raspi-config

Once booted, the Pi should present a login prompt. Login as the default user pi with a password of raspberry. You are now able to configure the system using the raspi-config utility. Type raspi-config at the prompt and press enter. You should be presented with a menu as follows:

You can now go through these options and set the various aspects of your Pi. Use the arrow keys to move between options, Tab to move to the Select or Finish options and hit Enter to action the highlighted option or action. You can get more details on the RaspberryPi.org site.

raspi-config main menu

The raspi-config options are:

1. Change password … : you can change the password for the Pi user from raspberry to something else. The Pi user is a privileged username on the Pi and can do pretty much everything the root user can do. Make sure you do not forget this password as it will be needed to access the Pi later.

2. Hostname : you can change the hostname to something meaningful. Typically this matches a setting in your network DNS but if you do not have a DNS system then select something short, unique and relevant. For the Hadoop project, this might be data-master for the first machine in the cluster (see the network design article here).

3. Boot Options : useful to make sure that this is set for CLI. Choose B1 Desktop / CLI then B1 Console and press Enter – this sets the system to always boot to text mode (i.e. no GUI or Graphical User Interface which means you use the CLI or Command Line Interface) and requires the user to enter a username and password to login.

Once completed (OK is selected and Enter pressed) you will be returned to the main raspi-config menu.

4. Localisation Options : these are important to ensure that your keyboard works properly and the time and date are set correctly.

a. Select I1 Change Locale and select the most appropriate location for your system – you can select multiples if you wish to switch between different locales in live use but for our purposes, just select the most appropriate (scroll down to it using the arrow keys and tap the spacebar to highlight it with an asterisk against the entry. Tap again to de-select) and tab to OK and hit The example below shows the English UK UTF-8 option highlighted.

b. Select I2 Change Timezone and select through the region and city/locale options to select the most appropriate. The example below shows UK, London selected.

raspi-config-4-localisation-timezone-Europe-London

c. Select I3 Change Wi-fi Country to select the most appropriate location for your WiFi. This configures the channels used by the WiFi chip in the Pi3 for your location. Defaults settings are usually OK but go through this option these if you are unsure.

5. Interfacing Options : these include the peripherals for the Pi, most of which we are not concerned with. However, we do need the SSH server so select P2 SSH and select Yes to enable SSH access to the Pi (should be enabled by default but do this to be sure).

6. Overclock : can be ignored for the Pi3 as overclocking the CPU (making it run faster than normal) is not possible at this level.

7. Advanced Options cover multiple and important aspects of the Pi. For our purposes (relating the Hadoop cluster project) we are concerned with two settings (NB: do them in this order as the last will require a reboot).

raspi-config-7-advanced

A3 Memory Split : determines the amount of memory reserved for the display. As we are using a text (CLI) interface then set this number to 16 and select OK. This maximises the amount of memory left for running applications.

A1 Expand Filesystem : an important step which ensures that the whole of your MicroSD card is available for use. Once completed, you will need to reboot to activate the setting (can wait until other aspects are completed if required).

8. Update to update the tool to the latest version. Worth doing but will require that the Pi is connected to the internet.

Finally, tab to Finish and hit Enter to leave raspi-config. You will be given the option to reboot – no harm in doing this now but ensure you know the pi user password if you changed under option 1 above.

(Optional) Update firmware with rpi-update

Not needed these days. This utility installs the leading edge firmware and is not really necessary in normal use as apt-get (see next step) updates all that is needed. Simple enough to do if required but the Jessie Lite installation above does not include this utility so it needs to be installed. Very simple. Make sure you are logged in as Pi or root (or as a sudo-enabled user – see the details on setting up SSH for the Hadoop cluster for more details). If using root then drop the sudo prefix from the commands below. From the command prompt:

sudo apt-get update

Once completed (this command updates the package cache from the default Raspbian repositories and compares it to what is installed), execute the following from the command line:

sudo apt-get install rpi-update

Once completed successfully, you can execute the firmware update by simply typing

sudo rpi-update

at the command prompt. Messages will tell you if the firmward needs updating and, if so, will automatically complete this. Reboot if required once completed.

Update all software using apt-get

Again, as a privileged user execute the following from the command prompt (preceding each command with sudo if required):

sudo apt-get update

Once completed (this command updates the package cache from the default Raspbian repositories and compares it to what is installed), execute the following from the command line:

sudo apt-get dist-upgrade

This command updates all packages and the operating system to the current level. It may take a while so let it finish and check for error messages plus any configuration requests (some software updates require you to accept a new setting or configuration file – I find that accepting the default answer to any question is fine).

All Done !

You can now reboot and the Pi is ready to rock (type sudo reboot at the command line). At this point you can install packages using APT (e.g. sudo apt-get install <packagename>).  For example sudo apt-get install oracle-java8-jdk will install the standard Java SDK used for the Hadoop cluster build).


If this article on Techno Babble is incorrect, unhelpful or obscure then please comment below or let me know directly. Feedback is very welcome. There are many great resources on the ‘net for working with the Raspberry Pi – some of the best instructions for Raspbian installation include:

The official Raspberry Pi site is always a good place to start. https://www.raspberrypi.org/documentation/installation/installing-images/

A great beginners’ guide to getting started with a Pi by Gus is on PiMyLifeUp https://pimylifeup.com/how-to-install-raspbian/

Richard’s Ramblings – good material on minimising the Raspbian build but for information only. This approach is largely superseded by the Jessie Lite build used in the article above. http://www.richardsramblings.com/2013/02/minimalist-raspberry-pi-server-image/

Leave a Reply

Your email address will not be published. Required fields are marked *