I am setting up a second Raspberry Pi … decided this time to log all the update and installation steps for later use.
A. Setting up the operating system on an SD card
- Download a disk image from raspberrypi.org. Whatever method you use, you should end up with a file ending in .img. This is your disk image file.
- Copy the disk image file to an SD card. A 4GB SD is fine, as is 8GB. On the mac, can use Pi Filler . For detailed instructions for copying to an SD card using any operating system, see elinux.org
- Configure the system: Attach RPi to a television with an HDMI cable. Attach keyboard, with mouse attached to keyboard. Insert wifi dongle. Attach power. After the RPi boots up, you will be presented with a screen that allows you to set a password (make it strong!), locale, time zone, etc. I always enable ssh, since I almost always un “headless”. Configure and reboot.
- Setting up wifi. After logging in, issue the command
startx. When the GUI boots, up, double click on the Wifi setup wizard and configure the wifi card for your network. You will need to scan, select a network, double click on that network to bring up a dialogue box that allows you to enter a password (PSK) and say “add”. - Find your IP address. After configuring Wifi, reboot. Towards the end of the boot process, you will see a message that gives your IP address, e.g., 10.0.1.21 Note this address and shut the RPi down.
- Connect the the RPi: plug the RPi in. Go to your favorite computer, connected to the same Wifi network. Connect to the RPi using ssh, e.g.,
ssh pi@10.0.1.21.
B. Update the system and add packages
- Update the system:
$ sudo apt-get update $ sudo apt-get upgrade
- Add wifi networks that you commonly use. To do this, say
sudo nano /etc/wpa_supplicant/wpa_supplicant.confto edit the relevant configuration file. You will see entries like the following:
network={ ssid="mynetwork" psk="foobar1234" proto=RSN key_mgmt=WPA-PSK pairwise=CCMP auth_alg=OPEN }Duplicate this entry as many times as needed, then change the ssid and psk, aka network name and password.
- Reserve DHCP address. You will lead a more peaceful life if you reserve a DHCP address on your router for your RPi. This ensures that each time you want to ssh to the RPi, it will have the same IP address. Here some directions for DHCP reservations.
- Install the tight vncserver so that you can connect to the RPi with a graphical UI:
$ sudo apt-get install tightvncserver
Then ssh to the RPi and say
$ vncserver :1
On the “computer” side, run a program like chicken on the mac, ….
C. Essential shell scripts. Put these in /usr/local/bin. Be sure to say chmod u+x pathtoscript. Then run script as sudo script name/
- Backup to remote computer:
#!/bin/bash # filename = backup # purpose: back up home directory to remote folder # usage: $ backup rsync -a --delete -e ssh /home/pi frodo@10.0.1.44:/Users/frodo/backup-rpi &> /dev/null
Even though
backuphad user and group execute permissions set (bychmod u+x backupandchmod g+x backup, I could not execute$ sudo backup. The problem was solved by adding the user pi to the group staff:usermod -a -G staff pi. - An installation script. It is worth your while to develop an installation script for your current setup so that you can clone as need be. Below is one that I use. After the above steps have been completed, copy your backup script to the new machine, then say
sh backup.sh# basic_install.sh -- backup all files in /home/username # execute by $ sh basic_install.h echo "Updating ... \n" apt-get -y update echo "\n\nUpgrading ... \n" apt-get upgrade echo "\n\nInstalling tightvncserver ,,,\n" apt-get -y install tightvncserver echo "\n\nInstalling emacs ...\n" apt-get -y install emacs echo "\n\nInstalling git ...\n" apt-get -y install git echo "\n\nInstalling motion ...\n" apt-get -y install motion echo "\n\nInstalling mpc and mpd ...\n" apt-get -y install mpc mpd echo "\n\nInstalling gnuplot ...\n" apt-get -y install gnuplot-x11
The -y option automatically gives the “yes” answer to any questions that apt-get might ask. Thus you can do an unattended install.
/li>
<
D. Gotchas
If you change SD card (ie.make up a new one, as above) and then try to ssh to the RPi computer, you will receive a message saying that ssh failed because of security issue. Something like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the RSA key sent by the remote host is blah blah blah Please contact your system administrator. Add correct host key in /Users/foo/.ssh/known_hosts to get rid of this message. Offending RSA key in /Users/foo/.ssh/known_hosts:25 RSA host key for 10.0.1.43 has changed and you have requested strict checking. Host key verification failed.
You will need to do
$ sudo emacs /Users/foo/.ssh/known_host
then search for the IP address that you ssh’d to, and delete the that IP address and its associated RSA key. Then you can proceed as before and accept a new RSA key. You will then get a message like this:
The authenticity of host '10.0.1.43 (10.0.1.43)' can't be established. RSA key fingerprint is d5:93:4a:1d:0b:11:14:48:7a:72:90:98:03:82:57:23. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '10.0.1.43' (RSA) to the list of known hosts.

















