How to write Raspbian Jessie image file to SD cards on Apple macOS / OS X

Posted on in Categories , , , last updated June 27, 2017

I got a Raspberry PI 3 from my friend. I am a long term macOS user. How do I write Raspbian image file to SD card using macOS?

Raspberry PI 3 is a small and affordable SBC (Single-board computer) that you can use to learn programming or Linux operating system for fun and profit. This tutorial shows how to download and install Raspbian on SD cards when using Apple macOS.

Steps to write Raspbian Jessie image file to SD cards:

  1. Find your SD card name such as /dev/disk2
  2. Unmount /dev/disk2
  3. Write raspbian-jessie.img file using a dd command
  4. sudo dd bs=1M if=fileName.img of=/dev/rdiskN
  5. Finally the eject the SD card and insert into your Raspberry PI 3 computer

Step 1 – Download Raspbian

Visit this page to grab the latest version of OS. I downloaded a file named 2017-06-21-raspbian-jessie.zip. One can double click to extract the zip file or use the unzip command:
$ unzip 2017-06-21-raspbian-jessie.zip
This resulted into a file named 2017-06-21-raspbian-jessie.img. You need to use 2017-06-21-raspbian-jessie.img for writing on SD card.

Step 2 – Find your SD card name on macOS

First, insert the SD card in your Mac. Open the terminal app and type the following diskutil command:
diskutil list
Sample outputs:

Fig.01: Identify the SD card on macOS
Fig.01: Identify the SD card on macOS

Where,

  • I have 16 GB SD card on my system.
  • I have identified the disk /dev/disk2 as my SD card
  • Do not use the partition such as /dev/disk2s1, /dev/disk2s2 and so on.
  • Depend upon your Mac config your SD card name may be /dev/disk3 or /dev/disk4 and so on. Use the SD card size to identify correct device name.

Step 3 – Unmount your SD card

To unmount a single volume named /dev/disk2, run:
diskutil unmountDisk /dev/disk2
Sample outputs:

Unmount of all volumes on disk2 was successful

Step 4 – Write the image to your SD card

Warning: The dd command overwrite your SD card. If you give the wrong disk name, the following command will wipe out your data and macOS hard disk. You have been warned. Please keep backups and be careful while typing commands.

You need to use the dd command as follows to write downloaded 2017-06-21-raspbian-jessie.img file to /dev/rdisk2 (remember to replace /dev/disk2 with /dev/rdisk2):
$ sudo dd bs=1m if=2017-06-21-raspbian-jessie.img of=/dev/rdisk2
Sample outputs:

4444+1 records in
4444+0 records out
4659871744 bytes transferred in 385.614770 secs (12084267 bytes/sec)

Step 5 – Eject a disk

To safely remove the SD card and make it ready for use, type the following command:
$ diskutil eject /dev/rdisk2
Sample outputs:

Disk /dev/rdisk2 ejected

Now, remove the SD card and insert into your Raspberry PI 3 computer. Power it on and enjoy your new operating system. Here is my desktop:

Fig.02: Raspberry PI powered by Raspbian Jessie
Fig.02: Raspberry PI powered by Raspbian Jessie (click to enlarge)

And there you have it, Raspbian Jessie installed and running. Happy programming.

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

4 comment

  1. … or make your life so much easier and use Etcher. Early versions were a bit flaky on the Mac but recent ones work flawlessly.

Comments are closed.