Monday, August 12, 2013

Cooking Raspberry Pi

In this post I discuss installing and configuring the Raspbian "Wheezy" distribution.

My previous posts discussed the hardware you need to get your Pi setup. Now it's time to focus on installing an operating system on our Pi and configuring it. First, we need to choose which operating system we want to install. As of this writing there are several options, but I'm going to focus on the Raspbian "Wheezy" distribution. Rapsbian is a Debian-based linux distribution that happens to be the most popular OS choice for the Pi.

Pick An OS, Any OS
Installing Raspbian is a two-step process. First, you need to select the appropriate version to download. You can find the link to download Raspbian Wheezy here. On this page you'll find multiple ways to download the distribution. The simplest is to download the NOOBS.zip. You can follow the directions for doing so on the link provided. In this post I'll focus on the second option of installing the raw normal Wheezy image. Note that you'll also see references to a soft-float version of Wheezy. You don't need to be concerned with this unless you plan to use Java with the Pi. In that case you'll need to install the soft-float Wheezy version because it plays nicely with Oracle's Java JVM. I don't recommend using this version otherwise, since its performance isn't as good as the normal Wheezy version.

The Write Stuff
Once you've download and unzipped the distribution you'll need need to use a special tool to transfer the img file to an SD card. Once such tool for Windows is Win32DiskImager . In this post I'll focus on how to create an SD card using Windows. If you're working with a Mac you can find similar instructions for creating SD card images using the Mac's dd Unix command by searching the Internet. The basic concepts are the same, you start by downloading an image file, then use a low-level utility to write the bootable operating system image to an SD card. 

The first step is to start Win32DiskImager. Once the screen appears, you'll see something similar to the image below. Click the Folder icon next to the Image File field and select the .img file you downloaded and unzipped previously. Next you'll want to select the SD card in the Device dropdown. Make sure you select the correct SD card before you begin writing data because this process erases all data from the selected card. Once you're satisfied with your selection, press the Write button to begin preparing the card. This process may take 30 minutes or more, depending on the speed of the SD card you're using and the transfer speed of the card writer.



Give It The Boot
Once card creation is complete you should have a working Wheezy SD that you can place into the Pi and boot with. As the Pi boots you'll see 100's of lines quickly scroll by. These are displayed as part of the normal Linux kernel startup. After a minute or so you should arrive at the Raspi-config screen shown below. The remainder of this post I will walk you through each of these menu options. 



The first option we'll look at is expand_rootfs . As you can probably guess by the name, this is used to expand the root file system. This is very important to do because if you don't do so your Pi will only have disk space equivalent to the Wheezy image you wrote to the card, rather than the entire SD card size. For example, if you install a 2GB Wheezy image on an 8GB SD card the root file system will only be 2GB. You essentially have 6GB of space that isn't available for use since it isn't allocated in the filesystem. So, go ahead and choose this option. Once you do so you'll see a few dozen lines flash by on the console. These are telling us that the partition manager is resizing the root file system. After completion you'll see a screen stating that the resizing was completed and will take effect on the next reboot. Don't worry about rebooting now. We'll finish with the other options and do the reboot last.

The next option we'll look at is overscan. If you're working with an HDMI monitor or TV you can use this option to control the appearance of the screen. You'll want to play around with Enable / Disable  until you find the option that properly shows all of the example content. For most displays Disable is generally the preferred setting.

Next you'll want to use configure_keyboard to select the proper keyboard you're using. Since the Pi is manufactured in the UK the default keyboard selection is an International version (typically the Generic 105-key (Intl) PC). If you're a US user you'll probably want to change this to the Generic 104-key PC keyboard then select English (US). You can take the default for the rest of the options that appear. This seems a bit arcane, but if you don't follow this pattern you'll find some very needed symbols such as the @ symbol won't be mapped properly when you press the key.

You can use change_pass to change the default password for the user pi. I highly recommend doing so, since it provides a measure of security if you're planning to use your Pi to store documents and so forth or to connect remotely using ssh.

Where Am I?
The change_locale options lets you set a default language. You'll only need to change this setting if you don't wish to select English as the default language. Next you can select your current timezone using the change_timezone option. Note that the Pi doesn't have a realtime clock, but the timezone is used to offset the time obtained by Internet-based time services that provide the current time/date in universal time. Users in the US will want to choose the US menu option, then select the appropriate timezone.

The memory_split option allows you to select the amount of memory you wish to allocate for video memory vs. core memory. If you're planning to  to play videos you'll want to allocate at least 128MB for GPU (video) memory. This is typically the fourth option in the menu and begins with 128. The overclock option lets you overclock the Pi's processor, in a somewhat safe fashion. I say somewhat safe because while it's designed to protect the Pi's processor from being pushed too hard, unfortunately it does little to prevent the SD card from being corrupted if the Pi becomes unstable and crashes from overclocking. I found that pushing the overclock above Medium (900MHz) resulted in corrupted SD cards quite often. When this happens you pretty much have to reinstall Wheezy from scratch. All of your configuration changes are lost. Your overclocking mileage may vary. 

The ssh option allows you to setup the Pi for remote access using ssh. I recommend enabling this option to allow an easy way to control your Pi from other computers on your network. In future posts I'll discuss how to use ssh, along with more advanced ways to access the Pi using a VNC client. The start_desktop option lets you control whether the graphical desktop is automatically started when the Pi boots. In most cases you'll probably want this to be the default option. The exception is cases where you use the Pi as a dedicated server that doesn't need a graphical interface.

Almost There
Last, but not least, the update menu option checks for updated versions of the configuration menu (raspi-config) that we've just walked though. It's probably a good idea to do this once in a while. You can do it a couple of ways, first by running the configuration menu again by entering the following command in the terminal window: sudo raspi-config. The second way is by running the following terminal command: sudo apt-get update,  followed by the command: sudo apt-get install raspi-config.

The final step in completing the install/configuration process is to reboot the Pi. You should exit the menu by tabbing to the Finish button and pressing Enter. This takes you to a command prompt where you can type the command: sudo reboot. This restarts the Pi and all of the options you've selected will now take effect.

In this post I went through the most common options for configuring the Pi for first-time use. You can find more detailed instructions regarding each configuration option by referring to the Raspi-config page on the elinux.org site.

In my next post I'll provide some handy scripts and tips to help you find your way around Wheezy. Until then, happy baking!

No comments:

Post a Comment