38

I want to burn a .img file of Wheezy OS to my 8GB SD Card from Mac OS X but can't figure out how.

Any help would be appreciated.

user1133275
  • 2,167
  • 12
  • 30
  • Check out my answer [here](http://raspberrypi.stackexchange.com/a/4213/4062). The question is on backing up your SD card, but the process is identical, see the bit on restoring the image. Alternatively, [this wiki](http://elinux.org/RPi_Easy_SD_Card_Setup#Copying_an_image_to_the_SD_card_in_Mac.C2.A0OS.C2.A0X_.28command_line.29) may help. – Alex Coplan Dec 28 '12 at 15:06
  • 1
    You can use the open source graphical app [Etcher](https://etcher.io/) to do this, and it works on Mac, Windows and Linux. – Brad Parks Jun 18 '17 at 01:01
  • This app may be helpfull for you: http://alltheware.wordpress.com/2012/12/11/easiest-way-sd-card-setup/ Welcome ;) – user4056 Dec 28 '12 at 07:46
  • well maintained instructions at https://www.raspberrypi.org/documentation/installation/installing-images/mac.md – jimmont Jan 11 '21 at 08:03

9 Answers9

80

First, verify the path to your SD card. You can do this by running the following command from terminal:

diskutil list

The output shows a list of disks currently mounted on the system. Here's the relevant line from my output:

/dev/disk3
#:                       TYPE NAME                    SIZE       IDENTIFIER
0:     FDisk_partition_scheme                        *8.0 GB     disk3
1:                 DOS_FAT_32 RPISDCARD               8.0 GB     disk3s1

In this case I can verify /dev/disk3 is my SD card because the TYPE, NAME and SIZE values are correct.

If you have an existing partition on the disk you may need to unmount it, otherwise you'll get a "Resource busy" error message when you try to write the image.

diskutil unmount /dev/disk3s1

Now to write the image file to the disk. Note the 'r' added to rdisk3 which drastically improves write performance by telling dd to operate in raw disk mode:

sudo dd if=RetroPieImage_ver2.3.img of=/dev/rdisk3 bs=1m

Depending on the size of your SDcard this may take a while. You can press CTRL+T to see the current status of dd. As an example for my Samsung 8GB SD card the write speed was 12MB/s the command took 11mins to complete.

donturner
  • 900
  • 1
  • 6
  • 5
  • In case anyone is getting error `Resource busy` then go to Disk Utility, unmount your SD card and try again. It will work. – atulkhatri Jul 29 '17 at 19:25
31

There is a faq/howto available that discusses all the various OS-es. For the Mac it is (nearly) the same as under the various other types of Unix versions. The use of dd.

In short you type:

sudo dd if=path_of_your_image.img of=/dev/rdiskn bs=1m

N.B: the of=/rdev/diskn needs to be the SD card, if you do this wrong you might end up destroying your Mac system!!!! Be careful!

Be sure to use /dev/rdiskn instead of just /dev/diskn. This way you are not writing to a buffered device and it will complete much faster.

For a total step by step guide through this process please consult this explanation. There are 3 chapters for the Mac in this document.

The most easy way is described on the first chapter on Mac (Copying an image to the SD card in Mac OS X (Only with graphical interface)), it involves an application that does everything for you, to be complete I copy the link to this application here

ikku
  • 4,454
  • 1
  • 24
  • 28
  • It's not that difficult, and the actual copying is only one command, the rest is to make sure you will be writing to the correct device. And the first chapter states: The RPi-sd card builder utility is a app which will walk you through the process of installing to SD card. That sounds like a nice application that with a couple if clicks does what you want... The link for this app is in the document. – ikku Dec 27 '12 at 17:43
  • 1
    Can't get that to work. :( –  Dec 27 '12 at 17:51
  • Oh, and the application keeps crashing. –  Dec 27 '12 at 17:51
  • Then I guess you need to switch to option 2, [Mostly GUI](http://elinux.org/RPi_Easy_SD_Card_Setup#Copying_an_image_to_the_SD_card_in_Mac.C2.A0OS.C2.A0X_.28mostly_graphical_interface.29) – ikku Dec 27 '12 at 17:54
  • What application keeps crashing? dd? :-D – XTL Dec 28 '12 at 07:27
  • No, that app you can use for a 'one click write image to sd card' (RPi-sd card builder), that the howto on elinux.org talks about. – ikku Dec 28 '12 at 11:14
  • A couple of hints for using dd: If you receive the error 'Operation not supported' when using dd, remove the SD Card, re-insert it and then unmount the partition using the disk utility. If you aren't sure if it's still running you can open another terminal and enter the following: $ killall -INFO dd –  Jul 28 '14 at 02:33
  • -1 This answer is unsafe, even with the bold warning, until you add a way to check which disk/partition you should overwrite, @ikku. – Greg Dubicki Apr 02 '16 at 21:21
4

Try this: ApplePi-Baker

It's free, writes IMG files to SD-Card, can prepare a NOOBS card and can make a backup to IMG of your SD-Card.

  • 1
    DO NOT TRY THIS!!!! It freezes, then if you cancel, you get stuck with some partitions on the card that literally refuse to be deleted. Disk Utility has greyed out all of my format/erase options. – boulder_ruby Jan 01 '15 at 19:39
  • @boulder_ruby: some users seem to have authentication issues with v1.6 due to authentication requirements by OS X. Your problem however is completely new to me. Did you cancel of "Force Quit" (maybe this caused "dd" to go weird in the background)? – Hanzaplastique Jan 02 '15 at 09:12
2

In 2020, this accepted answer is obsolete: For most cases, people should follow the new raspberrypi.org Installation Guide.

Alternatively, the community-provided Etcher tool also provides a graphical tool to burn Pi IMG files to SD card.

Sometimes the built-in SD card reader gives errors with Etcher. If you don't have a USB SD adapter, 'dd' sometimes still works although the user must take care because the wrong command may damage their mac's OS.

If you must use 'dd', the accepted answer sudo dd if=path_of_your_image.img of=/dev/rdiskn bs=1m works (with care taken) however if you have installed Homebrew with the 'gnubin' utilities, it provides the GNU dd utility which has different syntax. For GNU dd (including Linux hosts) use 1M instead of 1m (otherwise you get error: "dd: invalid number: ‘1m’" which is what inspired me to add a new answer).

Scott Prive
  • 181
  • 4
0

You could also try: dd Utility

Features:

  • Write IMG files to memory cards and hard drives.
  • Backup and Restore IMG files to memory cards and hard drives.
  • Install and Restore compressed disk image files on the fly. Supported file formats: IMG, Zip, GZip and XZ.
  • Backup and compress disk image files on the fly in ZIP format to significantly reduce the file size of backups.
  • Ideal for flashing IMG files to SD Cards for use with Raspberry Pi, Arduino, BeagleBoard and other ARM boards.
  • Mac Retina displays supported.
0

I made a script to burn .img or .iso files to SD card or USB.

Github > burn.sh

Ghanima
  • 15,578
  • 15
  • 58
  • 113
0

Yes the simple answer is to just dd it, but there are some safety precautions you may want to enforce by wrapping your dd in a script;

#!/bin/bash

#
# copy_img_to_sd.sh
#

ME=$( id | grep root | wc -l | perl -p -e 's/[^0-9]+//g');
if [ "$ME" != "1" ] ;then
    echo "must be root"
    exit 1;
fi
IMG=$1
if [ ! -f $IMG ] ;then
    echo "can not find $IMG";
    exit 2;
fi 
DISK=$(ls -l /dev/disk? | wc -l |perl -p -e 's/[^0-9]//g')
if [ $DISK -lt 3 ] ; then
    echo "can not find sdcard";
    ls -l /dev/disk?
    exit 2;
fi
DISK=$(ls -1 /dev/disk? | tail -1);
R_DISK=$(ls -1 /dev/rdisk? | tail -1);
echo "we are about to do this:"
echo $(diskutil information $DISK | grep Total)
ls -1 /dev/disk?s* | grep "$DISK" | perl -p -e 's/^(.*)$/diskutil unmount $1;/g'
echo dd bs=1m if=$IMG of=$R_DISK
echo sync
echo diskutil eject $R_DISK
echo "Press [enter] to continue or [Ctrl]+[C] to cancel";
read YNM;
ls -1 /dev/disk?s* | grep "$DISK" | perl -p -e 's/^(.*)$/diskutil unmount $1;/g' | bash 2>/dev/null
dd bs=1m if=$IMG of=$R_DISK
sync
diskutil eject $R_DISK

Accidentally writing an image to your internal drive will require a fresh OS X install to correct. Backup and keep an install.log so if it ever happens to you you can laugh it off.

Steve Robillard
  • 34,158
  • 17
  • 102
  • 108
user1133275
  • 2,167
  • 12
  • 30
0

Found a really good link: http://www.tweaking4all.com/hardware/raspberry-pi/install-img-to-sd-card/#macosx for installing file.img on SD card, very detailed steps!

  • Can you add some more detail in your answer? Linking things Is not as helpful as explaining it... – Kachamenus Nov 08 '15 at 18:35
  • I would do but then again I would be copying and pasting everything from the website onto here. It outlines steps from downloading package and transferring the .img file onto SD Card. Its as detail as it gets. – Karbon62 Nov 09 '15 at 21:28
-3

Use df to find the device path, in this case /dev/disk2.

$ df -h

Filesystem      Size   Used  Avail Capacity   iused    ifree %iused  Mounted on
/dev/disk1     465Gi  414Gi   51Gi    90% 108573777 13263821   89%   /
devfs          214Ki  214Ki    0Bi   100%       741        0  100%   /dev
map -hosts       0Bi    0Bi    0Bi   100%         0        0  100%   /net
map auto_home    0Bi    0Bi    0Bi   100%         0        0  100%   /home
/dev/disk2s1   3.7Gi  2.3Mi  3.7Gi     1%         0        0  100%   /Volumes/UNTITLED