Jump to content

Recommended Posts

Posted (edited)

Unix/MacOS tools to write images to SD cards:

  • the usual dd
  • dc3dd & dcfldd are improved forks of dd

dcfldd has also a nice "on the fly" hashing mechanism (so to avoid complex md5 or sha*) but it has many options so it is a bit complicated to use (see).

 

I am often using dc3dd on Debian like systems because you can see realtime the % of the processing and you may leave dc3dd to manage buffering & doing the hashing on the fly:

sudo apt-get install dc3dd

sudo dc3dd if=Image.bin of=/dev/sdX

sudo dc3dd verb=on hash=md5 if=Image.bin of=/dev/sdX hof=sdX_output.md5

Prior to dc3dd, I was using "pv" (but "pv" has some delayed display because it is linked to the piped "dd")

pv -baret Image.bin | sudo dd of=/dev/sdX bs=10M

also make sure all the buffers are written to the SD card

sudo sync
Edited by wildcat_paris
added pv from TK
Posted

You can have progress indication with standard dd also:

 

dd if=Image.bin of=/dev/sdx

 

in another virtual terminal:

 

ps a --> lookup the pid of dd process

 

kill -SIGUSR1 <pid>

 

will show progress under the original dd command.

 

ok. this is just for freaks....

Posted

Since there exists a second operating system besides Linux that people use on their desktops here some notes regarding OS X:

 

The aforementioned tools can be easily installed using homebrew, eg. dc3dd (brew install dc3dd):

macbookpro-tk:~ tk$ brew info dc3dd
dc3dd: stable 7.1.614 (bottled)
Patched GNU dd that is intended for forensic acquisition of data
https://sourceforge.net/projects/dc3dd/
Not installed
From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/dc3dd.rb

And to get progress notification pv is also always worth a look: https://technobliss.wordpress.com/2013/01/19/progress-while-copying-an-img-file-tofrom-an-sd-card-with-osxlinux/

 

On OS X the Linux/Unix tools to deal with devices should be avoided, instead diskutil used and raw devices accessed as already outlined in our user documentation: https://github.com/igorpecovnik/lib/blob/master/documentation/user-faq.md#how-to-prepare-sd-card (of course f3 to check SD card prior to useage is available on OS X too through homebrew)

Posted

I prefere ddrescue, because "It uses a similar technique as dd and copies block by block, but has an intelligent algorithm to recover failed data." (see Gentoo wiki). Not a bad idea, if we use SD cards as the boot/root medium.

 

And of course, some write progress and statistics :D

 

And if you have the zsh installed, you can even write the compressed image on the fly to the SD card (maybe it does work with bash too):

ddrescue --force =(unzip -p  /imagepath/image.img.zip) /dev/mmcblk0 (for internal card readers or use the common /dev/sdx device)
Posted

I prefere ddrescue, because "It uses a similar technique as dd and copies block by block, but has an intelligent algorithm to recover failed data." (see Gentoo wiki). Not a bad idea, if we use SD cards as the boot/root medium.

 

Since this thread here is about writing OS images to SD card recommending ddrescue is a really bad idea (in the opposite direction to try to recover from an SD card that starts to show failures if you forgot to make backups then ddrescue is great)

 

Really: Trying to use broken SD cards is a bad idea since you waste so much time since all the symptoms you run into later feel like 'broken software' but instead it's just broken hardware. No operating system can run reliably on broken installation media. There is no reason to use crappy SD cards at all since good cards from the 4 recommended vendors aren't that expensive any more.

Posted

Most linux distro's come with Disks (gnome-disk-utility) which can restore images to disks, create images from a disk, etc.

I started preferring this GUI method after I f*cked up a HDD by making a typo in a DD command (accidentally writing the SD-card image to a HDD).

Posted

Since this thread here is about writing OS images to SD card recommending ddrescue is a really bad idea

 

Sorry, you misread me and so I disagree here. You are right, for writing back the image from a "defect" SD card this tool is nearly perfect (that's why I hinted it).

 

And for the mentioned topic: For writing the image to the SD card, you can use this tool too, but this doesn't mean, you can use bad SD cards as target, because ddrescue is trying to rescue the good parts first in case of read errors, not write errors! So it doesn't allow you to write to a broken SD card, it simple stops with error message. So no difference to dd (besides progress bar and statics) and dc3dd.

 

 

I started preferring this GUI method after I f*cked up a HDD by making a typo in a DD command (accidentally writing the SD-card image to a HDD).

 

S.. happens ;), my sorry to you. So you can use the Suse Studio Imagewriter (available on most distros, not only on OpenSuse, no KDE or GNOME needed, runs "standalone" everywhere), exactly what you need, writes images only to USB drives, so no fear to destroy your harddrive.

 

PS: Because most images are compressed (gzip, tar etc.), I prefer the CLI on-the-fly command as already written down.

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines