6

(txs all for your help and suggestions, but suspending this for now while I track down my formatting errors on that SD. If I can't get that to work, little reason to expect dd to work, even if other people have encountered similar issues doing this on osx).

I'm trying, as root, to write to micro SD to load up a Raspberry Pi's Linux:

W$dd bs=1m if=/Users/jluc/Downloads/2017-01-11-raspbian-jessie.img of=/dev/disk2

This is supremely slow, it's been running for 8-9 hours and hasn't written much when I kill -9 it.

301989888 bytes transferred in 23103.442503 secs (13071 bytes/sec)

Now, in such write ups as Solution: dd too slow on Mac OS X, he advises to use /dev/rdisk, because it's treated differently.

But every time I've used /rdiskN instead of /diskN, I get:

dd: /dev/rdisk2: Input/output error

This is on Sierra, but it worked on Yosemite, if I recall correctly.

INSTALLING OPERATING SYSTEM IMAGES ON MAC OS mentions the possibility that /rdisk won't work and advises you to use /disk instead.

What gives? Is this something new with Sierra as opposed to earlier versions?

update: tried suggestion as per @oa and still getting the same error.

Searching `` got me this: https://stackoverflow.com/questions/37232109/how-to-fix-bad-dd-img-write-to-sdcard. Now, that post is about an img file that is too big for the SD. I have a 4.1Gb img, and this is a 32Gb file, so that wouldn't apply.

But... what I've noticed is that diskutil list has a number of things for that disk.

jluc@node_modules$ diskutil list /dev/disk2
/dev/disk2 (external, physical):
#:                       TYPE NAME                    SIZE         IDENTIFIER
 0:     FDisk_partition_scheme                        *32.1 GB    disk2
 1:             Windows_FAT_32 boot                    66.1 MB    disk2s1
 2:                      Linux                         32.0 GB    disk2s2

See how the first partition, the FAT32 boot shows @ 66.MB?

Looking some more:

jluc@node_modules$ df -h | egrep "disk2|Filesystem"
Filesystem                          Size   Used  Avail Capacity iused      ifree %iused  Mounted on
 /dev/disk2s1                        63Mi   21Mi   42Mi    33%     512          0  100%   /Volumes/boot

So, wondering if it's not that /dev/disk2 is not interpreted as being only 60 MB because of the boot and I am therefore getting a capacity error. Will try to repartition it first.

  • What is the write speed rating of your micro SD? Some are severely constrained no matter what system or block size you choose. – bmike Jan 28 '17 at 19:43
  • Class 10. The funny thing is... I used this exact same SD before, but using El Capitan or Yosemite (not sure what laptop I used) as the mac OS. Ah... one additional bit of info. The reason I have to reimage is that I (dumb me), did a rm -rf pi3 while I had mounted the pi3 using sshfs. So, basically, I rm -f / on the pi3 while running. Noticing that, I unplugged the pi3 to stop the damage. – JL Peyret Jan 28 '17 at 19:51
  • It cannot be "interpreted as being only 60 MB" . dd has no knowledge of the disk structure, and doesn't care; it just copies raw blocks. Indeed it makes no difference whether the card is formatted or not. – Milliways Jan 28 '17 at 22:42
  • @Milliways. Yeah, that's would I have expected as well. But like I mentioned further down, I am getting formatting errors so I might have nuked the SD. How? I am sure an rm -rf / is mighty destructive, esp one interrupted midway by unplugging. but hardware-destructive??? I will install Linux on my laptop and see if I can force it to reformat the whole SD somehow. if that works, I'll go back to osx and dd - just because I want to get this working on osx. If not, new SD. – JL Peyret Jan 28 '17 at 22:49
  • @JLPeyret You can try formatting, but this also writes raw blocks, so is unlikely to make any difference. – Milliways Jan 28 '17 at 22:54
6

I installed the same image last night on a RPi3.

You need to unmount the disk first. Then you can write to the disk using sudo.

diskutil unmountDisk /dev/rdisk2
sudo dd bs=1m if=~/Downloads/your_image.img of=/dev/rdisk2
diskutil unmountDisk /dev/disk2

I'm on macOS Sierra, too.

  • Tried exactly that. Same issue. I know there's nothing wrong with your command. But something is glitching either on the SD, the adapter or the Mac. – JL Peyret Jan 28 '17 at 19:47
  • What error exactly do you get with the command above? The same 'dd: /dev/rdisk2: Input/output error'? – oa- Jan 28 '17 at 20:57
  • actually, I am getting formatting errors on the disk itself. so i might have a corrupt SD somehow. if that turns out to be the case, i'll remove or update this question as needed. – JL Peyret Jan 28 '17 at 22:14
  • It most likely won't even run if still mounted. The reason this answer is correct is that it uses rdisk2 instead of disk2 - rdisk2 is the raw version as per: daoyuan.li/solution-dd-too-slow-on-mac-os-x – Willem van Ketwich Feb 24 '18 at 3:18
2

It works for me! You may be interested the the script I use, which can copy images and compressed backups.

It includes checks to prevent you inadvertently overwriting something else and automatically unmounts the SD Card.

You need to customise the script with disk and image.

#!/bin/bash
# script to restore backup to Pi SD card
# 2016-10-24

DSK='disk3'

# Image name (no ext)
IMG='ubuntu-standard-16.04-server-armhf-raspberry-pi'

# Check for sensible disk
export PTYPE=$(diskutil list  /dev/$DSK | awk '/GUID_partition_scheme/ {print $2}; /Apple/ {print $2}; /Windows_NTFS/ {print $2}' )
if [ "$PTYPE" ]; then
    echo "Disk not a SD Card - Contains "$PTYPE
    exit
elif [ ! /dev/$DSK ]; then
    echo "/dev/$DSK not found"
    exit
fi

echo Ensure SD partitions are unmounted!
diskutil unmountDisk /dev/$DSK

# Check if image exists - else try to uncompress
if [ -s $IMG.img ]; then
echo $IMG.img exists
elif [ -s $IMG.img.gz ]; then
echo Uncompressing $IMG.img.gz
echo Ctl+T to show progress!
time  gunzip -k $IMG.img.gz
fi

echo please wait - This takes some time
echo Ctl+T to show progress!
time sudo dd if=$IMG.img of=/dev/r$DSK bs=1m

exit
  • What speeds do you get with this script and how does it compare with the theoretical speed of the SD media in question? – bmike Jan 28 '17 at 19:42
  • @bmike It takes less than 15 minutes to copy an 8GB image. I haven't actually timed it for a while. This is about 32MB/sec. There is nothing special in the script, just normal dd. When I did not use raw it could take many hours. – Milliways Jan 28 '17 at 22:37
  • Thanks! That's on par with my experiences - 15 to 20 minutes to write systems in that range. Being specific will help people know they are seeing what others are. – bmike Jan 28 '17 at 22:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .