Chapter 5. Expanding on Storage Options

In this chapter we will explore how we can expand the storage options of the Raspberry Pi 2 beyond that of the microSD card.

As you come to write more applications or use different media types on your device you may find that the microSD card becomes too restrictive. Also, using the Raspberry Pi with an external HDD allows you to create your own Network-attached storage (NAS) device. We will explore the Samba suite of software to achieve this.

In order to use these devices there are some modifications that are required in the boot up process.

We will cover the following topics:

We'll start by looking at the Raspberry Pi and how it boots up, then discuss what changes are required.

What follows is a brief explanation of the process that eventually results in Raspbian being loaded. This will provide some context when we come to modify the cmdline.txt file in order to boot the operating system from the HDD rather than the microSD card.

Start by running the following ls command:

This is the boot directory as its name suggests. In here you will see a variety of files that are used in a specific order to boot the Raspberry Pi 2 up into the operating system.

The following screenshot illustrates what this directory typically looks like:

Booting up

We will now summarize how these files are used in the overall process.

The first step happens when we power up the Raspberry Pi. The CPU and other components start up and the VideoCore GPU kicks off the boot process based upon its firmware located in Read Only Memory (ROM).

This firmware can optionally be updated with the latest version by following the steps in the document available at https://github.com/Hexxeh/rpi-update.

For those who are interested, the Raspberry Pi firmware can also be acquired from the repository available at https://github.com/raspberrypi/firmware.

Next, the bootcode.bin file is called. You should be able to see this in the boot directory. The bootcode.bin file starts the GPU up. While the bootcode.bin file is in machine code format, the config.txt file (also in the /boot directory) is human readable. This can be used to pass configuration parameters during startup.

You can read more about these and config.txt at the official Raspberry Pi website, available at https://www.raspberrypi.org/documentation/configuration/config-txt.md.

Following this, the next stage is start.elf, which is then loaded. start.elf is responsible for loading the configuration parameters from cmdline.txt and also the operating system kernel (Linux). In essence it kicks off the operating system running on our ARM architecture.

For the tasks in this chapter we are interested in cmdine.txt, which we will need to edit once we have our external drive setup.

At a superficial level the boot process is very simple and results in the operating system loaded on the microSD card being used. Since we plan to use an external HDD instead, let's look at getting our hardware setup so we can boot Raspbian from it.