User Tools

Site Tools


projects:pi:test

Booting the Raspberry Pi for the first time

Once you have received your Raspberry Pi and unpacked the mini-computer it is time to fire it up and see what its all about. However much like a normal desktop computer wont boot without a operating system (such as Windows) neither will the raspberry. This guide will show you how to pick a operating system, flash it to a SD card and boot your Raspberry Pi for the first time.

To complete this project you're gonna need:

  • Raspberry Pi - Model B (Buy here)
  • SD Card (min. 2 GB)
  • A computer with an internet connection and a SD card reader
  • And some of the other accessories described here (keyboard, mouse, monitor etc.)

Selecting a Operating System (OS)

Since the Raspberry Pi is powered by a so-called ARM processor it cannot run the same operating system as your computer. Instead it must run one of the operating systems that have been optimized and ported to the Raspbery Pi ARM hardware architecture. There are a few different operating systems available as listed here. It is important to note that most of them are based on the linux kernel and that it is not possible to run windows on the Raspberry Pi.

Raspbian “Jesse”

The Raspbian “Wheezy” operating system is the standard operating system to run on the Raspberry Pi. It has very good integration with the hardware and comes pre-loaded with a graphical user interface and development tools. This will come in very handy if you are not too experienced in a linux enviornment.

Please note that the use of the dd tool can overwrite any partition of your machine. If you specify the wrong device in the instructions below you could delete your primary Linux partition. Please be careful.

  • Run df -h to see what devices are currently mounted.
  • If your computer has a slot for SD cards, insert the card. If not, insert the card into an SD card reader, then connect the reader to your computer.
  • Run df -h again. The new device that has appeared is your SD card. The left column gives the device name of your SD card; it will be listed as something like /dev/mmcblk0p1 or /dev/sdd1. The last part (p1 or1 respectively) is the partition number but you want to write to the whole SD card, not just one partition. Therefore you need to remove that part from the name (getting, for example, /dev/mmcblk0 or /dev/sdd) as the device for the whole SD card. Note that the SD card can show up more than once in the output of df; it will do this if you have previously written a Raspberry Pi image to this SD card, because the Raspberry Pi SD images have more than one partition.
  • Now that you've noted what the device name is, you need to unmount it so that files can't be read or written to the SD card while you are copying over the SD image.
  • Run umount /dev/sdd1, replacing sdd1 with whatever your SD card's device name is (including the partition number).
  • If your SD card shows up more than once in the output of df due to having multiple partitions on the SD card, you should unmount all of these partitions.
  • In the terminal, write the image to the card with the command below, making sure you replace the input file if= argument with the path to your .imgfile, and the /dev/sdd in the output file of= argument with the right device name. This is very important, as you will lose all data on the hard drive if you provide the wrong device name. Make sure the device name is the name of the whole SD card as described above, not just a partition of it; for example sdd, not sdds1 or sddp1; or mmcblk0, not mmcblk0p1.
dd bs=4M if=2016-02-09-raspbian-jessie.img of=/dev/sdd
I used:  sudo dd bs=4M if=2016-02-09-raspbian-jessie.img of=/dev/sdg
Run sync
  • Please note that block size set to 4M will work most of the time; if not, please try 1M, although this will take considerably longer.
  • Also note that if you are not logged in as root you will need to prefix this withsudo.
  • The dd command does not give any information of its progress and so may appear to have frozen; it could take more than five minutes to finish writing to the card. If your card reader has an LED it may blink during the write process. To see the progress of the copy operation you can runpkill -USR1 -n -x dd in another terminal, prefixed with sudo if you are not logged in as root. The progress will be displayed in the original window and not the window with the pkill command; it may not display immediately, due to buffering.
  • Instead of dd you can use dcfldd; it will give a progress report about how much has been written.
  • You can check what's written to the SD card by dd-ing from the card back to another image on your hard disk, truncating the new image to the same size as the original, and then running diff (or md5sum) on those two images.
  • The SD card might be bigger than the original image, and dd will make a copy of the whole card. We must therefore truncate the new image to the size of the original image. Make sure you replace the input file if= argument with the right device name. diff should report that the files are identical.
dd bs=4M if=/dev/sdd of=from-sd-card.img
truncate --reference 2016-02-09-raspbian-jessie.img from-sd-card.img
diff -s from-sd-card.img 2016-02-09-raspbian-jessie.img
  • Run sync; this will ensure the write cache is flushed and that it is safe to unmount your SD card.
  • Remove the SD card from the card reader.

Once the OS has been flashed onto the SD card, some files need to be added in order to enable SSH access and have the Pi connect to the desired network via WiFi.

Etcher automatically ejects the drive when the flashing procedure is completed, so you may have to remove and reinsert the microSD card in your computer.

To enable SSH access,

<code oobas>create an empty file called "ssh" //(no file extension!) and put it on the microSD card's /boot directory.
</code>

to enable WiFi,

create a file called "//wpa_supplicant.conf"// with following content, on the microSD card's /boot directory:
 
  ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  update_config=1
  network={ssid="<your_ssid>" psk="<your_password>"}
 

Replace <your_ssid>” and <your_password>” with the values matching your own wireless network and save the file. Upon first boot, the file will be moved to the correct location on the filesystem.

First boot

Once we have programmed the SD Card - plug it into the Raspberry Pi, your should now have a configuration looking like this:

image2

Connect power and you should see the boot sequence on your TV (if not check if you selected correct HDMI input on TV). After first boot the Raspberry Pi boots up in setup mode. If it does not boot into setup mode you can type the following command to get there:

sudo raspi-config

When in setup mode we want to:

  • Re-size to file-system to use the entire SD card in my case (4GB)
    • First option in setup menu
  • Change the locale to match your location
    • This is found under “Internationalization Options”
  • Change the timezone to match your location
    • This is found under “Internationalization Options”

For more details on how this is done in the setup menu watch this video:

object1

rpi-update is a tool to upgrade the firmware for your Raspberry Pi. Firmware is a small package of code that usually lives on a special chip of a computer that helps the software know how to talk to the hardware.

sudo rpi-update

We can now reboot the Raspberry Pi - and when it boots again it will come up with our new configuration! To log in use the following credentials:

User: pi Password: raspberry

Your Raspberry is now setup, configured and ready for you to use for any purpose you want.

projects/pi/test.txt · Last modified: 2017/06/27 15:41 by 127.0.0.1