tinyapps.org / blog

Securely wiping floppy disks under OS X in Terminal #

Faced with several dozen floppy disks that needed wiping, Disk Utility.app was looking a bit cumbersome: Disk Utility > click floppy drive > Erase > Security Options... > Zero Out Data > OK > Erase... > Erase

I decided to give sudo dd if=/dev/zero of=/dev/fd0 a go:
dd: /dev/fd0: Operation not supported.

Ah! Perhaps OS X does not use fd0:
$ ls /dev/fd0
ls: /dev/fd0: No such file or directory

In that case, let's have a look at what we've got:
$ diskutil list
  #:                       TYPE NAME                    SIZE       IDENTIFIER
  0:      GUID_partition_scheme                        *111.8 Gi   disk0
  1:                        EFI                         200.0 Mi   disk0s1
  2:                  Apple_HFS MacBook HD              111.5 Gi   disk0s2
  #:                       TYPE NAME                    SIZE       IDENTIFIER
  0:                            TEST                   *1.4 Mi     disk1
OK, how about:
$ sudo dd if=/dev/zero of=/dev/disk1
dd: /dev/disk1: Resource busy
What if we unmount the floppy from the Finder and then try the same command?
$ sudo dd if=/dev/zero of=/dev/disk1
dd: /dev/disk1: Operation not supported
A quick search turned up the answer - unmount from within diskutil, not the Finder:
$ diskutil unmount /dev/disk1
Volume TEST on disk1 unmounted
$ sudo dd if=/dev/zero of=/dev/disk1
dd: /dev/disk1: end of device
2881+0 records in
2880+0 records out
1474560 bytes transferred in 110.617912 secs (13330 bytes/sec)
That worked beautifully, if slowly: it took almost two minutes to wipe a single floppy disk (fiddling with the block size seemed to help, but I was not inclined to spend much time investigating further see update below). Macworld and the diskutil manpage turned up a much faster method that had the additional benefit of not requiring root privileges:
$ diskutil secureErase 0 /dev/disk1
Started erase on disk1 TEST
Finished erase on disk1 TEST
This single-pass zero-fill erase took less than 30 seconds to complete. Wiping the floppies was now a breeze:
$ diskutil unmount /dev/disk1 && diskutil secureErase 0 /dev/disk1
UPDATE: Rather than using /dev/disk1 (which is the block device, AKA buffered device or cooked device) I should've been using /dev/rdisk1 (the raw device). This made the dd process slightly faster than even diskutil when using block sizes of 1440k and 360k. Connected raw devices can be listed by issuing the ls /dev/rdisk? command. See Block device versus raw device performance for more information.
For those who doubt the efficacy of zeroing a disk, see:

/mac | Oct 10, 2009

Subscribe or visit the archives