Raspberry Pi Networking Cookbook Golden all chapter instant download
Raspberry Pi Networking Cookbook Golden all chapter instant download
https://ebookultra.com/download/raspberry-pi-by-example-1st-edition-
pajankar/
https://ebookultra.com/download/raspberry-pi-the-complete-manual-7th-
edition-coll/
https://ebookultra.com/download/raspberry-pi-media-center-1st-edition-
sam-nazarko/
https://ebookultra.com/download/penetration-testing-with-raspberry-pi-
second-edition-michael-mcphee/
Raspberry Pi Hardware Projects 1 1st Edition Andrew
Robinson
https://ebookultra.com/download/raspberry-pi-hardware-projects-1-1st-
edition-andrew-robinson/
https://ebookultra.com/download/raspberry-pi-projects-for-dummies-1st-
edition-mike-cook/
https://ebookultra.com/download/raspberry-pi-home-automation-with-
arduino-1st-edition-k-dennis/
https://ebookultra.com/download/raspberry-pi-a-quick-start-guide-1st-
edition-maik-schmidt/
Raspberry Pi Networking Cookbook Golden Digital
Instant Download
Author(s): Golden, Richard
ISBN(s): 9781849694605, 1849694605
Edition: New edition
File Details: PDF, 10.87 MB
Year: 2013
Language: english
www.it-ebooks.info
Raspberry Pi
Networking Cookbook
Rick Golden
BIRMINGHAM - MUMBAI
www.it-ebooks.info
Raspberry Pi Networking Cookbook
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the publisher,
except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers
and distributors will be held liable for any damages caused or alleged to be caused directly or
indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies
and products mentioned in this book by the appropriate use of capitals. However, Packt
Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-84969-460-5
www.packtpub.com
www.it-ebooks.info
Credits
Reviewers Proofreader
Hector Cuesta-Arvizu Jonathan Todd
Shea Silverman
Indexer
Acquisition Editor Monica Ajmera Mehta
Erol Staveley
Production Coordinator
Lead Technical Editor Shantanu Zagade
Mayur Hule
Cover Work
Technical Editors Shantanu Zagade
Sharvari Baet
Devdutt Kulkarni
www.it-ebooks.info
About the Author
Rick Golden sat in the computer lab at SUNY Fredonia and completed his first CAI tutorial
for programming in APL. It was the summer of 1972; he was nine years old.
Most of the programming that he has done since then has been in Algol-based languages
such as PL/I, FORTRAN, BASIC, Pascal, C, C++, C#, Objective C, and Java. He did occasionally
write code in languages such as APL, FORTH, LISP, and Scheme; however, he could not find
an employer that would actually pay him to develop solutions using those non-structured
languages. In recent years he has had more success introducing organizations to scripting
languages such as Python, Perl, TCL, Ruby, Groovy, and Node.js.
He also had the privilege to work in many different domains applying leading technologies
through each cutting-edge wave of structured programming, architectural frameworks,
and design patterns. He has championed distributed computing, scripting languages, SOA,
browser applications, CMS, ESBs, web services, nosql and map-reduce, top-down structured
approach, UML, use cases, XP - extreme programming, iterative development, and agile
development. And, he is still moving forward.
Now, as he approaches his 40th year as a programmer, software architect, and product
manager—a career that has spanned eighty percent of his life. He greatly enjoys guiding and
coaching the next generation of programmers and software architects—awakening others to
the same joy and passion for computing that he has had for the past 40 years.
I'd like to thank my family for giving me the space to complete this book.
They have always been supportive and remain my biggest fans.
I'd also like to thank my colleagues Corny, David, Darren, and Pete who have
always been available for advice and snippets of code when I needed them;
Greg, John, and Steve who were long ago my interns but still remain sources
of inspiration; and Ingo who is now and will remain always my muse.
And, most importantly, I'd like to thank my father, George H. Golden Jr.,
who sat me down in front of a teletype when I was eight years old and
showed me how to play Hunt The Wumpus. Not only did my dad introduce
me to computers and computer programming, he also introduced me to
the Raspberry Pi. Without his encouragement, I could not have written
this book.
www.it-ebooks.info
About the Reviewers
Hector Cuesta-Arvizu provides consulting services for software engineering and data
analysis with over 8 years of experience in a variety of industries including financial services,
social networking, e-learning, and Human Resources. He is a Raspberry Pi enthusiast.
Shea Silverman has been using computers since he was two years old. He has always
been drawn to technology, video games, education, and the public sector. He is currently a
member of the Orlando hackerspace FamiLAB, an alumni of the University of Central Florida,
and is working towards his Masters in Nonprofit Management.
I would like to thank my family and friends for their ongoing support in
my endeavors. I would also like to thank Liz, Eben, and the Raspberry
Pi Foundation for the creation of the Raspberry Pi, and the wonderful
community that has flourished since its release.
www.it-ebooks.info
www.PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub
files available? You can upgrade to the eBook version at www.PacktPub.com and as a print
book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up
for a range of free newsletters and receive exclusive discounts and offers on Packt books
and eBooks.
TM
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book
library. Here, you can access, read and search across Packt's entire library of books.
Why Subscribe?
ff Fully searchable across every book published by Packt
ff Copy and paste, print and bookmark content
ff On demand and accessible via web browser
www.it-ebooks.info
Table of Contents
Preface 1
Chapter 1: Installation and Setup 7
Introduction 7
Preparing for the initial boot 9
Printing a case – the Punnet 18
Setting up new SD cards 22
Image writer for Windows cards (Win32DiskImager) 25
Convert and copy for Linux (dd) 27
Creating SD cards with BerryBoot 30
Booting the "official" Raspbian Linux distribution 37
Shutting down the Raspberry Pi (shutdown) 41
Chapter 2: Administration 45
Introduction 45
Configuring remote access (raspi-config) 46
Configuring memory usage (raspi-config) 50
Remote access (SSH) 53
Remote access (PuTTY) 58
Changing the login password (passwd) 62
Chapter 3: Maintenance 65
Introduction 65
Updating the operating system (apt-get) 66
Searching for the software packages (apt-cache) 74
Installing a package (apt-get) 75
Package management (aptitude) 79
Reading the built-in documentation (man) 83
Reading the built-in documentation (info) 86
www.it-ebooks.info
Table of Contents
ii
www.it-ebooks.info
Preface
Back in 2006, Eben Upton and his colleagues at the University of Cambridge's Computer
Laboratory noticed a disturbing trend—interviewees for degree course placement did not know
enough about what a computer is or how it worked. So, he set out to design an inexpensive
computer that would inspire kids to experiment with computers at home—a similar to the
hobbyist computers, such as the Apple II, Amiga, and Commodore 64 computers of a
generation before. On February 29, 2012, the first batch of 10,000 Raspberry Pis sold out
within a few minutes, crashing the websites of the stores selling them. By the end of 2012
more than 500,000 Raspberry Pis have been sold and not just to school children.
The Raspberry Pi credit-card-sized single-board computer costs about $35 and has as much
computing power as the early Xbox—more than enough power for playing games, running a
home media center, a file server, a website, a small database, or a wireless access point. Its
Broadcom System on a chip (SoC) architecture includes a powerful graphics processing
unit (GPU), and the single-board design includes a network port, an HDMI connection, two
USB ports, an SD card slot, and 512 MB of memory. There is more power and there are more
features available on this small, inexpensive computer today than there were on the expensive
desktop computers that ran the original Windows operating system.
This book contains recipes that take advantage of the power and features of the Raspberry Pi
to create a number of practical solutions that can be realized without programming—solutions
that anyone with minimal computer skills can apply in their home or office. This book is not
about educating or inspiring children to learn computer programming. This book is for parents,
hobbyists, and computer geeks who would like to learn more about the Raspberry Pi's "official"
Raspbian Linux operating system and the advanced networking solutions that are available
for the Raspberry Pi today.
www.it-ebooks.info
Preface
Chapter 2, Administration, contains a collection of recipes for the Raspberry Pi that cover the
basic administration of the Raspberry Pi including how to access the Raspberry Pi remotely
using Secure Shell.
Chapter 3, Maintenance, has recipes that are for the basic maintenance of the Raspberry Pi
including installing and updating new software and accessing the built-in documentation.
Chapter 4, File Sharing, has recipes that are for sharing files with other computers on the
same local network including automounting disks and installing a file server.
Chapter 5, Advanced Networking, has recipes that are for advanced networking solutions
including setting up a webserver, a wiki, and a wireless access point.
ff A Raspberry Pi
ff A 5V power supply (the Raspberry Pi does not usually come with one)
ff A keyboard
ff A mouse
ff A display (a TV or a monitor)
ff A handful of SD cards
ff USB devices ( such as an external disk)
ff A network connection
You may also want to purchase a case and a powered USB hub. They will help you protect your
Raspberry Pi. The case protects the Raspberry Pi from the elements, and the powered USB
hub protects it from the power drain that results from connecting too many devices.
www.it-ebooks.info
Preface
The recipes in the first three chapters do not require any additional devices other than the
Raspberry Pi and a network connection. The recipes in Chapter 4, File Sharing, show how to
connect a USB disk to the Raspberry Pi. And in Chapter 5, Advanced Networking, the final
recipe shows how to use a USB wireless network adapter to turn the Raspberry Pi into a
wireless access point.
For most of the recipes in this book, you will just need the Raspberry Pi, a power supply, and a
network connection. After completing the recipes in Chapter 2, Administration, the Raspberry
Pi can be accessed remotely and does not require a display, keyboard, or mouse.
The book is also intended to turn the beginning Raspberry Pi user into an accomplished
Linux administrator. Even an advanced Linux user will find the recipes in this book useful
as a reference for creating advanced networking solutions with the Raspberry Pi.
The recipes in this book begin simply leading the reader through the installation and basic
administration of the Raspberry Pi. As the book progresses, the solutions become more
advanced, building on the knowledge gained from previous recipes. The final chapter contains
a number of advanced networking solutions.
Although inexpensive, the Raspberry Pi has enough power for a number of practical solutions
both at home and at the office. This book is for those who would like to use the Raspberry Pi
in practical solutions, not just as an educational toy.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of
information. Here are some examples of these styles and an explanation of their meaning.
Code words in text are shown as follows: "This recipe shows how to update the Raspberry Pi
using the apt-get command."
New terms and important words are shown in bold. Words that you see on the screen, in
menus or dialog boxes for example, appear in the text like this: "Clicking the Next button
moves you to the next screen."
www.it-ebooks.info
Preface
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this
book—what you liked or may have disliked. Reader feedback is important for us to
develop titles that you really get the most out of.
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to
get the most from your purchase.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do
happen. If you find a mistake in one of our books—maybe a mistake in the text or the
code—we would be grateful if you would report this to us. By doing so, you can save other
readers from frustration and help us improve subsequent versions of this book. If you find
any errata, please report them by visiting http://www.packtpub.com/submit-errata,
selecting your book, clicking on the errata submission form link, and entering the details of
your errata. Once your errata are verified, your submission will be accepted and the errata
will be uploaded on our website, or added to any list of existing errata, under the Errata
section of that title. Any existing errata can be viewed by selecting your title from
http://www.packtpub.com/support.
www.it-ebooks.info
Preface
Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt,
we take the protection of our copyright and licenses very seriously. If you come across any
illegal copies of our works, in any form, on the Internet, please provide us with the location
address or website name immediately so that we can pursue a remedy.
We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at questions@packtpub.com if you are having a problem with any
aspect of the book, and we will do our best to address it.
www.it-ebooks.info
www.it-ebooks.info
Installation and Setup
1
In this chapter we will cover:
Introduction
This chapter introduces the Raspberry Pi and explains how to download and install fresh
images of popular Raspberry Pi distributions and how to set them up for the initial boot.
Developed by Raspberry Pi Foundation in the U.K. for promoting the teaching of basic
computer science in schools, the Raspberry Pi is a single-board computer about the
size of a credit card. The Raspberry Pi is based on a Broadcom BCM2835 System on
a Chip (SoC) that includes a 700 MHz ARM1176JZF-S processor. The Raspberry Pi is well
designed for experimenting with computers and learning computer programming. Its eight
General-Purpose Input/Output (GPIO), I2C bus, and SPI bus also make it an ideal choice
for experimenting with computer hardware and peripheral devices.
www.it-ebooks.info
Installation and Setup
The Raspberry Pi also has two USB ports, an onboard Ethernet network connector (RJ45),
both HDMI and Composite RCA video outputs, and audio output via a 3.5 mm jack or over
HDMI—the same type of high-speed connections that are found on most desktop computers
and laptops. With these standard peripheral connections the Raspberry Pi has the potential
to be much more than just an educational tool or an experimenter's toy.
The preceding image shows two Raspberry Pis with their original packaging.
Although the Raspberry Pi was designed for experimenting, this book is about using the
Raspberry Pi in practical networking solutions both at home and at the office. This chapter
begins by listing the components you will need, in addition to the Raspberry Pi, for practical
application of the solutions described in this book. The first recipe explains how to create a
simple yet sturdy case for the Raspberry Pi, out of paper. The remaining recipes describe
how to download, install, and configure a number of common Raspberry Pi-optimized
operating systems.
Once you've completed this chapter, you will have created a simple case to protect your
Raspberry Pi; you will have downloaded, installed, and configured an operating system for
your Raspberry Pi; and you will have booted your Raspberry Pi for the first time. You will also
understand how to create application cartridges for your Raspberry Pi.
www.it-ebooks.info
Chapter 1
The Raspberry Pi is shipped without a case and without a power supply. There is no keyboard.
There is no monitor. Depending on how you intend to use the Raspberry Pi, you will need
additional components. As a minimum, you will need a power supply, an SD card, and a
network cable.
An HDMI cable (or composite video cable), a USB keyboard, and a USB mouse are needed
if you'd like to use the Raspberry Pi as you would use a desktop computer. You may wish
to attach additional peripherals depending on how you intend to use the Raspberry Pi.
This recipe suggests a number of different hardware combinations.
After completing this recipe you will be ready for the initial boot of your Raspberry Pi.
The preceding image shows a Raspberry Pi without a case, an SD card, and a power supply.
Getting Ready
The following are the basic components required for this recipe:
ff Raspberry Pi
ff Class 4 SD card of 4 GB (or greater)
ff 5V micro USB power supply
9
www.it-ebooks.info
Installation and Setup
The Raspberry Pi draws its power from a 5V micro USB power supply and needs an SD card
for its operating system. A single 4-GB SD card has more than enough room for hosting the
operating system, as well as many useful applications. While no further components are
required to boot the Raspberry Pi, the networking solutions in this book will require
additional components.
The preceding image shows a Raspberry Pi with an SD card, a network, and power cables.
The essential networking required for this recipe is a network connection. For the simplest
networking solutions, the only additional component that the Raspberry Pi needs is a network
connection. Once the operating system on the SD card has been configured, remote logins to
the Raspberry Pi are possible.
10
www.it-ebooks.info
Chapter 1
The media center required is a HDMI television or monitor. For the simplest media solutions,
in addition to the basic components, the only additional component that the Raspberry Pi
needs is an HDMI connection. Both audio and video can be streamed through the Raspberry
Pi's HDMI connection. There is enough room on a 4 GB SD card to store a small collection of
music and video files, in addition to the operating system.
The preceding image shows a Raspberry Pi in the Punnet with monitor, keyboard, and mouse.
11
www.it-ebooks.info
Installation and Setup
The Raspberry Pi has two USB ports, with enough power to support low-power devices such as
a USB Bluetooth adapter, a simple keyboard, or a mouse.
When using the Raspberry Pi as a firewall or wireless access point, an additional LAN or WLAN
adapter is required. If the adapter is powered by the USB connection, an additional powered
USB connector will be required for the adapter to operate reliably.
USB devices that require power over the USB connection, such as multimedia keyboards, gamer
mice, cameras, printers, or external hard drives (including thumb drives), should be attached
indirectly via a powered USB hub instead of directly attaching them to either of the Raspberry
Pi's two USB ports. For greater reliability, the USB ports on the Raspberry Pi should typically be
connected to powered USB hubs instead of directly connecting them to USB devices.
The Raspberry Pi is an excellent gaming platform whether for creating games, for playing
single-player console games, or for playing multiplayer network games. Many of the older
text-based games can be played on the Raspberry Pi with just a keyboard or via a remote
login. However, USB game controllers can also be connected to the Raspberry Pi to further
enrich the gameplay of multimedia action games.
12
www.it-ebooks.info
Chapter 1
The preceding image shows a Raspberry Pi in the Punnet lying on a USB hub with
devices attached.
ff Raspberry Pi
ff Class 4 SD card of 4 GB (or greater)
ff 5V micro USB power supply
ff Powered USB hub
ff Network cable
ff HDMI or DVI monitor
ff HDMI to DVI adapter (optional)
ff Speakers
ff Keyboard
ff Mouse
13
www.it-ebooks.info
Installation and Setup
A power supply, preformatted SD card, monitor, keyboard, and mouse are the bare minimum
components needed for an initial setup. A DVI monitor can be attached to the Raspberry
Pi using an HDMI-to-DVI adapter. Both the HDMI-to-DVI adapter and the speakers can be
replaced with a single HDMI cable connected directly to an HDMI television. When connected
with HDMI, the television will output audio as well as video. The yellow RCA connector also
provides video output for older televisions.
How to do it...
The following are the steps for booting the Raspberry Pi:
14
www.it-ebooks.info
Chapter 1
How it works…
The Raspberry Pi does not come with a case. While it is not necessary for experimenting, you'll
probably want a case for protecting the Raspberry Pi. The next recipe in this chapter shows
how to make a case from paper (see the Printing a case – the Punnet recipe given next).
Before you can boot the Raspberry Pi, you'll need an SD card with a bootable disk image
on it. The "official" Raspbian Linux image for the Raspberry Pi is downloadable from
http://www.raspberrypi.org/downloads.
Once the disk image has been downloaded, it needs to be written to an SD card (see the
Setting up new SD cards recipe given later).
After the SD card has been prepared and inserted into the Raspberry Pi, the display, keyboard,
and mouse can be connected to the Raspberry Pi; and it is ready for booting (see the Booting
the "official" Raspbian Linux distribution recipe given later).
When it is time to turn the Raspberry Pi off, the operating system must first be shut down—the
opposite of booting (see the Shutting down the Raspberry Pi (shutdown) recipe given later).
There's more…
The Raspberry Pi is a very low-cost, single-board computer ($35 for the current model). It is
sold "bare bones" and requires a power supply, a preformatted SD card to hold its operating
system, and a keyboard and a display before it can do anything useful. However, it does
have a number of standard I/O connections that will enable it to connect to a large variety
of devices.
ff Power (5V at 700mA): The Raspberry Pi has a micro USB power connector that
should be connected directly to a power supply, neither to the USB port on a
computer nor to a USB hub.
ff Preformatted SD card (class 4): The Raspberry Pi is designed to boot from a
preformatted SD Card (4 GB or greater is recommended).
ff GPIO: Analog and digital I/O connection for expansion and experimenting.
ff RCA video (composite video): The Raspberry Pi can be used with older televisions
that have a composite video input.
ff Audio output (3.5 mm jack and stereo): The Raspberry Pi does not have an audio
input connector; however, a USB mic or sound card can be added.
ff LEDs: These are disk, power, and network traffic indicators. When these LEDs are
flashing, the Raspberry Pi is actively processing.
15
www.it-ebooks.info
Installation and Setup
ff USB 2.0 (two ports): There is limited power available on these ports. Devices
connected to the Raspberry Pi via USB should have their own power supply or
they should be connected indirectly via a powered USB hub.
ff Network (10/100 wired Ethernet RJ45): The onboard networking competes for
bandwidth with the attached USB devices.
ff HDMI (1080p30): This may be used for both video and audio output. It cannot be
used at the same time as the RCA video.
ff System on chip
Broadcom BCM2835 media processor
CPU core – ARMv6 architecture; ARM11 core at 700MHz
GPU core – 24 GFLOPS of compute power
Memory – 512 MB SDRAM stacked on media processor
ff LAN9512
10/100 Mb Ethernet (Auto-MDIX)
2x USB 2.0
The recommended accessories include a powered USB hub as it has the following advantages:
ff It has its own power supply separate from the Raspberry Pi's power supply
ff It has enough power to support the attached devices
However, the Raspberry Pi has some power supply problems. It is difficult to say how much
power is actually needed by the Raspberry Pi, as it varies depending on how busy it is and
which peripherals are connected. However, there have been problems reported that seem
related to an inadequate supply of power. These problems are reduced or eliminated when the
power supply for the Raspberry Pi produces at least 700mA at 5V and when USB devices are
connected indirectly through a powered USB hub.
16
www.it-ebooks.info
Chapter 1
See also
ff Raspberry Pi
http://en.wikipedia.org/wiki/Raspberry_pi
A detailed Wikipedia article about the Raspberry Pi.
ff DesignSpark – Raspberry Pi
http://www.designspark.com/theme/raspberrypi.
ff The MagPi
http://www.themagpi.com
The MagPi is a magazine for Raspberry Pi users. Monthly issues are available online.
17
www.it-ebooks.info
Installation and Setup
The Raspberry Pi is a single-board computer without a case. Cases are available from
a number of retailers (see the See also section of this recipe for a few suggestions).
However, the Raspberry Pi is normally sold without a case.
For general experimentation and setup, the Raspberry Pi does not really need a case.
It will function perfectly well sitting on top of the box that it came in, or on top of a powered
USB hub. Although for regular use, as part of one of the solutions in this book, a case
is recommended.
Once you finish with this recipe, you will have a simple protective case for your Raspberry Pi.
The preceding image shows the Punnet printed and ready to use.
18
www.it-ebooks.info
Chapter 1
Getting ready
The Punnet is a printable card case for the Raspberry Pi. It requires less than an hour to
assemble; however, a couple of hours should be allowed for the glue to set firmly before use.
A printable PDF template of the Punnet can be found on the Raspberry Pi Foundation website
(http://www.raspberrypi.org/archives/1310).
ff A Raspberry Pi
ff The Punnet PDF file (see the link given in the See also section)
ff Heavy card stock paper
ff White glue
ff Cellophane tape
ff A straightedge or ruler
ff A hobby knife
How to do it...
The following are the steps for creating a Raspberry Pi case out of paper:
1. Print the PDF file on heavy card stock paper, or print the file on copy paper and then
glue the copy paper to the heavier paper.
2. Carefully cut out the Punnet. Use the hobby knife with the straightedge as a guide for
cutting straight lines.
3. Use the straightedge to score and crease the folds. This will make assembly easier.
19
www.it-ebooks.info
Installation and Setup
4. Fold the Punnet around the Raspberry Pi and glue it, as shown in the previous
screenshot. Apply the glue sparingly—too much glue causes the paper to warp.
The preceding image shows the Punnet in use. A printed Punnet was glued to pink card stock
before folding. The card stock added strength and stability to the case.
How it works…
The Punnet is a simple paper box made from a single sheet of paper with cutouts marked that
align with the Raspberry Pi's connectors. The 50-mm scale printed on the page can be used
to validate the dimensions of the printout. Turn off any Scale to fit feature of the printer to
ensure that the page is printed at 100 percent. Once the page is printed, the scale printed on
the page can be measured to see if it is 50-mm long. If it is not 50-mm long, adjust the scale
in the printer properties and try printing the page again.
The PDF page format is designed for A4 paper (used in Europe); however, it should print fine
on 8½ x 11" paper (used in the USA) if the page is printed with actual size. The printed side
of the page will become the outside of the Punnet.
20
www.it-ebooks.info
Chapter 1
There's more…
It is easier to assemble the Punnet around a Raspberry Pi than trying and putting a Raspberry
Pi in a pre-assembled Punnet. First score the dotted lines so that it is easier to fold them,
then set the Raspberry Pi on the Punnet. Fold up the tabs and spread a small amount of glue
on the outside of each tab. Finally, fold up the sides around the Raspberry Pi and glue them
together. Use cellophane tape to strengthen the corners.
A straightedge or ruler is a useful tool for cutting and folding on straight lines; and a hobby
knife works better than scissors. White glue works well, if used sparingly.
Don't forget to cut a hole in the top to let cool air in. The Raspberry Pi can overheat if it is
kept fully enclosed.
A number of commercial cases are available for the Raspberry Pi (see the links give next).
21
www.it-ebooks.info
Installation and Setup
See also
ff The Punnet
http://www.raspberrypi.org/archives/1310
This is the original article featuring a home printable cardboard case for the
Raspberry Pi.
ff Raspberry box
http://www.amazon.com/shops/ATLOHWI71UDEX
This transparent acrylic box lets the inner beauty of the Raspberry Pi shine through.
From Spain, the retailer also makes classical guitars.
ff Pi Holder
http://www.piholder.com
The Pi Holder is a solid aluminium case with cooling pillars in the top half that attach
directly to the three heat-emitting IC chips on the Raspberry Pi. This case keeps the
Raspberry Pi cool and protected—a good choice for production use.
The Raspberry Pi does not come with an operating system. Before the Raspberry Pi can boot,
it needs an SD card with the operating system installed. Pre-installed SD cards are available
for purchase; however, downloading and installing an operating system's image is not difficult.
22
www.it-ebooks.info
Chapter 1
How to do it…
The following are the steps on how to write an image to the SD card:
How it works…
The "official" Raspbian Linux operating system image can be downloaded from the
Raspberry Pi Foundation website (http://www.raspberrypi.org/downloads).
Other operating system images can be found on the Embedded Linux community's wiki
page (http://elinux.org/RPi_Distributions).
If you are writing the SD card from a Windows computer, use Win32DiskImager.exe
(see the Image Writer for Windows cards (Win32DiskImager) recipe).
If you are using the Linux operating system or Mac OS to write the image to the SD card,
use the dd command-line utility (see the Convert and copy for Linux (dd) recipe).
If you'd like to try a simpler way of installing the Raspberry Pi that works on any computer
that can copy files to a formatted SD card, use BerryBoot (see the Creating SD cards with
BerryBoot recipe).
See also
ff The Raspberry Pi website – downloads
http://www.raspberrypi.org/downloads
This is the location of the "official" versions of Raspberry Pi optimized GNU Linux
distributions. Currently, Raspberry Pi Foundation recommends four distributions
of the Linux operating system, as follows:
Raspbian "Wheezy"
Soft-float Debian "Wheezy"
Arch Linux ARM
RISC OS
23
www.it-ebooks.info
Installation and Setup
The Soft-float Debian distribution is a slower distribution that has not been optimized
to use the Raspberry Pi's hardware-accelerated floating-point calculations. It has
been made available for use with software that has not been optimized yet (such
as Oracle's JVM). The other distributions are listed next with links to their original
maintainers' websites.
ff Raspbian
http://www.raspbian.org
Raspbian is a Linux operating system distribution based on Debian optimized for
the Raspberry Pi and comes with more than 35,000 packages pre-compiled for the
Raspberry Pi.
ff RISC OS
http://www.riscosopen.org/
The RISC OS was designed in Cambridge, originating from the same
team that designed the ARM processor, and was originally released in 1987.
ff GNU
http://www.gnu.org
The homepage of the GNU operating system.
24
www.it-ebooks.info
Chapter 1
Once you finish with this recipe, you will be able to write Raspberry Pi images to SD cards from
a Windows computer.
Getting ready
The following are the ingredients:
How to do it...
The following are the steps for writing a disk image to an SD card on a Windows computer:
The preceding screenshot shows the contents of the Win32DiskImager ZIP file.
25
www.it-ebooks.info
Installation and Setup
The preceding screenshot shows Win32 Disk Imager being used to write the
recommended Raspbian GNU Linux distribution to an SD card.
Writing an image to a disk takes about 5 minutes for a 2-GB image file. Once the
image is written to the SD card, the SD card may be ejected and used to boot the
Raspberry Pi.
How it works...
First, the image writer for Windows (Win32DiskImager) is downloaded and installed.
Finally, Win32 Disk Imager is used to write the Raspberry Pi disk image to the SD card.
There's more...
The utility, Win32DiskImager, was originally written to read and write disk images for
a specific Linux distribution; since then, however, it has been generalized and is now a
popular tool for many development projects such as the Raspberry Pi.
Win32DiskImager is also an excellent backup tool! After booting and configuring the
Raspberry Pi, a backup can be made to preserve the image in case the SD card is
damaged or lost.
26
www.it-ebooks.info
Chapter 1
A new backup should be created after each update to the Raspberry Pi's operating system,
application software, or configuration.
See also
ff Image writer for Windows
https://launchpad.net/win32-image-writer
This utility that was originally written to read and write disk images for a specific Linux
distribution; however, since then it has been generalized and is now a popular tool for
many development projects such as the Raspberry Pi.
Most versions of Linux (and Mac OS) have the dd command installed. This powerful version of
the copy command (cp) can be used to write blocks of data to devices such as an SD card.
Once you finish with this recipe, you will be able to write an SD card from a Linux
(or Mac OS) computer.
Getting ready
The following are the ingredients:
The dd utility is normally installed by default with most Linux distributions. If it is not installed,
use the appropriate Linux installation utility to install it.
All the commands in this example are executed as a privileged user (root).
27
www.it-ebooks.info
Installation and Setup
How to do it...
The following are the steps for writing a disk image to an SD card on a Linux computer:
The preceding screenshot shows the df command being used to discover the name of the SD
card drive, the umount command being used to unmount the SD card, and the dd command
being used to write the recommended distribution to an SD card.
How it works...
First a Raspberry Pi disk image is downloaded.
Then, the name of the SD drive is discovered using the df command. The df command shows
how much disk is free on each of the mounted disk drives. The SD card was just inserted, and
its primary partition (p1) appears in this list as /dev/mmcblk0p1. The disk device is /dev/
mmcblk0.
28
www.it-ebooks.info
Chapter 1
Finally, the dd command is used to write the Raspberry Pi disk image to the SD card. The
following is the explanation for the command: dd bs=1M if=2012-08-16-wheezy-
rasbian.img of=/dev/mmcblk0:
There's more...
The utility dd is one of the core GNU utilities found in most Linux distributions. It is a low-level
utility that simply copies blocks of data from one file to another.
The previous screenshot shows an example of how the df command can be used to
determine the name of the SD drive. The first partition of the SD disk, /dev/mmcblk0p1, is
mounted at /media/A1B1-918F. Disk images cover a whole disk, not just one partition, so
the correct name of the disk drive in the previous example is /dev/mmcblk0 (notice that p1
is missing).
Before the image is copied to the SD card in the previous example, the disk partition is
unmounted (umount /dev/mmcblk0p1—notice there is no n in umount). It is a good
practice to unmount all disk partitions before formatting or overwriting a disk.
The dd utility can also be used as a backup tool. Just exchange the input file (if=) and output
file (of=).
Use the following command to create a backup using the disk from the previous example:
dd bs=1M if=/dev/mmcblk0 of=backup-2012-08-16.img
See also
ff dd (Unix)
http://en.wikipedia.org/wiki/Dd_(Unix)
This article from Wikipedia explains original application of the dd command.
29
www.it-ebooks.info
Installation and Setup
ff dd (gnu – coreutils)
http://www.gnu.org/software/coreutils/manual/html_node/dd-
invocation.html
The GNU operating system manual reference for dd.
BerryBoot supports the installation of multiple Linux distributions on a single SD card and is
by far the easiest way of installing an operating system for your Raspberry Pi. However, it does
require an Internet connection during setup and installation.
The installation takes place by booting the Raspberry Pi with an installer that can be easily
copied to a FAT-formatted SD card using drag-and-drop from any PC. When the Raspberry Pi
boots, the installer runs and uses the Raspberry Pi's network connection to download the
latest distribution of selected operating systems.
Getting ready
You will need the following:
ff An initial Raspberry Pi setup (see the Preparing for the initial boot recipe)
ff The latest berryboot.zip file (see the link given in the See also section
of this recipe)
ff A class 4 SD card of 4 GB (or greater)
ff A network connection
30
www.it-ebooks.info
Chapter 1
The Raspberry Pi needs to be connected to the Internet (via a home or office network) to
complete this recipe. During installation, the network connection is used to download the
selected distribution files. Without an Internet connection this recipe will not work.
How to do it...
The following are the steps for creating a boot disk with BerryBoot:
1. Format the SD card as a bootable FAT disk. Use the normal disk formatting tools that
come with your PC's operating system.
2. Extract the contents of the berryboot.zip file to the newly formatted SD card.
Again, the normal archival tools that come with your PC will do the job.
3. Connect your Raspberry Pi to a network with access to the Internet.
31
www.it-ebooks.info
Installation and Setup
4. Insert the SD card in the Raspberry Pi and turn it on. This will start the BerryBoot
installation process.
5. After the network interfaces have been detected, the Welcome dialog box
is displayed.
i. Set the appropriate video scan option (the example shows a green
overscan area indicating overscanning should be disabled).
ii. The time zone and keyboard layout are also set on the Welcome
dialog box.
32
www.it-ebooks.info
Chapter 1
6. The Disk selection dialog box can be used to select an installation disk other than
the SD card. The target disk may be formatted in one of the following three ways:
B-tree file system (BTRFS) for scalable storage
ext4 – with discard flag set for SDD disks
ext4 – no discard is the default
www.it-ebooks.info
Installation and Setup
7. After the disk is formatted, BerryBoot downloads the list of available operating
system images. The Add OS dialog box is used to select which operating system
will be downloaded and installed next.
8. The BerryBoot menu editor screen is used to add additional operating systems and
manage those that have already been installed. All the installed images will appear in
the BerryBoot boot menu.
The Add OS button is used to add another operating system to the boot
menu (and repeat previous step)
The Edit button is used to change the name of the image displayed on the
boot menu and to configure the memory split
The Clone button duplicates the current image in the boot menu
The Export button can be used to export the current disk image to an
external disk
The Delete button deletes the current operating system from the boot menu
The Make Default button can be used to select which image will boot
by default
The Exit button is used to reboot the Raspberry Pi
34
www.it-ebooks.info
Chapter 1
How it works...
First an SD card is formatted as a bootable FAT disk (using the utility of your choice). Then the
BerryBoot installation files are copied to the disk. No special image writers are required! Just
drag-and-drop all the unarchived files onto the SD card.
Once all the installation files are copied to the newly formatted SD card, the disk can
be safely ejected and inserted into an unpowered Raspberry Pi. When the power cord is
connected to the Raspberry Pi, the Raspberry Pi will boot automatically into the BerryBoot
installation application.
After booting, the Raspberry Pi tries to detect all attached network cards. The installation
application can detect many modern wireless USB network cards; however, only a limited
number are actually configurable by the application. Once the network has been detected
(and selected), the Welcome screen is displayed.
The BerryBoot install application will then detect any attached USB disk devices (or network
storage). The installation application will permit the operating system to be installed on a disk
other than the SD card. However, the Raspberry Pi will still need the BerryBoot SD card to
boot. The Raspberry Pi will not boot from any other device. Choose mmcblk0 to format the SD
card. For most uses, the ext4 filesystem is the best choice. The B-tree file system (BTRFS)
has advanced features that are not covered in this book. Choose ext4 – with discard
flag set when formatting the SD card.
After the disk is formatted, the Add OS screen appears with a selection of Raspberry
Linux distributions. There are distributions for using the Raspberry Pi as a media center
(OpenELEC), as a classroom workstation (LTSP thin client BerryTerminal), and as a web
server (BerryWebserver). There are also alternative Linux distributions (Puppy Linux
and Sugar). And, of course, the "official" Raspbian Linux distribution is also included.
Once a Linux distribution has been chosen, it is downloaded and added to the boot menu.
Choosing Exit from the BerryBoot menu editor screen reboots the Raspberry Pi. After reboot,
the downloaded distributions are displayed on the boot menu and the user can select which
distribution to boot.
Application cartridges
Each of the recipes in this book could be used to create an "application cartridge".
An application cartridge is like a game cartridge that is plugged into a game console, ready
to play. The only difference is an application is stored on the cartridge instead of a game. So
when the application cartridge is plugged into the Raspberry Pi, an application is started and
is ready to use.
35
www.it-ebooks.info
Installation and Setup
Using application cartridges, the Raspberry Pi can easily be repurposed just by switching the
cartridge (the SD card). After shutting down and turning off the Raspberry Pi, the current SD
card in the Raspberry Pi could be replaced with another SD card that has a different image
installed on it – easily switching the Raspberry Pi from one purpose to another.
Write a multimedia home theatre distribution, for example OpenELEC or Raspbmc on one SD
card to create a home theatre application cartridge. Write an IPFire image on another SD card
to create a firewall application cartridge. A Berry Terminal image could be used to create an
application cartridge for client access to a terminal server; or recipes from this book could be
used to create application cartridges for a file server, a web server, or a wireless access point.
See also
ff BerryTerminal
http://www.berryterminal.com
This Linux distribution turns the Raspberry Pi into a low-cost thin client allowing users
to log in to a central Linux Terminal Server Project (LTSP) server. Thin clients can be
used to run applications from Linux and Windows servers. Thin clients are reliable,
cost-effective solutions for improving total cost of ownership (TCO) for organizations
that only require simple desktop features (schools, call centers, factories).
ff IPFire
http://en.wikipedia.org/wiki/IPFire
IPFire is a GNU Linux distribution that acts as a router and firewall. The Wikipedia
article describes the distribution in more detail. You can download IPFire from
http://www.ipfire.org/.
ff XMBC
http://en.wikipedia.org/wiki/XBMC
You can find a Wikipedia article describing the free and open source media player
application developed by the XBMC Foundation.
36
www.it-ebooks.info
Another Random Scribd Document
with Unrelated Content
Charl. What, married to a man unable too?
O strange incontinence! Why, was thy blood
Increased to such a pleurisy of lust,[158]
That of necessity there must a vein
Be opened, though by one that had no skill
To do't?
Charl. Speak.
Charlemont discovered.
Charl. I grant thee, Heaven, thy goodness doth command
Our punishments, but yet no further than
The measure of our sins. How should they else
Be just? Or how should that good purpose of
Thy justice take effect by bounding men
Within the confines of humanity,
When our afflictions do exceed our crimes?
Then they do rather teach the barbarous world
Examples that extend her cruelties
Beyond their own dimensions, and instruct
Our actions to be much more barbarous.
O my afflicted soul! How torment swells
Thy apprehension with profane conceit,
Against the sacred justice of my God!
Our own constructions are the authors of
Our misery. We never measure our
Conditions but with men above us in
Estate. So while our spirits labour to
Be higher than our fortunes, they are more base.
Since all those attributes which make men seem
Superior to us, are man's subjects and
Were made to serve him. The repining man
Is of a servile spirit to deject
The value of himself below their estimation.
Cata. Come, Soquette, your work! let's examine your work. What's
here? a medlar with a plum tree growing hard by it; the leaves o' the
plum tree falling off; the gum issuing out o' the perished joints; and
the branches some of 'em dead, and some rotten; and yet but a
young plum tree. In good sooth very pretty.
Soqu. The plum tree, forsooth, grows so near the medlar that the
medlar sucks and draws all the sap from it and the natural strength
o' the ground, so that it cannot prosper.
Cata. How conceited you are![164] But here th'ast made a tree to
bear no fruit. Why's that?
Soqu. There grows a savin tree next it, forsooth.[165]
Cata. Forsooth you are a little too witty in that.
Enter Sebastian.
Sebas. But this honeysuckle winds about this white thorn very
prettily and lovingly, sweet Mistress Cataplasma.
Cata. Monsieur Sebastian! in good sooth very uprightly welcome this
evening.
Sebas. What, moralizing upon this gentlewoman's needlework? Let's
see.
Cata. No, sir. Only examining whether it be done to the true nature
and life o' the thing.
Sebas. Here y' have set a medlar with a bachelor's button o' one side
and a snail o' the tother. The bachelor's button should have held his
head up more pertly towards the medlar: the snail o' the tother side
should ha' been wrought with an artificial laziness, doubling his tail
and putting out his horn but half the length. And then the medlar
falling (as it were) from the lazy snail and ending towards the pert
bachelor's button, their branches spreading and winding one within
another as if they did embrace. But here's a moral. A poppring[166]
pear tree growing upon the bank of a river seeming continually to
look downwards into the water as if it were enamoured of it, and
ever as the fruit ripens lets it fall for love (as it were) into her lap.
Which the wanton stream, like a strumpet, no sooner receives but
she carries it away and bestows it upon some other creature she
maintains, still seeming to play and dally under the poppring so long
that it has almost washed away the earth from the root, and now
the poor tree stands as if it were ready to fall and perish by that
whereon it spent all the substance it had.
Cata. Moral for you that love those wanton running waters.
Sebas. But is not my Lady Levidulcia come yet?
Cata. Her purpose promised us her company ere this. Sirrah, your
lute and your book.
Sebas. Well said. A lesson o' the lute, to entertain the time with till
she comes.
Cata. Sol, fa, mi, la.—Mi, mi, mi.—Precious! Dost not see mi between
the two crotchets? Strike me full there.—So—forward. This is a
sweet strain, and thou finger'st it beastly. Mi is a laerg[167] there,
and the prick that stands before mi a long; always halve your note.—
Now—Run your division pleasingly with these quavers. Observe all
your graces i' the touch.—Here's a sweet close—strike it full; it sets
off your music delicately.
Enter Servant.
Ser. My lord.
D'Am. I prithee call my daughter.
Enter Castabella.
Charl. Twelve.
Bor. 'Tis a good hour: 'twill strike one anon.
Charl. How fit a place for contemplation is this dead of night, among
the dwellings of the dead.—This grave—Perhaps the inhabitant was
in his lifetime the possessor of his own desires. Yet in the midst of all
his greatness and his wealth he was less rich and less contented
than in this poor piece of earth lower and lesser than a cottage. For
here he neither wants nor cares. Now that his body savours of
corruption
He enjoys a sweeter rest than e'er he did
Amongst the sweetest pleasures of this life,
For here there's nothing troubles him.—And there
—In that grave lies another. He, perhaps,
Was in his life as full of misery
As this of happiness. And here's an end
Of both. Now both their states are equal. O
That man with so much labour should aspire
To worldly height, when in the humble earth
The world's condition's at the best, or scorn
Inferior men, since to be lower than
A worm is to be higher than a king.
Cast. How?
Cast. O God!
Is Thy unlimited and infinite
Omnipotence less free because thou doest
No ill?
Or if you argue merely out of nature,
Do you not degenerate from that, and are
You not unworthy the prerogative
Of Nature's masterpiece, when basely you
Prescribe yourself authority and law
From their examples whom you should command?
I could confute you, but the horror of
The argument confutes my understanding.—
Sir, I know you do but try me in
Your son's behalf, suspecting that
My strength
And youth of blood cannot contain themselves
With impotence.—Believe me, sir,
I never wronged him. If it be your lust,
O quench it on their prostituted flesh
Whose trade of sin can please desire with more
Delight and less offence.—The poison o' your breath,
Evaporated from so foul a soul,
Infects the air more than the damps that rise
From bodies but half rotten in their graves.
D'Am. Conjure up
The devil and his dam: cry to the graves:
The dead can hear thee: invocate their help.
D'Am. Tereus-like
Thus I will force my passage to—
D'Am. Why dost thou stare upon me? Thou art not
The soul of him I murdered. What hast thou
To do to vex my conscience? Sure thou wert
The head of a most doggèd usurer,
Th'art so uncharitable. And that bawd,
The sky there: she could shut the windows and
The doors of this great chamber of the world,
And draw the curtains of the clouds between
Those lights and me, above this bed of earth,
When that same strumpet Murder and myself
Committed sin together. Then she could
Leave us i' the dark till the close deed was done.
But now that I begin to feel the loathsome horror of my sin, and, like
a lecher emptied of his lust, desire to bury face under my eye-brows,
and would steal from my shame unseen, she meets me
I' the face with all her light corrupted eyes
To challenge payment o' me. O behold!
Yonder's the ghost of old Montferrers, in
A long white sheet climbing yon lofty mountain
To complain to Heaven of me.—
Montferrers! pox o' fearfulness! 'Tis nothing
But a fair white cloud. Why, was I born a coward?
He lies that says so. Yet the countenance of
A bloodless worm might ha' the courage now
To turn my blood to water.
The trembling motion of an aspen leaf
Would make me, like the shadow of that leaf,
Lie shaking under 't. I could now commit
A murder were it but to drink the fresh
Warm blood of him I murdered to supply
The want and weakness o' mine own,
'Tis grown so cold and phlegmatic.
Watch. But, sir, she's taken with you, and she must
To prison with you.
Fres. Precious! I was sent by his lady to see if her lord were in bed. I
should ha' done't slily without discovery, and now I am blurted upon
'em before I was aware. [Exit.
Bel. Know not you the gentlewoman my wife brought home?
Ser. By sight, my lord. Her man was here but now.
Bel. Her man? I prithee, run and call him quickly. This villain! I
suspect him ever since I found him hid behind the tapestry.
Re-enter Fresco.
Fresco! th'art welcome, Fresco. Leave us. [Exit Servant.] Dost hear,
Fresco? Is not my wife at thy mistress's?
Fres. I know not, my lord.
Bel. I prithee tell me, Fresco—we are private—tell me:
Is not thy mistress a good wench?
Fres. How means your lordship that? A wench o' the trade?
Bel. Yes, faith, Fresco; e'en a wench o' the trade.
Fres. O no, my lord. Those falling diseases cause baldness, and my
mistress recovers the loss of hair, for she is a periwig maker.
Bel. And nothing else?
Fres. Sells falls, and tires, and bodies for ladies, or so.
Bel. So, sir; and she helps my lady to falls and bodies now and then,
does she not?
Fres. At her ladyship's pleasure, my lord.
Bel. Her pleasure, you rogue? You are the pander to her pleasure,
you varlet, are you not? You know the conveyances between
Sebastian and my wife? Tell me the truth, or by this hand I'll nail thy
bosom to the earth. Stir not, you dog, but quickly tell the truth.
Fres. O yes! [Speaks like a crier.
Bel. Is not thy mistress a bawd to my wife?
Fres. O yes!
Bel. And acquainted with her tricks, and her plots, and her devices?
Fres. O yes! If any man, o' court, city, or country, has found my Lady
Levidulcia in bed but my Lord Belforest, it is Sebastian.
Bel. What, dost thou proclaim it? Dost thou cry it, thou villain?
Fres. Can you laugh it, my lord? I thought you meant to proclaim
yourself cuckold.
Enter The Watch.
Bel. The watch met with my wish. I must request the assistance of
your offices.
[Fresco runs away.
'Sdeath, stay that villain; pursue him! [Exeunt.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com