jump to navigation

Run SpinRite on a Mac July 29, 2010

Posted by Robert Harder in Utility.
Tags: , ,
trackback

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:

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.

Yes, ask him.

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.

Comments»

1. Steve Gibson - September 17, 2010

This is not only a keyboard issue. The INT’s from BIOS are used also to access the disks, so all the methods need to be translated to EFI.

2. Robert Harder - September 17, 2010

Nuts. OK, don’t bother asking him. =) Thanks, Steve, for the expanded explanation.

3. Gene Lee - November 16, 2010

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

Why is this?

4. Robert Harder - November 16, 2010

The first problem is that you need to replace ‘/full/not/relative/path/to/file.vmdk’ with an actual pathname relevant to your computer.

Not sure if there are other problems masked by that one.

-Rob

5. Gene Lee - November 16, 2010

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?”

6. David Fulton - November 16, 2010

Hi Robert,

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?

7. Robert Harder - November 22, 2010

@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.

8. Sharron Clemons - December 21, 2010

@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.

9. chrisNova777 - December 29, 2010

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..
!

10. chrisNova777 - December 29, 2010

i wish there was a program that would be able to use an old machine and process more then one harddrive at a time.. so you can fix and maintain your harddrives..

11. Russ - January 3, 2011

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?)

Thanks!
-russ

12. Robert Harder - January 3, 2011

@Russ Yes, sadly you need a working computer to begin with, or at least a working, bootable external drive. You’d have to have gotten this set up ahead of time.

Here’s hoping Mr Gibson can bring SpinRite to us Mac users sometime…

13. Russ - January 5, 2011

Just an FYI, i got this working, but there were some tweaks.

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.

Hope that helps someone.

14. Laszlo - January 24, 2011

Hi,
thanks for the hack!

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.)

A newer version of VirtualBox break this, or what is wrong?

Thanks for any help!

15. Dan - January 30, 2011

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?

16. Robert Harder - March 11, 2011

@Laszlo About the resource busy thing, this last time I had to unmount the HD from the command line (even though it didn’t show up in the Finder anyway): diskutil unmount /Volumes/Macintosh HD

17. Robert Harder - March 15, 2011

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…

18. Cash Williams - June 22, 2011

Was thinking about running spinrite on my MacBook’s harddrive just for some preventive maintenance.

Couldn’t you just pull the drive and hook it up to a windows machine and run it there?

19. Robert Harder - June 22, 2011

@Cash Yes, but it’s a pain and makes it infeasible to perform regular checkups. Still…the only solution is as you say: pull it.

20. Jens Vogel - January 9, 2012

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.

21. Greg - June 4, 2012

I just got a new AMD mother board and SpinRite sits there with the
“working” at the bottom of the screen.

Linux had problems with EFI firmware but in the 3.0 kernel they have a work around.

Soon SprinRite will have to update to keep up with the current deployment of EFI firmware (BIOS).

Mother board:
ASUS E35M1-I
Integrated AMD Dual-Core Processor E-350 with
AMD Radeon™ HD 6310 Graphics

http://usa.asus.com/Motherboards/AMD_CPU_on_Board/E35M1I/

22. Reza - July 30, 2012

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)

23. http://tinyurl.com/kdseheney55343 - January 9, 2013

“Robert Harder

24. Mai - February 8, 2013

Fine way of describing, and pleasant article to get facts regarding my presentation focus, which i am going to present in school.

25. nunz - March 11, 2013

hi robert

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!

thnx for your helpful info.

26. Upcoming Video Games 2012 - May 13, 2013

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.

27. Diablo 3 Monk Builds Guides - May 15, 2013

Although some people may not like it, video games are here to stay.

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.

28. rapid weight loss kidney failure - October 9, 2014

rapid weight loss kidney failure

Think Harder » Run SpinRite on a Mac

29. if i stay on netflix - October 9, 2014

if i stay on netflix

Think Harder » Run SpinRite on a Mac

30. exercitii pentru abdomen - October 13, 2014

Nice replies in return of thi matter with solid arguments and describing thhe wole thing
concerning that.

31. miami beach luxury car rentals - October 14, 2014

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.

32. cure herpes outbreak - October 14, 2014

cure herpes outbreak

Think Harder » Run SpinRite on a Mac

33. Antonio - November 21, 2014

Hello there, just became aware of your blog through Google, and found that
it’s truly informative. I’m gonna watch out for brussels.

I will appreciate if you continue this in future.
Many people will be benefited from your writing.
Cheers!

34. Roboknight - April 3, 2016

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.

35. Carey - September 21, 2016

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.

36. Robert Harder - September 21, 2016

@Carey
I haven’t tried this in years. In “theory” it should work, but it’s hard to get up and running. I guess a Carbon Copy Clone HD would do it.

Yeah, I think SpinRite 6.1 will ship same time as Gnu/Hurd (https://xkcd.com/1508/).


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: