This How To article is in two parts:
- Part 1 - Introduction, creating external boot drive, installing QEMU and it's prerequisites
- Part 2 - Setting up your virtual boot drive, copying SpinRite to it, and running SpinRite via QEMU against your Mac drives (this article)
Part 2 of 2
E. Setting up the QEMU Boot Drive
- Create a folder to store your virtual disk images
- Open your Home folder
- Create a new folder called "QEMU" at this level (same level as Documents and Downloads folders)
- Download the base drive "srdos.qcow2" from my OneDrive, and move it to the QEMU folder
- Test that qemu is working:
- Open a Terminal window
- Change to the QEMU directory:
cd ~/QEMU
- Now you'll run qemu, attaching the base drive
sudo qemu-system-x86_64 -drive file=srdos.qcow2
- A window should open and settle at a DOS C:\> prompt
- There is a spinrite.exe file on the drive, but it's an old pre-release version that will not do anything
- Type shutdown at the C prompt and the DOS window should close
- Congratulations, you've got QEMU running!!!!
I bought my own copy of SpinRite, how do I get it on the C Drive?
You'll download the .zip file from GRC with your copy of SpinRite on a drive .img file. Then you'll use QEMU to mount both the base C drive as well as the .img file (as drive D), then copy SpinRite onto the C drive.- Go to GRC.com and download your personal copy of SpinRite
- Go through the Upgrade or Purchase process. You'll be presented with a web page with two links. You want to click on the link that leads to a .ZIP file, "For users without any access to Windows"
- Your Mac may automatically unzip the file, which contains one file called spinrite.img
- Move that file to the QEMU directory you created previously
- You now have two virtual drive files in that directory, one called srdos.qcow2 and one called spinrite.img
- Now you'll run a QEMU session to copy the spinrite executable
- From the Terminal window,
cd ~/QEMU
- Type the following command (note the backslash as the line continuation character):
sudo qemu-system-x86_64 \
-M pc \
-rtc base=localtime,clock=host \
-hda srdos.qcow2 \
-hdb spinrite.img \
-boot c
- This will open a FreeDOS session booted from the srdos.qcow2 file as the C drive, with the spinrite.img file as the D drive
- At the C prompt, type:
C:\>copy d:spinrite.exe c:\
- You'll be asked if you want to overwrite spinrite.exe on the C drive; Yes, you do
- You can start spinrite from the C prompt, it should show your licensed copy
- Now you can shutdown from the C prompt
- Next steps: determining the Unix drive names for the drives you want spirit to operate on, dismounting them from MacOS, and then starting QEMU
- From the Terminal window,
Determining Unix drive names
- You’ll need the device names of the physical drives on the system
- Open a Terminal session
- Run the command:
diskutil list
- This will show all the disks on the system; look for the devices noted as (internal, physical), AS WELL AS any "synthesized" drives which contain partitions from the internal disks
- Note the name(s) of the disk(s), AND the partitions which are under the main drive device for both physical and synthesized disks. You’ll unmount the partitions the drives to prevent concurrent access, then map the disk name(s) to virtual drive(s) using the QEMU command line.
- Run the command:
df -h
- This will show you the mounted partitions, and you must unmount them.
- EXAMPLE:
- You have a physical disk0, and a synthesized disk1. The output of df -h shows that
/dev/disk1s4
and/dev/disk1s1
are mounted. You would then run two unmount commands:diskutil unmount /dev/disk1s1
diskutil unmount /dev/disk1s4
- You should then unmount the physical and synthesized disks
diskutil unmountDisk /dev/disk1
diskutil unmountDisk /dev/disk0
- You have a physical disk0, and a synthesized disk1. The output of df -h shows that
- EXAMPLE:
- Alternatively, for unmounting after you've determined the device names, you can use the Mac Disk Utility
- Open the Disk Utility
- Go to the View Menu, and select "All Devices"
- For any disk you intend to target, if it's in APFS format, click on the highest level container on the left, and click "Unmount" from the toolbar
- For example, on my system:
- My external boot drive was /dev/disk2, showing synthesized drive of /dev/disk3
- My internal drive, which will be the SpinRite target, was physically /dev/disk0 with synthesized drive of /dev/disk1
- I used Disk Utility to unmount the container from the physical disk, which unmounted the synthesized drives
Running QEMU
- Once you've determined your target drive(s), mount them in the order that you'd like the emulated PC to see them. Let's say I only want to have SpinRite look at my internal drive, /dev/disk0. I'd use the following command:
sudo qemu-system-x86_64 \
-M pc \
-rtc base=localtime,clock=host \
-drive file=srdos.qcow2,media=disk,cache=none,index=0 \
-drive file=/dev/disk0,format=raw,media=disk,cache=none,index=1 \
-boot c
- Explanation:
- -M pc: sets the device type to what QEMU currently considers its baseline PC, which has:
- PS/2 mouse and keyboard
2 PCI IDE interfaces with hard disk and CD-ROM support
Floppy disk
- PS/2 mouse and keyboard
- -rtc sets the realtime clock within the emulated system to use the date and time from the host
- -drive file=srdos.qcow2,media=disk,cache=none,index=0 turns off write caching, and sets this drive as the 1st (index 0) on the IDE adapter. As this would be the C drive, you'll note the reference below to boot from the C drive
- -drive file=/dev/disk0,format=raw,media=disk,cache=none,index=1 mounts the target drive as the D drive
- -boot c says to boot from the C drive. Not really necessary
- -M pc: sets the device type to what QEMU currently considers its baseline PC, which has:
- After SpinRite runs, you can drop back to the C drive in the emulator and type shutdown
- If you wish to run this again on the same drive, you'll have to unmount the drive again using the command line or the Mac Disk Utility
And that's it!!
Big Caveat!!!
I have barely tested this!! All seems to work but please, please, please backup your data, and potentially be ready to completely wipe the machine and reinstall MacOS from scratch
Last edited: