At work I had the need to write a bootloader directly to a floppy disk. In-house we use
dd on Linux to do this, but it was giving me trouble on Mac OS X. I finally figured it out. Here are the instructions I wrote up:
These steps work on Mac OS X 10.5.2. They probably work on earlier versions, too, but I haven't tried it. This works with a TEAC FD-05PUW USB floppy drive that I picked up at Fry's (sometime in 2008-02).
When you plug in the USB floppy and insert a disk, the Finder will mount it on the desktop (if it's formatted) and create a couple of entries in
/dev/rdisk1 (the actual numbers corresponding to the drive will depend on how many other drives are attached. Be sure you're working with the right one!)
You would then be tempted to execute something like the following. Unfortunately, you'll get an error:
dd: /dev/disk1: Resource busy
If you try using the raw device instead, you get a different error:
dd: /dev/rdisk1: Invalid argument
382+1 records in
382+0 records out
195584 bytes transferred in 41.107951 secs (4758 bytes/sec)
In this case, the file is actually 195936 bytes in length. I'm not sure why it seems to write some of the bytes (I'm not sure it actually even wrote that many).
Using the buffered device (
/dev/disk1 is correct, but it's busy because it's mounted by the Finder. If you simply unmount it via the Finder, then all the entries in
/dev for the device go away, and you're unable to tell
dd what to do. The solution is to unmount the disk using
diskutil unmount, which leaves the
/dev/disk1 entry in place, and then you can use
$ sudo dd if=redboot-pc/install/bin/redboot.bin of=/dev/disk1
382+1 records in
382+1 records out
195936 bytes transferred in 13.345421 secs (14682 bytes/sec)
After that, I think it's safe to just unplug the USB drive, but I'd feel better if I knew how to completely unmount the device before doing so. In any case, the OS didn't complain like it would if a volume were mounted and online.