How It Is Done

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.

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:

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.

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.

Hi, when I get to the part where I have to create a virtual disk image pointed to the raw device, it says:Oracle VM VirtualBox Command Line Management Interface Version 3.2.10
(C) 2005-2010 Oracle Corporation
All rights reserved.

ERROR: VMDK: could not create new file ‘/full/not/relative/path/to/file.vmdk’
Error code VERR_FILE_NOT_FOUND at /Users/vbox/tinderbox/3.2-mac-rel/src/VBox/Devices/Storage/VmdkHDDCore.cpp(3491) in function int vmdkCreateRawImage(VMDKIMAGE*, VBOXHDDRAW*, uint64_t)
Error while creating the raw disk VMDK: VERR_FILE_NOT_FOUND
The raw disk vmdk file was not created

So I put a pathname relevant to the disk I want analyzed by spinrite? i.e. ‘MAC\ OSX/Users/jaelee/Downloads/file.vmdk’? Am I pointing it to an already existing file or creating a new one? The new one being “file.vmdk?”

I am trying to repair / recover / backup a 500Gb disk in a 2007 Intel iMac which has gone on the fritz. The iMac is running OS X 10.6x. I also have a MacBook Pro (MBP) and I was wondering if you have considered the following:

Install VirtualBox on the MBP and loading the SpinRite software in the VM, as you describe, and then connect the iMac (target) to the MBP (host) using Firewire Target mode. I connected my MBP to the iMac in target mode to run DiskWarrior (DW), but DW failed in it’s repair process.

I am not sure how to go about mounting the iMac drive in the VM on my MBP, but I am thinking it might work. What are your thoughts?

@GeneLee You’re pointing to a new file that the VBoxManage command is creating. @DavidFulton Not sure if connecting via FireWire will work since SpinRite doesn’t support FireWire. Not sure if VirtualBox would emulate a layer there or not for you.

spinrite is something u want to run on an older machien and leave it on for a week to refurbish a hard drive.. not something ud run on your shiny new imac or mac pro.. you wanna run this on your beat up old clunker of a machine set up on the floor in your basement or something..
!

Thanks for the info. I couldn’t get spinrite to work on my mac either. The problem is that my mac is dead and won’t boot. I’m assuming from your post here, that the machine you install virtualbox and spinrite on need to be working in the first place, correct? (ie. there’s no way to get spinrite working on a mac that won’t boot?)

1. On the command to make the virtual disk for virtualbox, I got an error saying “-register” was an unrecognized option, i took it out, it’s working so far without that.

2. The OS would consistently try to mount the internal HD, and this gave errors in virtualbox, and via the command line when trying to use the hard drive. So i would have to go to disk utility and unmount the drive. Then virtualbox could access it.

But sadly, I could not get VirtualBox working. As Russ said, the -register parameter was invalid. But even without that, I got a VERR_RESOURCE_BUSY error. I could not unmount the internal drive though. (I cannot think of what is using it.)

I’d like to run spinrite on my families laptops for preventative reasons. I’m more then happy to purchase spinrite after I figure out how to do this. Is the enclosure you bought a USB enclosure, and will spinrite run from the USB enclosure on the laptops internal disc?

You know, I’m starting to wonder if running Spinrite in VirtualBox really does anything. From some suspicious warnings I’ve received in Spinrite, the lack of SMART access, and the lack of any errors at all found, I’m wondering if VirtualBox “raw disk access” really is just providing access to /dev/disk0 as a block device, but still intercepting all IDE-related commands.

Who would know the answer to this? Maybe on the VirtualBox forums…I’m off to ask…

hi. some time ago i posted my aproach, how i ran spinrite on my internal mac drive using a windows 98 boot disk. i’ll share it here. hope it helps:

Hi there. Maybe someone is interested in how to run Spinrite booting from a mac. I managed to boot it and scan my internal drive. It went flawless but there are some restrictions.
the problem when trying to boot spinrite from a cd or usb drive is, that there is no keyboard access after starting the prog. there are two different reasons for that. at first you have to get hold of a boot image that provides you with ms-dos command line. i used win98 boot image and booted this from cd. there are loads of errors concernig ram drive stuff and himem.sys failing to load, but that’s unimportant. the best thing is to press shift+f5 on the boot menu, skipping the whole mess. you’ll notice that your keyboard layout is the standard u.s. – it’s really important not to execute the keyb command to switch to your countrys codepage, this is what kills the keyboard access in the first place. after establishing command line access make sure you attached a usb flash drive with the spinrite.exe on it before booting up. if done properly you can access the usb drive juct by typing “c:” you may ask, why not burn the spinrite executable right on the cd and access it from there. this has to do with the ability to write log files. log files are most important, because you won’t be able to run spinrite just like that. the program has it’s own routine to address your computers hardware. it overrides the bios. that’s the reason, why you still will not have acces to your macs keyboard after launching spinrite. the solution is to use spinrite’s command line switches and turn it into auto mode. this will make it work without any user input during the process. at first type “spinrite list” this will give you an overview of all the computers partitions. your mac drive and all its partitions are there. i found mine under “drive 0” this is what you need to specify. for example, doing a scan on drive 0 using level 4 you have to type “spinrite auto drive 0 level 4” very easy.
attention!: after starting the process there is no way to stop until the task is finished, since you have no keyboard access within the program you cannot abort the process. the only way to get out of spinrite is to turn of your mac. which may result in data loss, if done during a scan operation. so be careful when selecting the drive and level. be sure you make the right selection, otherwise you have to wait until the program finished the task and start over again. well, this sounds complicated, but in fact it’s really easy and it saved me loads of trouble, since there is no need to remove the mac drive and attach it to a pc to scan it. it worked perfect. after the scan is completed restart and look for the spinrite.log on your usb device. there is all the information about found errors and stuff. have a nice day.

I agree with you Greg for the high price i think there should be a proper solution available. I was considering to buy it for my mac in the first place so i will wait until there is a proper version (bootable USB for Mac’s)

did you ascertain whether running spinrite in virtual box actually does anything? About to try your method on a mac mini (easier than digging the disks out of the case) unless of course it doesn’t work!

Having gone through Beta testing for well over a year,
the game appears to have avoided most of the common problems that have
plagued many MMO’s upon launch, such as overburdened servers, long wait times, unbalanced game play or technical glitches. Again, please check out the GVGINU website, link above. Find out if this developer is making the kinds of games you want to make.

Online, they are available through individual resellers and auction’s sites, both as single titles and in collections. * If you do not yet want to join the millions of other guys and girls working tedious 9 to 5 jobs, Monday to Friday then the lifestyle of a video game tester might be the answer.

The flower gardening is the hobby of growing flower gardens for decorative purposes.

Special tools and techniques are needed for Bonzai gardening and
those people who enjoy this type of gardening really enjoy the challenge
of nursing these trees into the shape and style they want
to create. Gardening on a regular basis is a highly-physical activity that is believed to tone your muscles,
help you lose weight and also reduce your risk for certain health problems including heart disease
and obesity.

Thanks for the post. I am hoping to run this on a 750GB disk. Two things I’d like to point out:
1) take advantage of sudo vifs — What will this do? Adding a line such as the following
UUID=8F6DC28D-D642-3A08-B0FC-3FC86674B205 none hfs rw,noauto
(use Disk Utility to get your disks UUID)
will make sure that OS X won’t keep “grabbing” the disk, thereby causing SpinRite to crash.
2) Make sure that you turn off all of the sleep functionality… especially disks sleeping… This will kill your SpinRite process also as OS X will happily shut off access to the disk without VirtualBox knowing. Also, using “pmset noidle” can help here.

Finally, as a bonus: SpinRite doesn’t have access to the S.M.A.R.T. controls through the VM. So certain ultra-low level features may not function, but SpinRite will continue to happily work doing the basics, which may be all you need.

I’ve got a flaky drive in a late 2012 iMac (27″) – it’s a 1TB Fusion drive. I’m able to boot to an admin account, but my main account has vanished from the list of accounts (the files appear to still be there under /Users, though). Something is corrupt.

These instructions are OLD. Do they still work, as-is?? Has anyone come up with a better way? I wish Steve G would release SR 6.1.

I’m trying to create a bootable drive using CCC and an external drive. Taking forever to copy, probably due to drive errors. But I’m really leery of this approach being so old.

This woked, for me on a 2012 (5 year old) macbook pro. I used a trial version of Carbon Copy Clone to create a bootable external harrdrive (with VirtualBox and SpinRite.iso). I booted from that, launched VirtualBox, set the hard drive, and configured the VM to boot from CD ROM, mounted with SpinRite. Issues:
1) I had to unmount the main drive of my macbook between almost every instruction, it kept getting mounted!
2) I had to change the permissions for disk0 and all of it’s partitions (disk0s1, disk0s1…). I don’t pretend to understand this, but that’s what it took, otherwise only the base boot partition could be read by SpinRite.
3) I turned off drive sleep like @Roboknight suggested.

Finally, Gibson has said in Security Now that he is done with Squirrel and is working on the next SpinRite. So *hopefully* this will be easier in the near future.

Seriously, all this for wanting to SpinRite a drive from within Mac hardware? I’d have pulled it out in less than 4 minutes and put it in an old Pentium machine with SATA connectivity and plugged it right back in afterwards. It’s not that one would SpinRite a Mac spec disk every year, even. I have an example use case where I’ve just done the exact thing for a 2008 iMac boot-drive that was never scanned by SpinRite for 10(!) years, took me 4 minutes to have the scan by SpinRite started on an old PC I have specifically for that and other DOS purposes.