Ultimate Raspberry Pi Configuration Guide

The Raspberry Pi is a great thing: it is real computer, it is cheap ($40), it can interface with electronics, talk to the web and has full HDMI support.

However it runs on Linux, which I have a love-hate relationship with. I loveĀ the idea of Linux, but when I start messing around the command line and downloading packages and installing things, I often get lost.

Iā€™ve assembled bits and pieces from various online posts and guides into this Instructable, which is what I call the ā€œUltimate Raspberry Pi Configuration Guideā€.

What this Instructable does is to set up a wireless Raspberry Pi that allows you to:

  • ssh into from the Terminal window on the Mac (or equivalent on another machine).
  • run wirelessly with a static IP for each SD card.
  • automatically startup, no log in
  • set your the time zone
  • skip the GUI of the Raspberry Pi, which bogs things down and is unnecessary for most tasks
  • minimize any external monitor use, specifically never having to lug a monitor over to where the ethernet router lives
  • clone a ā€œbasic settingsā€Ā SD card so that we can have as many base-level installations as we want.

Right now, I have 3 Raspberry Pis running in my closet, each with a different purpose: one runs 7 Twitterbots, one is a Git server and one is an experimentation device for electronics. I plan to add more.

I wrote this Instructable for someone who has a secure home newtwork. You should have a router that can accept a direct ethernet cable. If you are working at an office, the network configuration

zsettings Iā€™ve outlined here might have to be adapted for your specific companyā€™s network/firewall.

Ultimate Raspberry Pi Configuration Guide

Step 1: Gather Materials

We need the following:

  • The Raspberry Pi itself
  • A power supply with a micro USB cable to power the Pi. Get a 2A one if at all possible
  • An 4gb SD card. For most cases, there isnā€™t a need for anything larger.
  • A USB wifi dongle. There are many of these that are Pi-compatible on the market
  • An ethernet cable to go into your home router

Not pictured, but needed: an HDMI monitor with an HDMI cable, a keyboard and some sort of ethernet router than lets you plug an ethernet cable directly into the back of it.

Step 2: Download Raspbian Wheezy

Unless you need special Linux capabilities, Raspbian/Wheezy is the recommended installation.

Download the package here: http://www.raspberrypi.org/downloads

Make sure you double-click the downloaded .zip so that you have a .dmg file. For the purposes of this Instructable, I leave the .img in my downloads folder.

Note: Iā€™m using a Mac as my host computer, but most of these instructions can be adapted for other operating systems.

Step 3: Initialize SD Card using Disk Utility

Use Disk Utility to initialize your SD card. It doesnā€™t matter what the name of the card is.

What does matter is that the format is MS-DOS (FAT). Format the SD card. It will only take a few seconds.

Quit Disk Utility when you are done.

Step 4: Copy the Wheezy Image onto your SD Card

Open the Terminal application on the Mac, which will be in your Applications folder.

For those of you unfamiliar with using this app, Terminal provides a command-line for controlling the underlying Unix operating system on Max OS X.

Type in (then press enter):

diskutil list

This will list all your mounted drives. You will see something like the image above: a list of drives with different partitions on them. You want to find the information pertaining to your newly-formatted SD card. In my case it is /dev/disk1s1. This may be different on your computer.

Now, unmount the disk using the Terminal command:

sudo diskutil unmount /dev/disk1s1

The device /dev/disk1s1 is from my setup ā€” yours may be different. Important: use the right device name on your system.

The precedingĀ sudoĀ command stands for superuser do. These are commands that can wreak havoc if misused, so will require your Admin password.

Youā€™ll be shown a message that your SD card has been unmounted. Its disk image will disappear from the desktop.

Hereā€™s where you want to pay close attention. We want to type in a command such as:

sudo dd bs=1m if=~/Downloads/2014-01-07-wheezy-raspbian.img of=/dev/rdisk1

Note that we are using the ā€œraw deviceā€, which means that the name /dev/disk1s1Ā maps to Ā /dev/rdisk1. Make sure you specify the appropriate raw device, i.e. if your SD device info from diskutil listĀ is /dev/disk3s1, use /dev/rdisk3 for the dd command.

Also, the filename or path for your wheezy-raspbian.img might be different that the one listed here, so please change it accordingly.

Terminal will ask you for your admin password since this was aĀ sudo command. Then you will have to wait longĀ awhile. There is no feedback that any copying is actually happening. This takes something like 30 or 45 minutes. Go have lunch.

Behind the scenes: what theĀ ddĀ command does is copy the disk image and do any necessary conversions.

Once theĀ dd process is done, Terminal will show you how many bytes were transferred to the SD card (about 2.9 gb). Eject the new SD card, which will be now mounted on your computer and be titled something likeĀ boot.

Congratulations, you have a bootable SD card for your Raspberry Pi!

Step 5: Basic Pi Configuration

Put the SD card in your Raspberry Pi, connect the keyboard, connect it to your HDMI monitor and plug in the USB power.Ā leave the wireless USB dongle disconnected.Youā€™ll see a black screen with a bunch of text, which shows all sorts of configuration details that you donā€™t need to worry about.

This will take you to a Raspberry Pi configuration screen. Youā€™ll see this only the first time. The options are:

1. Expand Filesystem: no need to do this ā€” some may disagree on this point
2. Change User Password: up to you
3. Enable Boot to Desktop/Scratch: by default, this is set to console, which is what we want to keep
4. Internationalisation Options:Ā set your timezone (if in the US, choose America, then find the correct city with your timezone)
5.Ā Enable Camera: no (you can always change this later)
6. Add to Rastrack: no
7. Overclock: this is up to you, I usually choose Medium, which makes the Pi run a little bit faster at the expense of power and potential component damange
8. Advanced options: choose A4 SSH ā€” this will enable secure shell access, which means that you can control your Raspberry Pi from a remote computer (extremely useful)

Choose Finish and reboot

When you get to a prompt, enter:

sudo nano /etc/default/keyboard

change XKBLAYOUT to =ā€usā€ ā€” assuming you are in the U.S., but you can set this to whatever the keyboard code is for your country. Here is a list of country codes from Wikipedia, use two-letter lowercase ones.

nano is a simple built-in editor. Type in ctrl-X and Y and overwrite to save the file.

Make these keyboard changes take effect by rebooting:

Ultimate Raspberry Pi Configuration GuideStep 6: Setting up Auto-login

Your Raspberry Pi will be without a keyboard and without a monitor and accessible only byĀ sshĀ ā€” at least thatā€™s the setup that Iā€™d recommend using. For that reason, we want to set it up to automatically login.After the reboot, at the command line, enter:

sudo nano /etc/inittab

now, scroll down to the line:
1:2345:respawn:/sbin/getty 115200 tty1

and comment it out by putting a ā€˜#ā€™ in front of it, such as:
#1:2345:respawn:/sbin/getty 115200 tty1

donā€™t worry if the 115200 reads as 38400 or anything like that, weā€™re just looking for the 1:2345 line

now add the line, beneath it:
1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Be super-careful to get the spaces exactly right.

Now:

sudo reboot

and the pi should automatically login.


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

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