Writing directly to a USB disk in OS X

Disclaimer : This procedure erases all data on the target volume so use the volume relevant to your setup, eg. that of your USB disk. I and my associates at meinit do not take responsibility if you overwrite the wrong volume and lose your music, movies, thesis, world peace plan etc. And there might be an easier way to do this, I await comments.

Today I would like to share a short note on how to write a raw disk image to a USB memory stick in OS X. The raw disk image can, for example, be a bootable filesystem image for a OS installer. In my case Fedora 8's "diskboot.img".

The main problem is that I was used to Linux's way of device naming but under OS X if you wish to write directly to a disk you need to use the "raw" version of the device. For example /dev/disk1 has raw device /dev/rdisk1.

The other issue I encountered is that when I insert the USB memory stick then /dev/disk1 exists but is mounted so I cannot write to it directly. If I eject the disk then the device node also disappears and I can't write to it. So we need to use the "Disk Utility" to properly unmount the volume, this utility is contained in Applications -> Utilities. Start this up, making sure your USB stick is plugged in. Once started you will see a list of storage devices, much like below :

screenshot of Disk Utility

Here you can see the USB storage quite easily. Highlight the partition within your storage media and click "eject". Now the device node still exists and you can use "dd" to write to the disk directly, /dev/disk1 in my case. My command to write to the disk was :

$ sudo dd if=./diskboot.img of=/dev/disk1 bs=8k

Adjust as required. Good luck and happy new year! :-)