Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
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 OS X to validate a Raspbian image and write it to an SD card

If you are a Mac user, the process will be a little different from the Windows recipe, but still not too difficult. To do it, we'll leverage OS X's built-in *nix system tools.

Note

Mac OS X used to have a lot of options for easy GUI image writers, but many of them were not updated over time. After Yosemite 10.10.5, the Raspberry Pi community recommends using command-line tools. Fortunately, it is a pretty easy process.

How to do it...

The process for validating and copying a NOOBs installation on OS X is fairly straightforward:

  1. Open a Terminal window in OS X.
  2. Next, run shasum against the downloaded ZIP file to validate the signature:
    $ shasum ~/Downloads/2016-05-27-raspbian-jessie.zip 
    64c7ed611929ea5178fbb69b5a5f29cc9cc7c157
        /Users/ed/Downloads/2016-05-27-raspbian-jessie.zip
    

    How to do it...

    The Raspbian Jessie download and SHA-1 signature

  3. If the return value matches the SHA-1 signature provided on the Raspberry Pi downloads page, your file is good and can be unzipped:

    Note

    As the downloads change, the SHA-1 will change too, so you'll likely be comparing a different number to your shasum output.

    $ unzip ~/Downloads/2016-05-27-raspbian-jessie.zip 
    Archive:  /Users/ed.snajder/Downloads/2016-05-27-
        raspbian-jessie.zip
    inflating: 2016-05-27-raspbian-jessie.img  
    

  4. Next, look at the filesystem before inserting the SD card:
    $ df -h
    Filesystem      Size   Used  Avail Capacity  iused 
        ifree %iused  Mounted on
    /dev/disk1     232Gi  216Gi   16Gi    94% 56751574 
        4163032   93%   /
    devfs          205Ki  205Ki    0Bi   100%      710 
        0  100%   /dev
    map -hosts       0Bi    0Bi    0Bi   100%        0 
        0  100%   /net
    map auto_home    0Bi    0Bi    0Bi   100%        0  
        0  100%   /home
    map -fstab       0Bi    0Bi    0Bi   100%        0  
        0  100%   /Network/Servers
    

  5. Then, insert the SD card and run the command again:
    $ df -h
    Filesystem      Size   Used  Avail Capacity  iused 
        ifree %iused  Mounted on
    /dev/disk1     232Gi  216Gi   16Gi    94% 56751576 
        4163030   93%   /
    devfs          211Ki  211Ki    0Bi   100%      730 
        0  100%   /dev
    map -hosts       0Bi    0Bi    0Bi   100%        0  
        0  100%   /net
    map auto_home    0Bi    0Bi    0Bi   100%        0 
        0  100%   /home
    map -fstab       0Bi    0Bi    0Bi   100%        0 
        0  100%   /Network/Servers
    
    /dev/disk2s6    63Mi   20Mi   43Mi    32%      512 
          0  100%   /Volumes/boot
    
    
    /dev/disk2s1   1.1Gi  1.0Gi   92Mi    92%        0 
          0  100%   /Volumes/RECOVERY
    
    

  6. As you can see, /dev/disk2s6 and /dev/disk2s1 were added. This creates two partitions on disk2 - most SD cards will only have one, but however many there are mounted, you need to unmount them with diskutil:
    $ sudo diskutil unmount /dev/disk2s1
    Password:
    Volume RECOVERY on disk2s1 unmounted
    $ sudo diskutil unmount /dev/disk2s6
    Volume boot on disk2s6 unmounted
    

    Note

    Very important: Running dd on the wrong device will be disastrous - use with extreme caution!

  7. There is a critical difference now from typical Linux drives and dd use. Let's say you had the aforementioned configuration and see that the SD card disk is disk2. For the dd command, you will change this to rdisk2:
    $ sudo dd bs=1m if=./2016-05-27-raspbian-jessie.img 
        of=/dev/rdisk2
    
    3833+0 records in
    3833+0 records out
    4019191808 bytes transferred in 377.097088 secs (10658241 bytes/sec)
    

    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. Newer versions of dd (on Ubuntu 16.04 and newer) include the status=progress flag, which will indicate copying progress.

  8. Finally, eject the disk, and you are ready to go!
    $ sudo diskutil eject /dev/rdisk2
    Disk /dev/rdisk2 ejected
    

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 $19.99/month. Cancel anytime
Banner background image