Run SpinRite on a Mac
Yes, I succeeded in running SpinRite 6 on an Intel Mac!
Here’s a screenshot:
Here’s a video:
You might notice that it’s horribly slow: about 1MB/sec if there are no errors. This makes it pretty much useless unfortunately. I’m just not that patient.
How It Is Done
Here are the key components for making this work:
- Booting from another hard drive.
- Installing VirtualBox.
- Setting up VirtualBox to point to your raw disk drive.
Until recently I had no way to do the raw disk access in a virtualization tool. VM Fusion v2 didn’t support it (don’t know about the current version). Sun (now Oracle) VirtualBox didn’t support it, but starting with v1.4, it does.
Step 1: Boot from another hard drive
This isn’t a small step. Get an external hard drive, a cheap one will do. If you have a spare, bare hard drive lying around, get an enclosure for it (I got some 2.5″ laptop HD enclosures for $7 each, shipped, on eBay).
You’ll either have to install Mac OS X on the hard drive directly or use something like Carbon Copy Cloner to copy your installation over. There are instructions for this sort of thing around the net.
Restart your Mac and hold down the Option key. That will present you with a choice of bootable volumes (like grub, for the geeks out there). Select your external drive.
Step 2: Install VirtualBox
VirtualBox is a free tool from Oracle for running other operating systems in a window inside your computer. If you don’t know about it yet, you might be pleased to learn you can run Windows applications right there on your Mac without having to reboot using Boot Camp.
Download and install VirtualBox.
Step 3: Set up raw disk access
The tricky thing here is that instead of having VirtualBox use a file on your hard drive to represent an entire guest operating system’s hard drive, you actually want it to have raw access to a real drive on your computer (your internal drive, presumably). Chapter 9 of the user’s manual describes how to do this but leaves one part out. Perhaps we can get that updated.
First we have to know what to call our raw internal drive. From the Terminal enter this command:
$ diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *1.0 TB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 999.9 GB disk0s2 ... and so on ...
That will list all drives attached to your computer. You’ll have to look at the sizes probably to determine which one is the drive you’re interested in. It’s probably /dev/disk0.
A quick look at this device reveals that it is owned by root, not you. In the Terminal:
$ ls -l /dev/disk0 brw-r----- 1 root operator 14, 0 Jul 17 18:11 /dev/disk0
You’ll have to fix this. I can’t say that what we’re about to do is normally a good idea, but presumably we’re only doing this on our non-production, SpinRite-dedicated, external boot drive. We need to make the device owned by you. In Terminal, and replacing USERNAME with your user account’s name:
$ sudo chown USERNAME /dev/disk0 Password:
You’ll have to enter your account password.
Now finally we can create a VirtualBox “disk image” that actually points to the raw device. All of the following lines should be on one line; I’ve broken them up for easier reading.
$ VBoxManage internalcommands createrawvmdk -filename /full/not/relative/path/to/file.vmdk -rawdisk /dev/disk0 -register
Step 4: Create a VirtualBox virtual machine
Now in VirtualBox you’ll go through the normal process of creating a virtual machine, but instead of creating a new virtual hard drive, you’ll select “Existing VMDK” and point to the VMDK file you just created.
You’ll get a SpinRite ISO image, which presumably you made on a Windows machine when you downloaded SpinRite, and mount that in the virtual machine as well, and when you start the virtual machine, Voila! You have SpinRite running and accessing your Mac HD. Slowly.
Why Is This Necessary?
This is painful. Why can’t you just pop in the SpinRite CD and boot your Mac? You can. Your Mac will boot the SpinRite CD and take you to the title screen where you’ll sit. And sit. And sit. Forever. Because although the CD boots, the software cannot read your keyboard inputs. Ack!
Who’s fault is this? Well, that’s not really the right question. Here is a slightly rough, slightly inaccurate, but generally helpful description of the problem. SpinRite works at a very low level without any operating system support to speak of (except a bit from FreeDOS). To read your keyboard inputs, SpinRite has to monitor actual hardware interrupts, and although these have been the same on PC BIOSes for years, Macs use the newer EFI firmware, and the mappings are different. Thus no keyboard. See update below.
Judging from his comments on the Security Now podcast, SpinRite creator Steve Gibson has no plans to update SpinRite, and indeed updating it to account for a new BIOS is no small task.
We could perhaps ask him on his feedback page to consider making a slight update to SpinRite which would create a SpinRite CD that automatically selected Drive Maintenance on all attached drives and began working without any user input. That way regular maintenance runs that generally don’t require any intervention could run, and if there was a more serious problem, well, then we’re simply back to square one.
Update: Mr. Gibson provided some feedback in the comments indicating that the issue is deeper than just keyboard interrupts, so having a run-automatically version wouldn’t help us. Rats.