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:
- Find your SD card name such as /dev/disk2
- Unmount /dev/disk2
- Write raspbian-jessie.img file using a dd command
- sudo dd bs=1M if=fileName.img of=/dev/rdiskN
- 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:
- 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
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
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
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:
And there you have it, Raspbian Jessie installed and running. Happy programming.