Fri, March 21, 2008 3:43 PM
Using dd to write floppy disks on Mac OS X
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 like /dev/disk1 and /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:
If you try using the raw device instead, you get a different error:
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 dd correctly:
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.