… there actually is a true BSD, struggling to get out!
Warning: This post scores somewhat higher on the geek-factor, than most of my posts. If simply starting the terminal scares the shit out of you, please do not read any further. I of course take absolutely no responsibility, if you should manage to fuck your rig up, because you felt inspired to do something because of this post.
One of the things I really miss on Windows is dd and /dev/random or /dev/zero, which is the superb tool to wiping USB-memory-sticks (actually I once read that the US Department of Defence uses isolated read-only OpenBSD installations with the Yarrow random implementation for secure disc-wiping – this of course has never been admitted in public :)) and not the least, recovering them if they somehow gets a little lost. Unfortinately it won’t restore lost data, but it is never the less an useful tool. Since MacOS X (of course?) doesn’t quite does things the Unix way, it took a little reading to get this working, but when there is a plethora of sources on the internet (I found this article helpful), that’s not much of a problem anyway. So here is how it ended:
Henrik:~ heb$ mount /dev/disk0s2 on / (hfs, local, journaled) devfs on /dev (devfs, local, nobrowse) map -hosts on /net (autofs, nosuid, automounted, nobrowse) map auto_home on /home (autofs, automounted, nobrowse) /dev/disk1 on /Volumes/16G_D33B05 (msdos, local, nodev, nosuid, noowners) Henrik:~ heb$ sudo diskutil unmount /Volumes/16G_D33B05/ Password: Volume 16G_D33B05 on disk1 unmounted Henrik:~ heb$ time dd if=/dev/zero of=/dev/disk1 554873+0 records in 554872+0 records out 284094464 bytes transferred in 10806.315287 secs (26290 bytes/sec) real 180m6.328s user 0m0.779s sys 0m10.301s Henrik:~ heb$ gpt create -f /dev/disk1 Henrik:~ heb$ gpt show /dev/disk1 start size index contents 0 1 PMBR 1 1 Pri GPT header 2 32 Pri GPT table 34 31588285 31588319 32 Sec GPT table 31588351 1 Sec GPT header Henrik:~ heb$ gpt add -t windows /dev/disk1 /dev/disk1s1 added Henrik:~ heb$
At this point a dialog-box will appear, because MacOS X detects the presence of a new device:
This box appears, because MacOS X doesn’t know exactly what to do with this device. It has a couple of suggestions, but we should let it ignore it, and let its inner FreeBSD handle the situation :o)
Henrik:~ heb$ newfs_msdos -v NEW_HEB -F 32 -b 512 /dev/disk1s1 newfs_msdos: warning: /dev/disk1s1 is not a character device 512 bytes per physical sector /dev/disk1s1: 31102279 sectors in 31102279 FAT32 clusters (512 bytes/cluster) bps=512 spc=1 res=32 nft=2 mid=0xf0 spt=32 hds=255 hid=0 bsec=31588285 bspf=242987 rdcl=2 infs=1 bkbs=6 Henrik:~ heb$
And we are done: A securely wiped, formatted and guaranteed virus free USB-memory-stick. Our IT-guy can’t do nothing but love this :)
This may seem like a awful lot of trouble, compared to using the much more userfriendly Disk Utility, that comes packaged with MacOS X these days anyways (which also happens to be a lot faster) but here’s the kickers:
First you get a device, that has been zeroed, which basically brings it back (unless there is some physical defects on it) to the state when it was purchased. Second: The device is never opened by any operating system, and thus can only be polluted if vira and similar, has gotten hold on the filesystem kerneldrivers or the tools used (which no virus to my knowledge has!). It is a completely clean and secure device. For paranoid people in a paranoid business, this is actually an issue :o)
The first three steps of course, is also a way of securing the device before disposal (as opposed to the more brute, but almost as efficient hammer-method ;o)).
This page by the way, has a lot of more examples of what to do with dd.