Productivity

A Beginner's Guide To The Raspberry Pi

The Raspberry Pi is a wonderful little computer that fits in the palm of your hand, yet packs enough power to run your home media centre, a VPN, and much more besides. Before you can do all that cool stuff, however, you need to configure it and install an operating system. Here’s how to do that.

Photos by Denise Kappa (Shutterstock), maymak (Shutterstock), Pakhnyushcha (Shutterstock), and Anan Kaewkhammul (Shutterstock), and me.

It’s Raspberry Pi week at Lifehacker (as well as being BBQhacker week — I guess that makes for a double food theme). We’ll be showing you some awesome DIY projects you can put together with this miraculous device. If you haven’t acquired one yet, check out the first section below to learn more about what it is, what you’ll need, and the cool stuff you can do with one.

What Is The Raspberry Pi?

The Raspberry Pi is a very capable mini computer that’s small enough to fit in your pocket (even though you’d probably never keep it there). For about $40, you get a caseless computer with HDMI and analogue composite video output. You can add up to two USB devices (which, in most cases, will be a mouse and keyboard) and connect it to the internet via wired Ethernet. The Raspberry Pi is powerful and inexpensive, allowing you to create a home media centre, internet radio, or even your own VPN server on the cheap. With that said, a little setup and a lot of other parts are required to get it up and running. In this post we’ll take a look at how to get a Raspberry Pi set up so you can start using it for a variety of purposes.

What You’ll Need

The Raspberry Pi may be a computer all on its own, but you’ll still need a lot of other things to make it work:

  • A Raspberry Pi: We’ll discuss where to buy this below.
  • An HDMI- or component video-capable television or monitor: In this post we’ll be working with an HDMI-capable monitor because it offers better resolution and built-in sound. You can use analogue if you want, however.
  • An HDMI or component video cable: You’ll need this cable to connect your Raspberry Pi to your television or monitor.
  • A 4GB Class 4 SD card (or better) and a card reader (if you don’t have one built into your computer): Most SD cards will work, but some aren’t compatible and will therefore cause issues. You can find out which cards are compatible, or locate a place to buy a compatible card with an operating system pre-installed, on this page.
  • A USB keyboard and mouse: Any standard USB keyboard or mouse will do. Wireless (non-Bluetooth) peripherals worked for me, but I had to unplug them and plug them back in after the Raspberry Pi booted. You’ll have fewer issues with fully wired keyboards and mice.
  • An Ethernet cable: Any standard Ethernet cable will do..
  • A good quality, micro USB power supply that can provide at least 700mA at 5V: Most modern smartphone chargers supply 700mA at 5V, but not all do. Check the bottom of your charger and look for a block of text. You’ll see its output values in that text which may read 0.7A instead of 700mA). If it offers at least that much power, you’re good to go. Don’t use a poor quality charger or you may run into problems.
  • A 3.5mm stereo audio cable: You only need this if you’re using analogue video and want to connect your Raspberry Pi to a set of external speakers or internal ones on your television or monitor.

All these peripheral devices are easy to buy. The Raspberry Pi itself is more challenging, as supplies are often limited due to high demand. The authorised local supplier in Australia is RS Components. You can try other overseas suppliers (including Amazon and eBay stores), but you may end up paying a premium.

How To Set Up A Basic Operating System

You can use the Raspberry Pi for all sorts of different tasks, some of which may require their own specialised operating systems. To start out, it’s a good idea to get acquainted with the Pi by installing Raspbian, a Raspberry Pi-focused version of Linux. Here’s what you need to do.

Step One: Prepare Your SD Card

Firstly, we need to prepare your SD card for the Raspberry Pi. This involves formatting it properly and putting Raspbian, the standard Raspberry Pi operating system, on it. The steps vary depending on whether or not you’re on a Windows, Mac or Linux machine; follow the instructions for your operating system below.

Windows

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB in size so it may take a little while to download.)
  2. Download Win32DiskImager and unzip the application (.exe file) inside.
  3. Insert your SD card into your Windows PC’s card reader.
  4. Open Win32DiskImager.exe, the application you just downloaded, by double-clicking on it. (If you’re running Windows 7 or 8, right click on it and choose “Run as Administrator” instead.)
  5. If your SD card isn’t automatically detected by the application, click on the drop-down menu at the top right (labelled “Device”) and choose it from the list.
  6. In the image file section of the application, click the little folder icon and choose the Raspbian .img file you just downloaded.
  7. Click the Write button and wait for Win32DiskImager to do its thing. When it finishes, you can safely eject your SD card and insert it into your Raspberry Pi.

Mac

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB so it may take a little while to download.)
  2. Download RPi-sd card builder (be sure to pick the appropriate version for your installed version of OS X) and unzip the application.
  3. Insert your SD card into your Mac using a card reader.
  4. Open RPi-sd card builder. You’ll immediately be asked to choose a Raspbian image. Choose the .img file you downloaded earlier.
  5. You’ll be asked if your SD card is connected. Since we inserted it earlier, it is, so go ahead and click Continue. You’ll be presented with SD card options. If you only have one inserted, you won’t see anything else in the list and it’ll be checked. If not, just check only the card you want to use and click OK.
  6. Enter your administrator password and click OK.
  7. You’ll be asked if the SD card was ejected. This is supposed to happen, as the application needs to unmount it so it can perform a direct copy. Double-check that your SD card is no longer available in the Finder. DO NOT remove it from your USB port. When you’re sure, click Continue.
  8. RPi-sd card builder finishes prepping your SD card, safely eject it and insert it into your Raspberry Pi unit.

RPi-sd card builder isn’t really an app; it’s an Automator action that acts like one. Some people have reported issues using it, so if you run into problems just open up the Terminal app (Your Hard Drive → Applications → Utilities → Terminal) and follow the instructions for Linux.

Linux

  1. Download the lastest version of Raspbian and unzip the .img file inside. (It’s almost 500MB so it may take a little while to download.)
  2. Open up your Linux terminal emulator of choice. If you don’t have one, try our favorite.
  3. Insert your SD card. If it mounts automatically, unmount it but make note of its location (e.g. /dev/disk2s1). Even though the card is unmounted, do not remove it from the reader
  4. In the command line, you’re going to need to type a single line to copy the contents of the Raspbian .img file to your SD card. It will look like this:

    sudo dd if=PATH_TO_IMG_FILE of=PATH_TO_SD_CARD_MOUNT_POINT bs=1m

    You’ll need to replace PATH_TO_IMG_FILE with the path to the .img file and PATH_TO_SD_CARD_MOUNT_POINT with the path to the SD card mount point. (The bs=1m just specifies the byte size and you don’t need to mess with it.) When you’re done, the command should look something like this:

    sudo dd if=/Users/adachis/Downloads/2012-12-16-wheezy-raspbian.img of=/dev/disk2s1 bs=1m

    It’s very important that you do not get this information wrong or you could end up writing Raspbian to the wrong disk and cause serious data loss. Be careful! When you’re sure you’ve got everything right, press enter.

  5. You will be prompted for the root password (or your administrator password for those of you on OS X who are using this method). Type it and press enter.
  6. It will take some time for the dd command to copy everything over to your SD card. While that happens, it will probably look like the Terminal froze up. Don’t worry, it’s still working; it just takes longer than an average 2GB copy to an SD card, so be patient. When it finishes, the command prompt will return and your SD card will be ready. Eject it safely and stick it in your Raspberry Pi.

Step Two: Hook Up Your Raspberry Pi

Connecting everything to your Raspberry Pi is easy. Start by connecting the HDMI cable from the unit to your television (or monitor). If you’re using the analogue composite video connection instead, connect it to your television (or monitor) and plug in a set of speakers to the 3.5mm audio jack. If you want your Raspberry Pi to connect to your network and/or the internet, use an Ethernet cable to connect it to your router. If you’ve set up a computer before, this should all seem familiar.

Finally, you need to connect your Raspberry Pi with a micro USB power adaptor. As mentioned earlier, you need an adaptor that can provide at least 700mA at 5V. Fortunately, you probably already have one. Many smartphone and tablet chargers utilise micro USB and provide 700mA at 5V (or more). You can find out by reading the small text on the plug and looking for the output section. (Note: it may say 0.7A (or higher) instead of 700mA.) When you have a compatible power adaptor on hand, connect it to a micro USB cable and then connect that cable to the micro USB port on your Raspberry Pi unit. It’ll turn on all by itself and you should see it boot for the first time.

Step Three: Configure Your Raspberry Pi

Once your Raspberry Pi boots for the first time you’ll need to configure a few things. You’ll know it’s ready for you when you see a Raspi-config window with a big list of settings. You can mess with the others if you feel so inclined, but the only thing you really need to do is expand the file system so you can use up all the space on your SD card. To do that, follow these steps:

  1. Select expand_rootfs (the second option) and press enter.
  2. Confirm that you want to expand the file system and let Raspbian do its thing.
  3. When you’re returned to the configuration list, go all the way to the bottom and select the Finish option.
  4. It will ask you if you want to reboot. Choose yes.

Your Raspberry Pi will reboot and take a little longer this time because it needs to expand the file system. After a about a minute you’ll be asked to log in. You’ll need to use the default username and password:

Username: pi

Password: raspberry

Once you’ve logged in, you’ve got yourself a working Raspberry Pi. Congratulations!

Of course, this is far from the end. You can use your Pi as much more than just a tiny computer, so check out Lifehacker through this week for how-tos on some of the coolest things you can do with it. Tomorrow we’ll show you how to turn that tiny little board into a killer XBMC media centre.