SpinRite on a Mac using QEMU

Software

More out of interest sake than being under any illusion of practicality, I decided this evening to try running SpinRite in QEMU on my Mac Pro. The verdict: it works, if you have lots of spare time!

Notes before proceeding

I tested this on a Mac Pro, running SpinRite in QEMU on a non-system drive. I would assume if you booted Mac OS X off an external drive you could try this on your machine's system drive as well, but your mileage may vary.

QEMU is easy enough to build yourself, or its available on Homebrew, MacPorts, Fink and pkgsrc.

Finally, this action is allowing software raw access to your drive, so be extremely careful about getting the labels and identifiers right. Backup your stuff. Do at your own risk!

The procedure

  1. Go into Disk Utility, click the drive you want to run SpinRite on, then go to File → Get Info. Under the "disk identifier" heading you should see a string called disk[number]. Make a note of it.

  2. Use Disk Utility to unmount the drive. If it says the drive is busy but you're sure you're not doing anything with it, you can force eject it with its shell sibling:

    % sudo hdiutil eject -force /Volumes/[label]

  3. Temporarily assign yourself ownership of that volume:

    % sudo chown [your username] /dev/disk[number]

  4. Fire up a QEMU session:

    % qemu -hda /dev/disk[X] -cdrom spinrite.iso -boot d

From here on in, its just like SpinRite on a regular machine… although an order of magnitude slower!

Don't forget when you're done to return permissions to root on the drive:

% sudo chown root /dev/disk[number]

Why go to all the trouble?

SpinRite is a preventative hard drive maintenance utility that is run off a bootable FreeDOS image burned either to a CD or run off a floppy disk. Unfortunately, while it boots on Intel Macs, the software requires BIOS level access to drives which EFI obviously fails to provide. As a consequence, the keyboard doesn't work and even if it did, the drives wouldn't be accessible.

One potential workaround is to physically remove internal drives from Macs, install them in a regular PC with a BIOS and perform SpinRite on it. While this works, its terribly clumsy and doesn't lend itself well to performing regular maintenance as Steve Gibson suggests we use it.

This got me thinking whether or not it can be virtualised. Provided the software had raw access to the drive, theoretically one could create a virtual machine, boot off the SpinRite ISO image and have it do its thing. I'd tried it using raw access in VirtualBox before, but it was complicated to configure and ran as slow as molasses.

Turns out, using QEMU to do this on a non-system drive is fairly simple, though just as slow. Oh well, you live and learn!

Author bio and support

Me!

Ruben Schade is a technical writer and infrastructure architect in Sydney, Australia who refers to himself in the third person. Hi!

The site is powered by Hugo, FreeBSD, and OpenZFS on OrionVM, everyone’s favourite bespoke cloud infrastructure provider.

If you found this post helpful or entertaining, you can shout me a coffee or send a comment. Thanks ☺️.