39,59 €
Connect your Raspberry Pi to the world with this essential collection of recipes for basic administration and common network services
This book is intended for students, scientists, and hobbyists who wish to connect their Raspberry Pi to other devices on a local area network or to the Internet of Things. Whether you are new to the Raspberry Pi, or already have a lot of experience with it, the recipes in this book will be a valuable reference to you and inspire your next project. You will want to have this book handy as a guide whenever you are working on networking projects for the Raspberry Pi.
With increasing interest in Maker Projects and the Internet of Things (IoT), students, scientists, and hobbyists are using the Raspberry Pi as a reliable, inexpensive platform to connect local devices to Internet services.
This book begins with recipes that are essential to installing the Raspberry Pi and configuring it for network access. Then it continues with recipes on installing common networking services such as firewalls and file sharing.
The final chapters include recipes for network monitoring, streaming data from the Raspberry Pi to IoT services, and using clusters of Raspberry Pis to store and analyze large volumes of data.
This book contains a collection of practical, engaging recipes that will guide you through enhancing your Raspberry Pi's existing network.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 441
Veröffentlichungsjahr: 2016
Copyright © 2015 Packt Publishing
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.
First published: March 2013
Second edition: January 2016
Production reference: 1241215
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-021-4
www.packtpub.com
Author
Rick Golden
Reviewers
Stefan Pietzonke
Werner Ziegelwanger
Acquisition Editor
Vivek Anantharaman
Content Development Editor
Arshiya Ayaz Umer
Technical Editors
Mohit Hassija
Edwin Moses
Copy Editors
Vedangi Narvekar
Jonathan Todd
Project Coordinator
Shipra Chawhan
Proofreader
Safis Editing
Indexer
Priya Sane
Production Coordinator
Shantanu N. Zagade
Cover Work
Shantanu N. Zagade
Rick Golden, in the summer of 1972, sat in the computer lab at SUNY Fredonia and completed his first CAI tutorial on programming in APL. He was 9 years old then.
He has been programming computers for over 40 years. He has designed and developed a multitude of projects, from low-level graphics and database drivers to large-volume e-commerce platforms.
At work, Rick is currently focused on developing software to improve healthcare by mining petabytes of healthcare claims to find opportunities to improve healthcare coordination. After work, Rick teaches 10-14 year olds how to program using Raspberry Pi computers.
I would like to thank my dad for giving me the opportunity to learn programming at such a young age, which was unheard of in the 1970s. His wisdom, patience, and faith in my programming abilities has encouraged me to become the man that I am today.
I would also like to thank my wife and family for supporting me during the many hours that I spent working on this book. Without their support, this book would not have been written.
Finally, I would like to thank Packt Publishing for giving me the opportunity to update this book and my editor, Arshiya Umer, for keeping me focused on my deadlines. Without her help and encouragement, this book would not have been published.
Stefan Pietzonke grew up in a village and wrote his first computer program at the age of 14. His first computer was an Amiga 500. He learned to program in Amiga BASIC. Now, he mostly writes programs in the C/C++ language.
He developed his own virtual machine called "Nano". The bytecode for the Nano VM can be created by using his assembler or compiler.
He also likes to conduct hardware projects. He built a robot from a computer mouse case. This robot is autonomous, drives around, and seeks light.
He has a blog (http://midnight-koder.net/wordpress/) about his software and hardware projects.
I want to thank my family for supporting me.
Werner Ziegelwanger studied game engineering and simulation and got his master's degree in 2011. His master's thesis was published with Terrain Rendering with Geometry Clipmaps for Games as the title. The publisher was Diplomica Verlag. His hobbies are programming, games, and all kinds of technical gadgets.
He worked as a self-employed programmer for some years and mainly did web projects. At that time, he started his own blog (http://developer-blog.net), which is about the Raspberry Pi, Linux, and open source.
Since 2013, Werner has worked as a Magento developer and the head of programming at mStage GmbH, an e-commerce company that is focused on Magento.
For support files and downloads related to your book, please visit 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 <[email protected]> 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.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.
A Raspberry Pi 2, with its 900MHz quad-core processor, has more processing power than a network server from the late-1990s. Created as an educational tool to inspire the next generation of programmers, the Raspberry Pi is also an excellent network server. It can be used to share files, host websites, create Internet access points, and analyze network traffic. Multiple Raspberry Pis can be clustered to create a single, highly available, and fault-tolerant super computer. This book shows you how.
The Raspberry Pi Foundation recognized that computers had become so expensive and arcane that programming experimentation on them had to be forbidden by parents. The parental restrictions on using computers had created a year-on-year decline in the numbers and skills levels of the A Level students applying to read Computer Science. So, the Foundation set out to create a computer that was "affordable, and powerful enough to provide excellent multimedia, a feature we felt would make the board desirable to kids who wouldn't initially be interested in a purely programming-oriented device".
2 million Raspberry Pis were sold in the first two years of its release, which was not limited to educators and school children. Hobbyists were also excited to use the inexpensive Linux-based computer in their projects. In February 2015, the quad-core Raspberry Pi 2 was released with significantly more power and memory than the original, which was more than enough memory and power for many typical server applications.
In this cookbook, you'll find a collection of server-side recipes for the Raspberry Pi, including recipes to set up file servers and web servers, create secure wireless access points, and analyze network traffic. There is even a recipe to create a highly available fault-tolerant supercomputer.
Chapter 1, Installation and Setup, has a number of beginner recipes to set up the Raspberry Pi as a network server, which include instructions on how to download and install new operating system images, boot for the first time, and the proper way to shut down the system.
Chapter 2, Administration, has more beginner recipes to configure the Raspberry Pi as a network server, which includes instructions on how to execute privileged commands, configure remote access, and manage user accounts.
Chapter 3, Maintenance, has intermediate and advanced recipes to maintain the Raspberry Pi server. You'll learn how to update software, read the built-in documentation, and upgrade the system.
Chapter 4, File Sharing, has a number of different intermediate recipes to share files.
Chapter 5, Advanced Networking, has a collection of advanced recipes to set up and monitor network applications, including a firewall, web server, wireless access point, and network protocol analyzer.
Chapter 6, IoT - The Internet of Things, has several intermediate recipes to connect your Raspberry Pi to the Internet of Things.
Chapter 7, Clustering, has advanced recipes to create a highly available fault-tolerant supercomputer from a cluster of Raspberry Pis.
For most of the recipes in this book, you will need a little more than a basic Raspberry Pi setup (Raspberry Pi and a power supply) that is connected to a local area network.
You may choose to use a display, keyboard, and a mouse with the Raspberry Pi. However, most recipes have been written to remotely access the Raspberry Pi as a server.
Internet access is required to download software and connect to the Internet of Things.
This book is for students, educators, hobbyists, and computer professionals who would like to use the Raspberry Pi as a network server.
Previous experience with the Raspberry Pi is not required. After completing the beginner and intermediate recipes in this book, you will gain the knowledge and experience that you will need to complete even the advanced recipes.
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Use the chown command to give the user pi ownership of the directory (.) and all of the files in it (*)."
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Press the Tab key to select Finish and then press the Enter key:"
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
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 at www.packtpub.com/authors.
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.
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from http://www.packtpub.com/sites/default/files/downloads/Raspberry_Pi_Networking_Cookbook_ColorImages.pdf.
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 could 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 to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted 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.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will cover the following topics:
This chapter introduces the Raspberry Pi. It begins by listing the components that you will need, such as a power supply, in addition to the Raspberry Pi.
The core recipes of this chapter describe how to download, install, and configure a number of common Raspberry Pi operating systems.
The last two recipes describe the initial boot of the official Raspbian Linux distribution and how to safely power off the Raspberry Pi.
Once you've completed this chapter, you will have downloaded, installed, and configured an operating system for your Raspberry Pi and booted your Raspberry Pi for the first time.
This recipe explains which components are needed for the initial boot, in addition to the Raspberry Pi, before it can be powered on for the first time.
The Raspberry Pi Foundation has released a number of versions of the Raspberry Pi since it was first released in June 2012, which include Raspberry Pi B (April 2012), Raspberry Pi A (February 2013), Raspberry Pi Compute Module (April 2014), Raspberry Pi Model B+ (July 2014), and the Raspberry Pi 2 Model B (February 2015).
The original Raspberry Pi Model B has a memory of only 512 MB, a single-core processor, and two USB ports. The current model, the Raspberry Pi 2 Model B, has a memory of 1 GB, a quad-core processor, and four USB ports.
The examples in this book feature the Raspberry Pi 2 Model B.
The Raspberry Pi is shipped without a case and power supply. There is no keyboard or monitor. Depending on how you intend to use the Raspberry Pi, you will need additional components. For the majority of the recipes in this book, you will only need a power supply, an SD card, and a network cable.
You may wish to attach additional peripherals, depending on how you intend to use the Raspberry Pi. An HDMI 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. This recipe lists a number of different Raspberry Pi projects and the peripherals needed to complete them.
After completing this recipe, you will be ready for the initial boot of your Raspberry Pi.
To get started with this recipe, there are a few prerequisites that you must be familiar with.
These are some of the basic components:
The Raspberry Pi draws its power from a 5V micro USB power supply and needs an SD card for its operating system. While no further components are required to boot the Raspberry Pi, many of the networking solutions in this book will require additional components.
A single 4 GB SD Class 10 card has more than enough room and speed to host the base operating system as well as many useful applications. Because the SD card is where the Raspberry Pi stores its operating system, the speed of the operating system is dependent on the speed of the SD card. Class 10 cards will have better performance than Class 4 or Class 6 cards. The Embedded Linux Wiki maintains an SD Card compatibility table, which can be viewed by visiting http://elinux.org/RPi_SD_cards.
In addition to an SD Card, the Raspberry Pi will need additional components for many applications. For most of the recipes in this book, you will need only a network connection. For some, you may also need a display as well as a keyboard and mouse.
The following are a few examples of networking applications and the components that they will need.
By basic networking, we mean having a network connection. For the simplest networking solutions, the only additional component that the Raspberry Pi needs is a network connection—either a direct TCP cable connection, or a wireless network USB dongle. Once the network is configured and remote logins to the Raspberry Pi are possible, the Raspberry Pi can be remotely accessed, updated, and administered.
As part of media centers, we will require an HDMI television or monitor.
For the simplest network media solutions, in addition to the basic networking 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. Furthermore, there is enough room on an SD card to store a small collection of music and video files in addition to the operating system.
If you are using desktop computers, these will be required:
The Raspberry Pi 2 has four USB ports, with enough power to support low-power devices, such as a USB keyboard or a USB mouse. With its quad-core processor, it is powerful enough to browse the Web, send e-mails, and edit documents or images. Because it runs the Linux operating system, the Raspberry Pi can also run hundreds of educational, scientific, and business programs. In short, the Raspberry Pi can run many useful open source desktop applications.
For network hubs, we will require these:
When using the Raspberry Pi as a firewall or wireless access point, an additional LAN or WLAN network adapter is required. If the network adapter is powered from the USB connection, an additional powered USB connector will be required for the adapter to operate reliably.
The Raspberry Pi is an excellent gaming platform if you wish to create games, or play single-player console games or multi-player 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.
A power supply, preformatted SD card, monitor, keyboard, and mouse are the bare minimum components that are needed for an initial setup. When connected with an HDMI to a television, the television will output audio as well as video.
Perform the following steps to boot the Raspberry Pi:
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 can be downloaded from http://www.raspberrypi.org/downloads.
Once the disk image has been downloaded, it needs to be written to an SD card (refer to the Setting up new SD cards recipe).
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. Then it is ready to be booted (refer to the Booting Raspbian Linux recipe).
Connect the power supply in the end! There is no on-off switch for the Raspberry Pi. When the power supply is connected, the Raspberry Pi immediately boots. Therefore, it is important to have all the cables connected and the SD card inserted before connecting the power supply.
When it is time to turn off the Raspberry Pi, the operating system must first be shut down, which is the opposite of booting (refer to the Shutting down the Raspberry Pi recipe).
The Raspberry Pi 2 is a low-cost single-board computer (it costs only $35). It is sold bare bones and requires a power supply, a preformatted SD card to hold its operating system, a keyboard, and a display before it can do anything useful. However, it does have a number of standard I/O interfaces and on-board components that will enable it to connect to a large variety of devices.
The standard connectors and interfaces for the Raspberry Pi are as follows:
The central on-board components for the Raspberry Pi are as follows:
In addition to a power supply, the following accessories are recommended:
It is difficult to say how much power is actually needed by the Raspberry Pi because the power needed varies depending on how busy the Raspberry Pi is and which peripherals are connected. However, problems related to an inadequate supply of power have been reported. These problems are reduced or eliminated when the power supply for the Raspberry Pi produces at least 800mA at 5V and the USB devices are connected indirectly through a powered USB Hub.
Here are some of the symptoms:
Here are the causes:
Here are the solutions:
The following recipes explain how to create bootable SD cards from downloaded disk images using Win32DiskImager.exe, dd, and diskutil.
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. Preinstalled SD cards are available for purchase. However, downloading and installing an operating system image is not difficult.
Once you've completed this recipe, you will know how to download a Raspberry Pi operating system. The following recipes will show you how to write it to an SD card.
Perform the following steps to write an image to the SD card:
The easiest way to get started with the Raspberry Pi is to download the NOOBS (New Out Of Box Software) distribution from the Raspberry Pi Foundation website, which can be viewed by visiting http://www.raspberrypi.org/downloads. The files from this distribution can be copied directly to a formatted SD card. No additional disk utilities are required to create a bootable image (refer to the Booting with NOOBS recipe).
Included with NOOBS is the Raspberry Pi Foundation's recommended operating system distribution, Raspbian Linux. On the downloads page, you will also find a link to the Raspbian Linux disk image. There are links to a number of other third-party operating systems too. For more images for the Raspberry Pi, visit the Embedded Linux community's wiki page (http://elinux.org/RPi_Distributions).
Unlike NOOBS, once one of these individual operating system images is downloaded, you'll need to write it to an SD card using a special disk utility.
If you are using the Mac OS operating system, use diskutil and dd to write the operating system image to an SD card (refer to the Mac OS Disk Utilities recipe). If you are writing the SD card from a Windows computer, use Win32DiskImager.exe (refer to the Image Writer for Windows recipe). If you are using the Linux operating system to write the image to the SD card, use the dd command-line utility (refer to the Convert and Copy for Linux recipe).
The Raspbian Linux distribution is recommended by the Raspberry Pi Foundation. It also is the operating system distribution that is used throughout this book.
The Embedded Linux for the Raspberry Pi distributions (http://elinux.org/RPi_Distributions): The Embedded Linux community maintains an excellent wiki page on Raspberry Pi operating system distributions. The wiki page has a comparison table and links to downloadable image files. Many of these distributions are specialized for a specific use, such as penetration testing; use as a home theater, firewall, or an inexpensive desktop PC; or the development of software.Windows 10IoT—Downloads (https://ms-iot.github.io/content/Downloads.htm): Windows for IoT and the other tools that you will need to develop for Windows IoT devices such as the Raspberry Pi are available at this website.As of this revision, the Window 10 IoT distribution does not have a user interface. It is labeled as Windows 10 IoT Core Insider Preview. The tools needed to interact with the IoT Core are available from the downloads page of Windows 10 IoT.
This recipe explains how to use the Raspberry Pi Foundation's NOOBS to install a Raspberry Pi operating system.
NOOBS is not an operating system distribution. It is a tool that is used to install operating systems. By using NOOBS, you can select an operating system for your Raspberry Pi.
This is the easiest way to get started with the Raspberry Pi. No special disk utilities are required. Therefore, this recipe works from any computer that has an SD card writer.
Once you've completed this recipe, you will be able to use NOOBS to select an operating system for your Raspberry Pi.
Ingredients:
The installation of NOOBS on an SD card is not operating system-specific.
Download the NOOBS ZIP file (NOOBS_v1_4_2.zip) from the Raspberry Pi website (https://www.raspberrypi.org/downloads/noobs/).
The following steps are required to copy NOOBS to an SD card:
The NOOBS installation process is not operating system-specific. The files in the NOOBS ZIP file simply need to be expanded onto a newly formatted SD card.
Once the files have been expanded onto the SD card, the SD card can be safely ejected from the computer and inserted into the Raspberry Pi.
After the SD card is firmly inserted into the Raspberry Pi and all of its other components are connected (the HDMI monitor, network connection, USB keyboard, and USB mouse), you can connect the power supply and boot the Raspberry Pi. Ensure that the power supply is connected in the end. Otherwise, your Raspberry Pi will not boot properly.
When the Raspberry Pi is finished booting NOOBS, you will be presented with a choice of operating systems. Select Raspbian [RECOMMENDED] from the top of the list by pressing the Spacebar or clicking on it with the mouse. Click on Install (i) or press the I key to install the Raspbian Linux operating system.
Raspbian Linux is the operating system that is used throughout this book.
NOOBS will then extract the Raspbian Linux operating system and reboot the Raspberry Pi. As NOOBS is extracting the operating system, you will be presented with a few tips on how to use the Raspberry Pi, including the default username and password (the default username is pi and the default password is raspberry).
After the Raspberry Pi is rebooted, you will be ready to use the raspi-config command to complete the installation (refer to the Booting Raspbian Linux for the first time recipe).
NOOBS is the easiest way to get started with the Raspberry Pi. It is an installation tool and not a complete operating system.
In this recipe, you used NOOBS to install the Raspbian Linux operating system. NOOBS can also be used to install a number of other operating systems, including Arch, OpenELEC, Pidora, and RaspBMC.
By using NOOBS, Raspbian Linux can be configured so that it boots directly into an easy-to-use programming environment called Scratch. NOOBS also has a built-in configuration editor that can be used by experts to apply additional tweaks to the boot configuration.
NOOBS is designed to make it easier to select and install operating systems for the Raspberry Pi without having to worry about manually imaging an SD card.
This recipe explains how to use the diskutil and dd disk utilities that are found on a Mac OS X computer to install a Raspberry Pi operating system image on an SD card.
You should have already downloaded a Raspberry Pi disk image and you should be ready to write the disk image onto an SD card.
Once you've completed this recipe, you will be able to write an SD card from a Mac OS X computer.
Ingredients:
Both the diskutil and dd disk utility commands are installed by default with the Mac OS X operating system. The diskutil command is used to administer disk devices, and the dd command is used to copy data to and from a disk device.
The dd command requires administrative privileges. Use the sudo command to temporarily give the user administrative privileges.
The following steps need to be performed to write a disk image to an SD card on a Linux computer:
Choose the disk carefully! Ensure that you do not erase the wrong disk!
Here is an example of a Terminal session that shows the diskutil and dd commands being used to discover the name of the SD card's disk drive, unmount the SD card, and write a Raspberry Pi disk image to the SD card:
The diskutil command is used to find the name of the SD card and unmount the disk.
The command is first used with the list subcommand to show information about each mounted disk drive.
After the SD card is inserted, the SD card appears in this list as /dev/disk2.
Now that we know that the SD card disk device is /dev/disk2, the SD card is unmounted by using the unmountdisk subcommand.
Finally, the dd command is used to write the Raspberry Pi disk image to the SD card:
Note that the output file is named /dev/rdisk2 and not /dev/disk2. The extra r asks Mac OS X to use the raw mode when writing to the disk. The raw mode is much faster, if you want to write, than the default mode.
The diskutil command utility is a feature-rich tool that is used to modify, verify, and repair disks on Mac OS X. More information about the diskutil command can be found by using the built-in man pages (man diskutil).
Before the image is copied to the SD card in the preceding example, the disk partition is unmounted (diskutil unmountdisk). It is important to unmount the disk before formatting or overwriting it.
When the image is copied with the dd command,
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 preceding example:
Pressing Ctrl + T while the dd command is running will cause the command to report its progress.
More information about thedd command can be found in its man pages (man dd).
This recipe shows how to install a Raspberry Pi operating system image on an SD card using the open source Image Writer for Windows, Win32DiskImager.exe.
You should have already downloaded a Raspberry Pi disk image, and you should be ready to write the disk image onto an SD card using a Windows PC.
To complete this recipe, you will also need an Internet connection to download Image Writer for Windows.
Once you've completed this recipe, you will be able to write Raspberry Pi images to SD cards from a Windows computer.
Here are the ingredients:
The precompiled binary of Win32DiskImager is distributed as a ZIP file and can be downloaded from https://launchpad.net/win32-image-writer.
The following steps are required to write a disk image to an SD card on a Windows computer:
Writing an image to disk takes about 5 minutes for a 2 GB image file. Once the image is written to the SD card, the SD card can be ejected and used to boot the Raspberry Pi.
First, you will need to download and install Image Writer for Windows (Win32DiskImager). The Win32DiskImager is a single standalone executable and can be installed to a folder that is located anywhere on your PC.
Double-click on the expanded Win32DiskImager executable to start the application.
Once the application has started, select the downloaded Raspberry Pi disk image as the source Image File and then select the location of the SD card writer as the target device. When you click on the Write button, the Win32DiskImager writes the Raspberry Pi disk image to the SD card.
The 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.
To create a backup, perform the following steps:
The steps needed to back up a Raspberry Pi disk image from an SD card are similar to those required to write the image. The only difference is that during a backup, the SD card is the source of the copy, and a new image on the disk is the target.
