How to Install and Set Up Raspian on Raspberry Pi

This is a condensed version from adafruit website (simon monk). I made this so everything is on one webpage and is easier to navigate.

Overview
When you buy a Raspberry Pi, it may or may not be sold with an SD card. The SD card is important because this is where the Raspberry Pi keeps its operating system and is also where you will store your documents and programs.  
learn_raspberry_pi_overview.jpg
Even if your Pi came with an SD card with the operating system on, it is a good idea to update it to the latest version, as improvements and bug fixes are going in all the time. Since putting the operating system onto an SD card wipes everything else off the card, it is worth considering using a USB flash drive for your documents, so that when you install a new version of the operating system, you don't have the complication of copying them off somewhere safe before reformatting the SD card.
If your Pi did not come with an SD card then the minimum size you should get is 4GB, but buy a bigger SD card if you think you will need the space.
This lesson shows you how to create an SD card for your Raspberry Pi.


You Will Need

To prepare an SD card for your computer, you will need:
A 'regular' computer with a built-in SD card reader, or an add-on USB SD card reader. The instructions here are for Windows and Mac. You can pick up a tiny microSD card reader/writer that is nice and fast and works with all USB-ports at the Adafruit shop. Please check what version of raspberry you have. The older version uses regular SD card. Newer B+ model uses microSD.
learn_raspberry_pi_ID939_LRG.jpg
learn_raspberry_pi_SD102_MED.jpg

Downloading an Image

The operating system that will be installed onto the SD card must be downloaded from the Internet. This will usually be a zip file that then extracts to a file of type .img an image file. Whatever image file you download, the actual installation process is the same.

Choose your Operating System

There are a bewildering number of operating systems that you can install on your Raspberry Pi, if you are a beginner, then do not consider anything except one of the Linux distributions, and if you are an advanced user, then you probably won't be reading this anyway.

Choose your Distribution

Having decided you want to install Linux, that is not the end of the story. You now have to decide which distribution or 'distro' of Linux you want to install. Being an Open Source operating system, anyone can take one of the existing distributions an add things to it or configure it in a certain way before packaging it up as another distribution option for anyone to use. This is how the most common Raspberry Pi distribution 'Raspbian' came into existence. The 'Debian' distribution was configured and kitted out with useful things like IDLE (a python-programming language development editor) and Scratch (a learn-to-program gaming system) to make it suitable for the Pi. Adafruit have then taken Raspbian and configured it to make it as easy as possible to use the GPIO connector to attach DIY electronics to the Pi.
All of the Adafruit tutorials (and nearly every other tutorial online) will work with either so we suggest picking one of the two:
In fact, if like me, you decide to keep your documents on a separate USB Flash drive, it is no bad thing to buy two SD cards and try both.
In appearance, there is very little to choose from between the two. When it come to how it behaves, then 'Raspbian' is the more 'standard' distribution, but then Occidentalis is more electronics-hardware ready.
Having said that, both distributions are regularly updated and each will no doubt incorporate features found in the other.
Incidentally, the name Occidentalis come from the Latin name for the raspberry (Rubus Occidentalis).
So, having made your choice, download the zip or img file and if it is in a zip file unzip it onto the Desktop.


Making an SD Card Using a Windows Vista / 7

There is a very useful utility that we can use to write a SD card available for Windows 7 and Vista. It is not unfortunately available for Windows XP.
Step 1.
Step 2.
This will download a zip file that you must extract. The result will be a folder called 'faii-1.0.2-3-x32'. If you keep this outside of the Program Files area then you will be able to run it without changing its privileges. You can just leave it on your Desktop.
Step 3.
Eject any external storage devices such as USB flash drives and backup hard disks. This makes it easier to identify the SD card. Then insert the SD card into the slot on your computer or into the reader.
Step 4.
Right click to run the file fedora-arm-installer.exe as an administrator. This will launch the following application.
learn_raspberry_pi_fail1.png
Step 5.
Select the image file and device.
To do this, click the Browse button and navigate to the .img file for the distribution that you want to install and the select the device from the drop-down.  
learn_raspberry_pi_fail2.png
Check that you have the right device, as it will be reformatted, and then click Install.
It will take a few minutes to install, but once the SD card is ready, you will see the following.
learn_raspberry_pi_fail4.png
That's all there is to it. Your SD card is ready for use in your Raspberry Pi.

Making an SD Card Using a Mac

Ray Vijoen has created a useful script that makes it really easy to make an SD card using a Mac. It is a shell script that takes all the necessary steps to create the SD card, including formatting it. You still have to run it from the command line.
Step 1.
Download Raspberry-PI-SD-Installer-OS-X fromhttps://github.com/RayViljoen/Raspberry-PI-SD-Installer-OS-X
Look for the 'zip' button at the top and download it as a single zip file.

Step 2.
Extract the zip file. It will expand into a folder called 'Raspberry-PI-SD-Installer-OS-X-master'.

Step 3.
Use Finder to move the img file that you downloaded earlier into the Raspberry-PI-SD-Installer-OS-X-master folder.
You can see here that I have both the Occidentalis and Raspbian images in the folder. That is fine, you can have as many images as you like in the folder.
learn_raspberry_pi_00_screen_folder_contents.png
Step4.
Open the Terminal app – you will find this in the Utilities folder of your Applications folder on your Mac.
Then type the command 'cd' followed by the path of your Raspberry-PI-SD-Installer-OS-X-master folder.
learn_raspberry_pi_01_screen_cd.png
Step 5.
Eject any external drives that you have connected to your computer. This just makes it easier to identify the correct drive that corresponds to your SD card.
Insert the SD card that you want to use. Note that all data on this card will be erazed.

Step 6.
Run the Pi Installer by typing the following command into the Terminal:
> sudo ./install Occidentalis_v02.img
'Occidentalis_v02.img' is the name of the img file for the distribution that you want to install.
You will be prompted for your Mac password and then should see this:
learn_raspberry_pi_02_screen_select_drive.png
Step 7.
Enter the number next to the SD card drive. Make sure you get this right, because whichever drive you select will be erased.
It is then just a matter of waiting until all the image file is installed. This will take a few minutes. You can check on the progress by pressing ctrl-T
When everything is complete, you should see this:
learn_raspberry_pi_04_screen_complete.png
Thats all there is to it, the SD card is now ready to use with your Raspberry Pi.

Test & Configure

learn_raspberry_pi_overview.jpg
If you plan to use multiple SD cards, it is not a bad idea to label them. Put the label on the side that shows when the SD card is inserted into the Pi.
Testing the card is easy - insert it into your Pi, then connect a keyboard to the USB port and a NTSC/PAL TV to the composite port or an HDMI monitor to the HDMI Port. Then power it by connecting a Micro USB cable to the Pi and powering it via a computer or a USB wall charger
You should see something like the following, an Adafruit/Raspberry logo in the top left, and a ton of text filling up the screen
learn_raspberry_pi_adafruit_833.jpg

In the next tutorial, you will find out how to configure your Raspberry Pi the first time you boot it up.

Overview

In the first lesson of this series, we showed you how to prepare an SD card containing an operating system for your Raspberry Pi. In this lesson, we will show you how to setup your Raspberry Pi the first time you boot it up.
learn_raspberry_pi_raspi-config_main.png
We do this using a tool called Raspi-Config that runs automatically the first time you boot your Raspberry Pi. This starts before the windowing system and so you have to use the cursor keys and Return key to navigate the menu system.

It is a bit like adjusting the BIOS settings on a PC, once you have things right, you probably won't need it again. We will start with the options that are most important and then look at some of the other options that you may wish to configure.

Using the Whole SD Card

This may seem a bit strange, but by default the Raspberry Pi only uses as much of the SD card as the operating system requires. This means that even though you might have used a large SD card, the operating system won't use it.
learn_raspberry_pi_raspi-config_expand_1.png
To fix this so that all the space on the SD card can be used, use up / down cursor keys to select the 'expand_rootfs' menu option and hit return. 

Once you do that, there will be some screen flashing as a script is run and then you will see the following confirmation.
learn_raspberry_pi_raspi-config_expand_2.png
Press Return again to return to the main menu.

Using the Whole Screen

Being designed to work with TVs, you may find that your Pi is only using the middle portion of the screen and there is a big unused area all round the screen.
learn_raspberry_pi_raspi-config_overscan1.png
This is not true of all TVs and monitors, but if its happening for you then selecting the option to Disable Overscan may fix this for you.
learn_raspberry_pi_raspi-config_overscan2.png
Use the left and right cursor keys to make your selection and then hit Return. 

If after disabling overscan, you cannot see the left edge of the screen then see the section 'Running Raspi_Config After Booting'.

Changing Timezone

Skipping past a few options for a moment, the next thing that you almost certainly need to do is (unless you live in the GMT timezone) is to change the timezone.
learn_raspberry_pi_raspi-config_timezone1.png
From the options, first select the Geographic Area, then the Timezone within that area.
learn_raspberry_pi_raspi-config_timezone2.png
learn_raspberry_pi_raspi-config_timezone3.png

Booting into Desktop

By default, when the Raspberry Pi boots, you just get a command line. No windows just a terminal where you can login and type commands. 

The final configuration that you definitely want to make, unless you don't like windowing environments is to change the boot behaviour so that it automatically starts the windowing system and logs you in.
learn_raspberry_pi_raspi-config_boot_1.png
Select the sensible option and hit Return.
learn_raspberry_pi_raspi-config_boot_2.png

Other Options

The options described above are those which could pretty much be considered essential when running your Raspberry Pi for the first time. There are some other options listed that are worth describing briefly.
  • configure_keyboard – as it implies allows you to chose from a long list of keyboard layouts.
  • change_pass – allows you to change the system password for the user 'pi' the default user on the system. By default, this password is 'raspberry' so those preoccupied with security may wish to change the password.
  • change_locale – For non-English speakers, you can select which locales should be available on the system and which should be the default for the operating system.
  • memory_split – allows you to adjust how much of the shared system memory is available for graphics and how much for the main processor. If you plan to run graphics hungry games, or video playback, then you may decide to alter these settings.
  • ssh – in a later tutorial we will look at remote controlling your Pi from another computer using ssh. This option allows you to enable ssh so that you can do that.
  • update – this option tries to find a newer version of Raspi_Config and download it. It is possible that new options will be added to the system in the future, so you may wsh to do this.

Running raspi-config After Booting

You can run raspi-config any time you like, if you find that there are some settings that you need to make.
Click on the desktop icon 'LXTerminal' to open a terminal session.
learn_raspberry_pi_terminal.png
Then enter the following command and hit return:
Copy Code
  1. sudo raspi-config



Test & Configure

learn_raspberry_pi_reboot.png
Reboot your Pi – click the icon bottom right – and this time you should boot straight up into the windowing environment.
In the next tutorial, we will look at configuring WiFi and finding the IP address of your Pi.

Overview

One of the first things that you will want to do is to get your Raspberry Pi connected up to the Internet.
In this lesson, you will learn how to:
  • Connect using an Ethernet cable
  • Use a WiFi adapter with both Raspbian and Occidentalis
  • Find out the IP address of your Raspberry Pi
learn_raspberry_pi_network_LEDs.jpg

Using a Wired Network

The quickest way to get your Raspberry Pi connected is to use an Ethernet patch cable and just plug it into the back of your home network router.
learn_raspberry_pi_router_connection.jpg
As soon as you plug your Pi in, you should see the network LEDs start to flicker.
learn_raspberry_pi_network_LEDs.jpg
For most home networks, you should also be able to connect to the Internet without any further configuration. For this to work, your router should be configured for DHCP (Dynamic Host Configuration Protocol). This service runs on your home network router, dishing out IP addresses to any device that connects to it either through WiFi or by cable.
If DHCP is not turned on, on your home network router, then connect to its management console using a different computer that is already connected.
You should be able to find a setting somewhere that turns it on.
learn_raspberry_pi_router_admin.png

Buying a USB WiFi Adapter

Look for a WiFi adapter that supports the RTL8192cu chipset, as both the latest Raspbian and Occidentalis distributions both have support for this built-in and we've found its much faster than the Ralink chipsets
If you already have a WiFi adapter, just give it a go, even a lot of the very low cost budget adapters will work without any trouble.
learn_raspberry_pi_wifi_adapter.jpg
WiFi does however use quite a lot of power, so check the power rating of your power supply. Some WiFi adapters require an external power supply to work well. We suggest the 5V 1A power adapter in our shop if this is the case. All of the WiFi adapters we have in the Adafruit shop will work just fine this way.
If you have a WiFi adapter plugged in, then you no longer have two free USB sockets available for your keyboard and mouse, so you may also need a powered USB hub.

Setting up Wifi with the Graphic Interface

Setting up WiFi requires that your router is broadcasting the SSID. Make sure you have "Broadcast SSID" set up on your router! This will not work with "private" SSID setups
Raspbian releases after 2012-10-28 include a WiFi configuration utility. You will find the shortcut for this on the Desktop. If you are using command-line tools or are logging in over Ethernet, check the next page for how to edit/etc/network/interfaces by hand
learn_raspberry_pi_wifi_config_icon.png
Step 1.
Double-click the icon and this is what you will see.
learn_raspberry_pi_wpa_gui_1.png
Step 2.
Click on the Scan button and a second window will open. Find your Wireless access point in the list and double click on it. This will open another window.
learn_raspberry_pi_wpa_gui2.png
Step 3.
Enter your password in the PSK field and then click Add. When you look at the first window, you should see that the connection is all set up for use. You can connect or disconnect using the buttons. Notice also the IP address of the Pi is shown at the bottom of the window.
learn_raspberry_pi_wpa_gui5.png

Setting up Wifi with the Command Line

This tutorial works best if your router is broadcasting the SSID. Make sure you have "Broadcast SSID" set up on your router! This may not work with "private" SSID setups
Setting up WiFi in Occidentalis, is also pretty straight forward. You just need to add the name of your wireless network (its SSID) and your password to a configuration file.
Step 1.
Boot the Raspberry Pi without the WiFi adapter plugged in.
Step 2.
Open a Terminal session by clicking on the LXTerminal icon, and enter the following command into it:
Copy Code
  1. sudo nano /etc/network/interfaces
learn_raspberry_pi_occ_1.png
Copy Code
  1. auto lo
  2.  
  3. iface lo inet loopback
  4. iface eth0 inet dhcp
  5.  
  6. allow-hotplug wlan0
  7. auto wlan0
  8.  
  9.  
  10. iface wlan0 inet dhcp
  11. wpa-ssid "ssid"
  12. wpa-psk "password"
If you are using a 'hidden' SSID, try the following (hat-tip tohttp://www.dafinga.net/2013/01/how-to-setup-raspberry-pi-with-hidden.html)
Copy Code
  1. auto lo
  2.  
  3. iface lo inet loopback
  4. iface eth0 inet dhcp
  5.  
  6. auto wlan0
  7. allow-hotplug wlan0
  8. iface wlan0 inet dhcp
  9. wpa-scan-ssid 1
  10. wpa-ap-scan 1
  11. wpa-key-mgmt WPA-PSK
  12. wpa-proto RSN WPA
  13. wpa-pairwise CCMP TKIP
  14. wpa-group CCMP TKIP
  15. wpa-ssid "My Secret SSID"
  16. wpa-psk "My SSID PSK"
  17.  
  18. iface default inet dhcp
Step 3.
This opens an editor screen of the wifi configuration file you need to change.
learn_raspberry_pi_occ_2.png
The two places where you need to make a change are on the last two lines. Change the file so that it looks like this:
learn_raspberry_pi_occ_3.png
Of course, you should put in your network and password! Note that you need to keep the double-quote characters around your wireless network name and password.
This kind of editor does not let you use the mouse. Instead, use the cursor keys to move around the file.

Step 4.
When you have finished press [ctrl]x. This will ask if you want to save the modified files.
learn_raspberry_pi_occ_4.png
Press 'Y' and then Return to save the file with the same name.

Step 5.
Shut down your Raspberry Pi, plug the WiFi adapter in and start it up again. You should find that the Raspberry Pi connects using the WiFi adapter as it boots up.

Finding Your Pi's IP Address

You can find the IP address of your computer, either by opening the WiFi setup tool again. The IP address will appear at the bottom of the Window.
If you are using Occidentals, or you want to do this over a command line terminal. Open up a LXTerminal window and type the following command:

Copy Code
  1. sudo ifconfig
learn_raspberry_pi_ifconfig.png
Next to the wlan0 entry you will see inet addr: 192.168.1.10which is the IP address of the Raspberry Pi.

Remember! If your IP address starts with 192.168 or 10.0 then its an internal address - that means you can get OUT to the Internet but you cannot have someone outside your home or network reach your Pi via the IP address. This is important if you want to have a webserver running on a Pi that outside people can reach. In general, its much safer to keep your Pi on an internal network so it can't be hacked as easily!

Test and Configure

If you have X running, open the Midori web browser and navigate to the URL of your favourite electronics supplier.
learn_raspberry_pi_browser.png
If you are using a command line, the ping command can be used to see if you are reaching the internet. Try ping google.com or ping adafruit.com to check if you can reach those sites!

Fixing WiFI Dropout Issues


If you find your module 'drops out' from time to time, you can fix it fairly easily with a command line fix (thanks perseus286!)

Create and edit a new file in /etc/modprobe.d/8192cu.conf
 sudo nano /etc/modprobe.d/8192cu.conf
and paste the following in
 # Disable power saving
options 8192cu rtw_power_mgnt=0 rtw_enusbss=1 rtw_ips_mode=1
Then reboot with sudo reboot