Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi Zero Cookbook

You're reading from   Raspberry Pi Zero Cookbook Delve into the practical world of the Raspberry Pi Zero

Arrow left icon
Product type Paperback
Published in Mar 2017
Publisher Packt
ISBN-13 9781786463852
Length 422 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Edward Snajder Edward Snajder
Author Profile Icon Edward Snajder
Edward Snajder
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Kick-Start Your Raspberry Pi Zero FREE CHAPTER 2. Setting Up Physical and Wireless Connections 3. Programming with Linux 4. Programming with Python 5. Getting Your Hands Dirty Using the GPIO Header 6. Controlling the LEDs and Displays 7. Controlling the Hardware 8. Taking Digital Inputs to the Raspberry Pi Zero 9. Interfacing Sensors with the Raspberry Pi Zero 10. Cooking up Projects to Amaze the World!

Using Ubuntu 16.04 to validate a Raspbian image and write it to an SD card

If you are using Ubuntu 12.04 or earlier, the Ubuntu ImageWriter is a GUI tool that makes the installation very easy. If you are using a newer version, usb-imagewriter is not available, but SD cards can still be created from the command line. This will generally work on most flavors of Linux; check with your project's documentation to see the recommended method.

How to do it...

  1. I find the easiest method is to look at what is mounted. If the SD card is inserted, it should be automatically recognized:
    $ mount -l
    

  2. Another way to find the mount(s) on the SD card is looking using the dmseg command. Ubuntu's documentation recommends using dmesg to find out which device the SD card is. Insert the SD card and run this:
    $ dmesg | tail -20
    

  3. You'll get a response similar to this:

    How to do it...

    dmesg output after SD card insertion

  4. Before overwriting, you need to detach the disks that are mounted. In this case, sdd1 and sdd2 are the mounted partitions for device sdd, as shown in the last line of the image above.
  5. In Linux, your disk devices are usually identified by looking in the /dev/ folder for devices starting with sd (for example sda, sdb, sdc). A partition is a division of the physical volume so it can be treated as different devices, and they can be identified by having incremental numbers (for example sdd has partitions sdd1 and sdd2):
    $ sudo umount /dev/sdd1
    $ sudo umount /dev/sdd2
    

  6. After downloading the latest ZIP file of the Raspbian image from the Raspberry Pi website, you can validate it using the sha1sum tool:
    $ sudo sha1sum ~/Downloads/2016-05-27-raspbian-
        jessie.zip
    64c7ed611929ea5178fbb69b5a5f29cc9cc7c157
       /media/sf_Downloads/2016-05-27-raspbian-jessie.zip
    

  7. If your return value matches the SHA-1 value on the Raspberry Pi Downloads page, unzip the file, and run the dd command to write your image to the SD card. Make sure you are using the correct device!

    The dd command is for entire disks, so we reference sdd instead of the partitions sdd1 or sdd2. We don't want to duplicate things to partitions, we want to duplicate the entire disk, and whatever partitions your source has will be applied to the destination, our SD card.$ sudo dd bs=1M if=/path/to/raspbian-jessie.img of=/dev/sdd

Note

The dd command can take a while to run, and doesn't provide any output while it is, so you can get that feeling it might be stuck. Be patient, depending on the speed of your SD Card it could take several minutes to copy.

The output will be similar to this:

How to do it...

dd command input and output

After several minutes, your card will be ready to go!

Whichever way you decided to set up your SD card, you are just a few connections away from getting your Raspberry Pi Zero online!

You have been reading a chapter from
Raspberry Pi Zero Cookbook
Published in: Mar 2017
Publisher: Packt
ISBN-13: 9781786463852
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime