How-to: Raspberry Pi tutorial part 1: Getting started

[easyreview title=”Complexity rating” icon=”geek” cat1title=”Level of experience required, to follow this how-to.” cat1detail=”The geek factor is quite high here, but this process is not particularly taxing.” cat1rating=”2.5″ overall=”false”]

Contents

In the line of my work, I’ve recently had cause to become better acquainted with every geek’s favourite cheap computer, the Raspberry Pi. At the time of writing, you can pick up a Pi for an extremely reasonable £30, but the first thing I discovered was that this is only half the story. For a workable system, you need all the necessary cables, some storage and a case. Here’s my shopping list:

The Pi plus extra bits, in all their glory
The Pi plus extra bits, in all their glory

So my total is £69.95 – over twice the price of buying just the Pi. But still pretty cheap, considering. You’ll also need a USB mouse/keyboard for initial input. I’m going to run my Pi headless (no screen or input devices needed, just a network connection), so I’m borrowing my Microsoft Natural wireless desktop for this purpose, which the Pi detected without issue.

Hardware installation

This may well be the easiest hardware installation you ever perform. The case has a couple of punch outs that you need to remove for the model B Pi. I forgot to photograph them I’m afraid, but it will be obvious – when you try and put the Pi in the case, it won’t fit without these pieces removed (e.g. for the ethernet port).

Pi and case

Put the Pi in the case.

Pi case installation

Put the case together and fasten the screws. Make sure you put the VESA mount between the screws and the case, if you’re going to monitor-mount the Pi.

Pi case and VESA mount

That’s it.

What to do, what to do…

There are lots of potential uses for your Pi. It has limited processing power and memory but apart from that, the only real limit is your imagination. I have no imagination to speak of, so I’m going to do what I do with every other gadget: put Linux on it and set it up as a home web/file server. I’ll cover the web/file server setup in a subsequent tutorial.

Here’s the plan:

  • Install Rasbian (a Pi-centric version of the venerable Debian GNU/Linux distribution).
  • Set up Webmin/Virtualmin for management of the server/web sites.
  • Install OwnCloud and create my own Dropbox replacement.
  • Experiment with using the Pi as a remote desktop client or thin/fat terminal.

In the process, I’m looking for any major issues or gotchas – things you might want to be aware of if you’re thinking of getting into Pis in a big way.

Prepare the SD card

For this step, you’ll need an SD card reader. If you don’t have a laptop/computer with a built-in reader, you can buy an external reader here. Note: my laptop’s built-in card reader was not supported by the SD Formatter program (see below) so I used an external reader.

  1. From the SD Association’s official website, download and install the SD Formatter.
  2. Format the SD card using SD Formatter:
    SD Formatter
  3. Download NOOBS (“New Out of Box Software” – chortle) from the official Raspberry Pi website. This file is currently over 1GB. I tried the direct download and it was pretty slow, so I’d recommend using the torrent if you’re so equipped. NOOBS gives us a choice of different operating systems to install on the Pi.
    NOOBS
  4. Extract the contents of the NOOBS zip file onto the newly formatted SD card.
    NOOBS files

Whack the SD card into the Pi and connect everything up (power last of all, since there’s no power switch). If at this point you don’t see any output, the chances are that your SD card has not been recognised. I’m using a Class 10, but I’ve read that some people have had problems with Class 10 cards and better results with Class 6. If your card is recognised, you should be rewarded with a few pretty lights when powered up.

Pi plumbed in

Install and configure Raspbian

At the NOOBS screen, choose Rasbian and click Install OS, then Yes. Go grab yourself a quick coffee.

Raspbian installation

The install will take a few minutes (the speed of your SD card is a factor here). Once it’s done, you’ll see a message “Image applied successfully”. Click Okay to reboot the Pi with your new OS.

Raspbian installation progress

raspi-config will launch with some initial setup options. I’ll work through them one by one.

raspi-config

  1. Expand the filesystem: You can skip this, because this option isn’t needed for NOOBS-based installations. Otherwise, this ensures you’re using the whole of the SD card.
  2. Change the password for the “pi” user. The default password is “raspberry”. Improve on that.
  3. Enable/disable boot to desktop: I’m not planning to use a desktop system with this Pi. X Windows is such a resource hog that we definitely want to set this to “No”. Of course if you want to use the Pi as a desktop system, you’ll select “Yes” here.
  4. Internationalization options: I’m in the UK, with a UK keyboard layout. It’s not a huge problem since generally I’ll be accessing the Pi via a web interface or service, but I am fussy, so I set everything up to be UK-centric. My correct locale was already selected. In these dialogue boxes, use the spacebar to select/deselect options, tab to move between fields, up and down cursors keys to navigate and enter to select.
  5. Enable camera: do this if you’ve bought the optional camera module (I haven’t).
  6. Add to Rastrack: this puts you on the Rastrack map of Pi installations. Not for me, but you might be interested.
  7. Overclock: if you need to squeeze more juice out of your Raspberry, you can force it into a more frantic mode of operation. I’m not going to do this, at this stage.
  8. Advanced options: Here, I’m going to set the hostname of the Pi and reduce the Pi’s use of GPU memory to 16MB (since we’re not running a graphical desktop). I’m also going to ensure that SSH is enabled (for later remote logon purposes).
  9. Finish and reboot to an ordinary logon prompt.
  10. For demo/proof of concept servers where security is less of a concern, I like to be able to log on as root. You can give the root user a password by logging in, then entering sudo passwd root and following the prompts.

Configure networking

I need this Pi to have a static IP address. You can use a DHCP reservation for this purpose if you like, but I prefer to create a fixed IP address on boot. Like this:

  1. Log in.
  2. If you didn’t log on as root, give yourself an elevated shell: sudo su
  3. Install your favourite console-based text editor. For me this is vim: apt-get --force-yes -y install vim
  4. Use the editor to edit the /etc/network/interfaces file. Replace the line iface eth0 inet dhcp with iface eth0 inet static
    address 192.168.1.11
    netmask 255.255.255.0
    gateway 192.168.1.1

    adjusting the values to match your network as appropriate.
  5. My DNS was already correctly configured, but you may need to check the contents of your /etc/resolv.conf file to ensure DNS is set up. If in doubt, this configuration should work:
    nameserver 8.8.8.8
  6. Save the files then back at the command prompt, enter reboot to restart the Pi with the new network configuration.
Typical Raspbian bootup messages
Typical Raspbian bootup messages

Once the Pi is up and running you’ll be able to connect via SSH using your favourite terminal emulation program (mine’s PuTTY).

As you’ll see from the Contents section above, I have a few ideas for things to do next. It’s a good plan to take a snapshot of the Pi in its current state, so we can hit the ground running any time we want to try something different, with a Raspbian base, so this will be the subject of my next how-to. In the meantime, if you have any questions about what we’ve done so far, or if you have any ideas for later tutorials, let us know in the comments!

Until next time. 🙂