md
Domespic [2] Raspbian
December 13, 2016
Previous: Part 1 - Descriptions Next: Part 3 – Gateways

Install Raspbian on an SD Card

You will need a computer to download an image of an SD card containing the Linux operating system: Raspbian (Raspberry Debian ). Presently (Nov. 2016), the latest version is named Jessie. Download the zipped Raspbian Jessie Lite image from the Raspberry Pi site found here https://www.raspberrypi.org/downloads/raspbian/. This installation was done with the September 2016 image with a version 4.4 of the Linux kernel.

Unzip the image; its the only file contained in the archive.

Follow the instructions found at the Raspberry Pi site to install the Raspian Jessie Lite image on an SD card (or microSD card if using a newer Raspberry Pi). As noted above, there must be an SD card reader built in or connected to the desktop computer.

If the operating system on the latter is Windows, you will have to download a piece of software to write the Raspbian image file to the SD card. All the details including links to the needed software are in the specific instructions. Desktops running Linux or Mac OSX already have the needed software to copy the image file to the SD card. Over the years, I have used both Windows and Linux without problem.
Work slowly, follow carefully the instructions because it is possible to overwrite a disk connected to your main computer, including the one containing it's operating system.

I used GParted to expand the ext4 file system to about 6Gb. Then I defined another unknown partition to fill the rest of card. I should be able to copy the image to an 8GB SD card that I can test on an older Raspberry Pi.

Boot the Raspberry Pi

Insert the memory card into the Raspberry Pi, connect

and finally connect the power supply. If all goes well, Raspbian will boot up.

Very soon after the initial setup, the keyboard and monitor will not be needed and the Ethernet cable can be replace with a Wifi Usb dongle. Unfortunately, Wifi is not enabled by default so the dongle cannot be used initially instead of an Ethernet cable to establish a connection with your home network.
Login as "pi" with the "raspberry" password. Don't forget that the password is not echoed on the screen.

If you want to use a desktop computer to access the Raspberry Pi, whether it is running with or without a keyboard and monitor, you will have to open an SSH session. That will require knowing the pi's IP address. If a keyboard and monitor are hooked up to the Raspberry Pi, run ifconfig to see what IP has been assigned to the Ethernet interface:

pi@raspberrypi:~ $ ifconfig eth0 Link encap:Ethernet HWaddr b8:27:eb:56:8a:ff inet adr:192.168.0.144 Bcast:192.168.0.255 Masque:255.255.255.0 adr inet6: 2607:fed8:f180:c5a:4e92:7cbf:61c0:5787/64 Scope:Global adr inet6: be80::960:b75f:b651:e513/64 Scope:Lien adr inet6: 2607:a0a9:e080:d69::a/128 Scope:Global ...

If there is no keyboard and monitor connected to the Raspberry Pi, it is a bit more more difficult to find the assigned IP address. It may be possible to find it by logging into your local network's DHCP server (usually the router) and getting the list of connected devices. Unfortunately, only an IPv6 address was shown in my router's web page. When I disabled IPv6 on the Raspberry Pi (as discussed latter), the IPv4 address did show up. I could have used an IP sniffer program to find the Raspberry Pi; it was simpler to connect a keypboard & monitor!

Assuming that the IP address is known, use an SSH client on another computer on the same local network to log in using port 22 at the specified IP address. On a Windows computer I suggest PuTTY. On a linux machine, use ssh as follows:

[michel@serveur ~]$ ssh pi@Raspberry_Pi_IP_address
or
[michel@serveur ~]$ ssh Raspberry_Pi_IP_address - l pi

When you first log in, you may see something like:

The authenticity of host '192.168.0.144 (192.168.0.144)' can't be established. ECDSA key fingerprint is 11:22:33:44:66:77:88:99:aa:bb:cc:dd:ee:00:11:22. Are you sure you want to continue connecting (yes/no)?
Just answer yes.

Udpate Raspbian

First update the operating system:

pi@raspberrypi:~ $ sudo apt-get update pi@raspberrypi:~ $ sudo apt-get upgrade

This last step will take a long, long time. Treat yourself to a coffee. You may have time to finish reading Tolstoy's War and Peace.

Static IP Address

It is almost mandatory to assign a static IP address so that it will be simpler to log into Domoticz from a tablet, telephone or desktop computer. Also, if there is no DHCP server on the LAN that assigns an IP address, it will be necessary to assign a static IP address. As usual, changes have to be made to configuration files.

Open the dhcpcd configuration file in nano:

pi@raspberrypi:~ $ sudo nano /etc/dhcpcd.conf
Then add the following
interface eth0 static ip_address=192.168.XXX.YYY/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1 interface wlan0 static ip_address=192.168.XXX.ZZZ/24 static routers=192.168.0.1 static domain_name_servers=192.168.0.1

Of course, 192.168.XXX.YYY needs to be replaced by the appropriate ip address. The router and name server addresses must also be adjusted to reflect the home network's parameters. For argument's sake, I'll suppose that the address of Ethernet interface is set to 192.168.0.21 and that the address of the wireless interface (wlan0) is set to at 192.168.0.22.

Add the second group of settings if a wireless connection will be used. Note that the ip address must not be the same as that of the ethernet link.

Save the configuration file by pressing Ctrl+O (letter O not the number 0) and press Enter to save the file with its current file name. Exit by pressing Ctrl+X.

That single change used to be sufficient to assign a static ip address in previous versions of Raspbian. Unfortunately, it did not work with Jessie. After some searching, and seeing that on booting only a version 6 ip address seemed to be assigned to the interface, I found the following solution. Create the file /etc/sysctl.d/local.conf containing a single line disabling IPv6.

pi@raspberrypi:~ $ sudo nano /etc/sysctl.d/local.conf
net.ipv6.conf.all.disable_ipv6=1

Again, save the configuration file by pressing Ctrl+O (letter O not the number 0) and press Enter to save the file with its current file name. Exit the nano editor by pressing Ctrl+X.

Wireless Connection

If a Wifi-usb dongle is to be added to an older Raspberry Pi, it will be necessary to set it up. The following comes the Raspberry Foundations's documentation. Open the wpa-supplicant configuration file with the nano editor:

pi@raspberrypi:~ $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Go to the bottom of the file and add the following:
network={ ssid="Name_of_your_wifi_network" psk="your_wifi_password" }
The quotation marks are needed. Now save the file by pressing Ctrl+O (letter O not the number 0) and press Enter to save the file with its current file name. Exit by pressing Ctrl+X.

Don't forget to plug in the wireless USB dongle.

Configure the Raspberry Pi

By default, logs or journals are files saved on the SD card by the systemd. This may not be the best thing, since there is a limit on the number of reads and writes that can be performed on an SD card. It is best to write the log to memory.

Edit the journald configuration file, changing three lines as shown next.
[pi@raspberrypi ~]$ sudo nano /etc/systemd/journald.conf
# This file is part of systemd. # [Journal] Storage=volatile Compress=yes RuntimeMaxUse=48M
The source for this tweak is the Domoticz wiki . It may be best to hold of until all is stable before doing this so that logs will be persistent.

Next, move on to configuring the Raspberry Pi itself.

pi@raspberrypi:~ $ sudo raspi-config

config screen

Navigate in configuration utility with the Tab key to move from one control to the next, the up and down cursor keys to select a choice within a list, select a choice by pressing on the Enter key.

  1. The first option, Expand Filesystem (already highlighted), should have already been done, but you can go ahead and press enter and let the system do its thing. Don't reboot at that point.
  2. It's good practice to change the user password, especially if you will want to use the home automation software from outside your home. Just remember what you entered as a new password. Otherwise you will be up the proverbial river...
  3. There should be no need to change the boot option.
  4. Chances are that you will want to change some if not all of the Internationalisation Options.
  5. There is no need to enable the camera as none is used.
  6. It is possible to speed up the Raspberry Pi but there is a risk. If you do speed it up, consider installing a heat sink to dissipate the greater heat that will be generated.
  7. It is probably a good idea to change the (A3) Memory Split, to allocate a minimum of memory (16Mb) to the GPU since a graphical user interface is not used in Jessie Lite. The (A4) SSH server is probably enabled by default (it certainly is if you are doing all this from an ssh session). If you have more than one Raspberry Pi it may be a good idea to change the (A2) Hostname. The rest of the options can probably be ignored.

Select Finish when done. If the system does not reboot, it is probably best to force it:

pi@raspberrypi:~ $ sudo reboot

Previous: Part 1 Descriptions Next: Part 3 – Gateways