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

  • 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 (click to enlarge)

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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Leaman Crews Jun 28, 2017 @ 3:03

    Excellent post! I have been using this method to write .iso files to USB sticks and SD cards in OS X/macOS for a long time now. But I recently discovered a nice GUI frontend for this process, Apple Pi Baker: https://www.tweaking4all.com/software/macosx-software/macosx-apple-pi-baker/

  • Biggles Jun 28, 2017 @ 6:40

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

    • 🐧 Vivek Gite Jun 28, 2017 @ 17:31

      Thanks for Etcher. To be honest I stick with default. But, I guess if you are a new user, you might wanna try out easy to tools.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum