Chapter 2

Downloading the Operating System

In This Chapter

arrow Introducing Linux

arrow Downloading NOOBS

arrow Preparing your SD card

arrow Copying NOOBS to your SD card

Before you can do anything with your Raspberry Pi, you need to provide it with an operating system. The operating system software enables you to use the computer’s basic functions and looks after activities such as managing files and running applications, like word processors or web browsers. Those applications use the operating system as an intermediary to talk to the hardware and they won’t work without it. This concept isn’t unique to the Raspberry Pi. On your laptop, the operating system might be Microsoft Windows or Mac OS. On an iPad or iPhone, it’s iOS.

In this chapter, we introduce you to Linux, the operating system most frequently used on the Raspberry Pi, and we show you how to create an SD or MicroSD card with an operating system on it. You’ll need to use another computer to set up the SD or MicroSD card. It doesn’t matter whether you use a Windows, Mac OS, or Linux machine, but you need to have the ability to write to SD or MicroSD cards using it and a connection to the Internet.

Introducing Linux

The operating system used on the Raspberry Pi is GNU/Linux, often called just Linux for short. The Raspberry Pi might be the first Linux computer you’ve used, but the operating system has a long and honorable history.

Richard Stallman created the GNU Project in 1984 with the goal of building an operating system that users were free to copy, study, and modify. Such software is known as free software, and although this software is often given away at no cost, the ideology is about free as in “free speech,” rather than free as in “free beer.” Thousands of people have joined the GNU Project, creating software packages that include tools, applications, and even games. Stallman aimed to make his operating system compatible with Unix, an operating system that was created by AT&T’s Bell Labs and that started to gain popularity in the 1970s. That would make it easy for existing Unix users to switch to using the GNU Project.

In 1991, Linus Torvalds released the central component of Linux, the kernel, which acts as a conduit between the applications software and the hardware resources, including the memory and processor. He is still “the ultimate authority on what new code is incorporated in the standard Linux kernel,” according to the Linux Foundation, the non-profit consortium that promotes Linux and supports its development. The Linux Foundation reports that 7,800 people from almost 800 different companies have contributed to the kernel since 2005.

GNU/Linux brings the Linux kernel together with the GNU components it needs to be a complete operating system, reflecting the work of thousands of people on both the GNU and Linux projects. That so many people could cooperate to build something as complex as an operating system, and then give it away for anyone to use, is a modern miracle.

Because it can be modified and distributed by anyone, lots of different versions of GNU/Linux exist. They’re called distributions or distros, but not all of them are suitable for the Raspberry Pi. The recommended distribution of Linux for the Raspberry Pi is called Raspbian (see Chapter 3). Software created for one version of Linux usually works on another version, but Linux isn’t designed to run Windows or Mac OS software.

Strictly speaking, Linux is just the kernel in the operating system, but as is commonly done, we refer to GNU/Linux as Linux in the rest of this book.

Creating a NOOBS Card

The easiest way to get started with the Raspberry Pi is to use the NOOBS software. NOOBS is short for new-out-of-box software, although it’s also a pun on the term noob that is sometimes used to describe beginners in Linux. Don’t underestimate the power of this software, though, especially if you’re a more experienced user: NOOBS is easy to copy to your SD or MicroSD card, but provides you with a simple menu for installing a number of different operating systems, including different versions of Linux, RISC OS, and XBMC media center software. The options are described in more depth in Chapter 3.

As we say in Chapter 1, you can buy a card with NOOBS already on it, and that might be the quickest way to get started. If you’ve got one, you can skip ahead to Chapter 3, but maybe have a read-through of this chapter while you’re waiting for the OS to install. It’s useful to know how to create your own NOOBS cards: It means you can get started with a new card in about 20 minutes, rather than having to wait for the postman to deliver one to you.

tip.eps You can also download a specific operating system from the Raspberry Pi website and install that on your SD or MicroSD card. In that case, the download is in a special format (an image file) that describes all the different files that need to be created on the SD or MicroSD card. To convert the image file into an SD or MicroSD card that will work on the Raspberry Pi, you need to flash the card, and can’t just copy the file across. Follow the image installation guidelines on the Raspberry Pi website if you prefer to take this approach (www.raspberrypi.org/documentation/installation/installing-images/README.md).

Downloading NOOBS

In your web browser, visit www.raspberrypi.org/downloads/. There are two versions of NOOBS available. We recommend NOOBS Lite because it offers a wide range of operating systems and media center software (see Chapter 3). It requires a network connection on the Raspberry Pi, so it’s not appropriate for the Model A.

The other version is the offline and network install version of NOOBS, which includes everything you need for the Raspbian Linux operating system in one file that you can copy to your SD card. It doesn’t need an Internet connection on the Raspberry Pi, but it only offers Raspbian. You can follow our instructions here for installing NOOBS Lite and easily adapt them where necessary if you prefer to use the offline and network version of NOOBS.

Formatting your SD card

For best results, you need to format your SD or MicroSD card. You can use a program available from the SD Association called SDFormatter on Mac and Windows, and you can find it at www.sdcard.org/downloads/formatter_4/. At the time of writing, the link to download is in the menu on the left. You need to read and accept the license agreement before you can download.

If you’re using Linux, you can use GParted to format your card, as we will show you.

warning.eps Whichever computer you’re using, you need to be extremely careful in doing this. When you format an SD or MicroSD card, its previous contents are completely erased, so make sure you’ve made copies of any files or photos you might need from the card before you begin. Make sure you have a backup of your hard drive and disconnect any removable disks before you start to minimize the potential damage from accidentally formatting the wrong disk.

Using Windows

The Windows SDFormatter software downloads as a Zip file, so double-click the file to open it, and then click setup.exe to run the SDFormatter installation program. Click Next to work through the steps. The program will suggest where it installs SDFormatter, but you can change this if you want to. Finally, click the Install button. You may receive an alert from Windows that tells you that a program is trying to make changes to your computer, and asks you if this is allowed.

If you are using Windows 8.1, move the mouse to the top-right corner and click the magnifying glass to open the search, type in SDF, and then click the program name when it appears. On older versions of Windows, run SDFormatter from the Start menu in the bottom left of the screen.

Figure 2-1 shows the SDFormatter software on Windows. Where it says Drive, select the drive that contains your SD or MicroSD card. If no drive is shown, try clicking Refresh. Check the drive here and double-check it as often as you need to because SDFormatter will erase everything on this drive. It’s a sensible precaution to disconnect USB drives and any other removable storage devices to protect them from accidental deletion before you go any further.

9781118904916-fg0201.tif

Figure 2-1: SDFormatter, used to format the SD or MicroSD card, on Windows.

Click the Option button and set the format size adjustment option to ON, and then click the Format button. The Quick Format option is fast but not secure, so you’ll receive a warning that data might still be recovered after it. (Don’t count on being able to do so, though!) Click OK to start the formatting. On Sean’s computer, this took less than a minute.

Using a Mac

The Mac version of SDFormatter downloads as an installation package. Double-click this package to install the software. Note you will need to enter your Mac’s password to do this, and also every time you run this utility.

Insert your SD or MicroSD card into your Mac’s slot, or into a card reader connected to your Mac and then double-click the SDFormatter icon. The software looks like Figure 2-2.

9781118904916-fg0202.tif

Figure 2-2: SDFormatter, used to format the SD or MicroSD card, on a Mac.

Make sure the Select Card drop-down shows the SD or MicroSD card you want to use. This is the drive that will be wiped, so check this as often as you need to for you to be certain. If the right card isn’t shown, use the drop-down menu to choose the right one.

Next, click the Overwrite Format option to select it. Click the Format button and SDFormatter starts to format your card. Note that there is no need to enter anything into the Name box. That will be completed automatically.

This is a great time to have a cup of tea because the card is going to take about half an hour to format. You can still use your Mac while this is running, although it might take a bit longer to format if you do. When the formatter is finished, you will see the icon of the SD or MicroSD card on the desktop.

Using Linux

Our recommended approach for flashing an SD card using a Linux-based computer does not require any additional software. We’re using Ubuntu, the most popular desktop distribution, so you might see some variations if you prefer a different distribution. These steps should give you the guidance you need in any case.

warning.eps Because this process involves completely erasing a disk (your SD card), make sure you have a recent backup of your computer before you proceed, just in case you accidentally wipe the wrong disk.

Follow these steps:

  1. You use a utility called GParted to set up the SD card on Ubuntu. It needs to be run with root permissions, so start it by issuing a command from the terminal. Enter the following:

      sudo gparted

    You can open a terminal window through Dash Home in Ubuntu, or the applications menu in your distribution, or use a keyboard shortcut (Ctrl+Alt+T in Ubuntu). Figure 2-3 shows GParted running on the desktop.

  2. Click in the top right to choose the correct disk, your SD card.

    Take particular care here. You can cause serious damage to your hard drive if you choose the wrong disk here. We know this is our SD card because it’s showing a capacity of 7.4GB and our hard drive has a capacity of 500GB.

  3. The main window shows the partitions on your card. You want to delete them, so click them in turn and then click the delete icon on the toolbar.

    The delete icon looks like a No Entry sign, or the international No symbol. This won’t take effect yet: You queue up the actions you want to carry out and then trigger them all when you’ve finished. (If you can’t set a partition to delete because it has a key icon beside it, right-click the partition and choose Unmount in the menu that appears.)

  4. Click the unallocated partition and click the Add Partition button.

    It’s on the toolbar and has a picture of a blank page with a plus sign on it.

    9781118904916-fg0203.tif

    Figure 2-3: GParted, running on the Ubuntu desktop.

  5. The pop-up window, which you can see in the foreground in Figure 2-3, appears. Click the menu to change the file system to fat32. Click the Add button.

    Again, this doesn’t take effect yet.

  6. Click the tick (or check mark) button on the toolbar to carry out the actions you’ve queued up, which remove the existing partitions and add a single new FAT32 partition.

Copying NOOBS to your SD or MicroSD card

You should now have a formatted SD or MicroSD card, and the zip file for NOOBS that you downloaded from the Raspberry Pi website. To install NOOBS on your SD or MicroSD card, you simply copy the files inside the zip file to the card.

On a Windows PC, double-click the NOOBS zip file to open it, select all the files in it, and then copy them to your formatted SD card. You can do this by using Ctrl+A to select the files and Ctrl+C to copy them, navigating to your SD card, and then using Ctrl+V to paste them.

On a Mac, double-click the NOOBS zip file and you will see a folder containing all the files you need. From the Edit menu, choose Select All and drag all the files onto the SD card icon on your desktop. It will take about 15 minutes to copy everything across. When it’s finished, eject the SD card by dragging it into the Trash can, which has now transformed into an eject icon.

On Linux, you can use the desktop environment (where available) to copy the NOOBS files to your SD card. In Ubuntu, you can simply go to the NOOBS zip file, double-click it to open it, select all the files in it, and drag them to your SD card to copy them across.

Alternatively, you can follow these steps to unzip and copy the files using the Linux command line:

  1. Remove and reinsert your card so it mounts automatically.
  2. Open a terminal window.

    You can do this through Dash Home in Ubuntu, or the applications menu in your distribution, or use a keyboard shortcut (Ctrl+Alt+T in Ubuntu).

  3. Enter sudo fdisk -l, where the last character is the letter l.

    This gives you a list of the disks available, as you can see in Figure 2-4.

    9781118904916-fg0204.tif

    Figure 2-4: A list of the available disks.

  4. Study this list to find your SD or MicroSD card.

    In Figure 2-4, the screen lists two disks, with the information about each one starting with the word Disk. The file size is usually a good indicator of which is your SD card. The first one (Disk /dev/sda) is 500.1GB, which is a large hard drive. The second one (Disk /dev/sdd) is just 7948MB. That’s roughly 8GB, so that’s your SD card. Take a note of the card’s partition name, which in this case is sdd1.

  5. Find out where the card is mounted.

    Use the mount command and search for the directory where your card has been mounted in the file system. In this case, the card’s partition name is sdd1, so we enter the following:

      mount | grep -i sdd1

    Figure 2-4 shows the output from this, which tells us where the card is mounted. In this case, it’s mounted on /media/65E8-9564.

  6. Use cd to go to the directory where your card is mounted.

      cd /media/65E8-9564

  7. Unzip your NOOBS download onto your card.

    This NOOBS download was stored in the folder /home/Ubuntu/Downloads, so we can unzip it onto our SD card using this command:

      unzip /home/Ubuntu/Downloads/NOOBS_v1_3_9.zip

    You can usually type the first couple of characters of each part of the path and then tap the Tab key on the keyboard to have Linux complete it for you, so you don’t have to remember the whole filename. It might take five minutes or so to unzip and copy the files across to your card.

Using Your NOOBS Card

Now you have a card with NOOBS on it, you’re ready to set up your Raspberry Pi. In the next chapter, we show you how to connect your Raspberry Pi up, insert your SD or MicroSD card, and finish installing the operating system.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.67.169