How To: Run SpinRite on an Apple Silicon Mac (Part 2 of 2)

  • Be sure to checkout “Tips & Tricks”
    Dear Guest Visitor → Once you register and log-in please checkout the “Tips & Tricks” page for some very handy tips!

    /Steve.
  • BootAble – FreeDOS boot testing freeware

    To obtain direct, low-level access to a system's mass storage drives, SpinRite runs under a GRC-customized version of FreeDOS which has been modified to add compatibility with all file systems. In order to run SpinRite it must first be possible to boot FreeDOS.

    GRC's “BootAble” freeware allows anyone to easily create BIOS-bootable media in order to workout and confirm the details of getting a machine to boot FreeDOS through a BIOS. Once the means of doing that has been determined, the media created by SpinRite can be booted and run in the same way.

    The participants here, who have taken the time to share their knowledge and experience, their successes and some frustrations with booting their computers into FreeDOS, have created a valuable knowledgebase which will benefit everyone who follows.

    You may click on the image to the right to obtain your own copy of BootAble. Then use the knowledge and experience documented here to boot your computer(s) into FreeDOS. And please do not hesitate to ask questions – nowhere else can better answers be found.

    (You may permanently close this reminder with the 'X' in the upper right.)

Scott

Well-known member
Sep 18, 2020
181
46

This How To article is in two parts:​

  1. Part 1 - Introduction, creating external boot drive, installing QEMU and it's prerequisites
  2. 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​

  1. Create a folder to store your virtual disk images
    1. Open your Home folder
    2. Create a new folder called "QEMU" at this level (same level as Documents and Downloads folders)
  2. Download the base drive "srdos.qcow2" from my OneDrive, and move it to the QEMU folder
  3. Test that qemu is working:
    1. Open a Terminal window
    2. Change to the QEMU directory:
      • cd ~/QEMU
    3. Now you'll run qemu, attaching the base drive
      • sudo qemu-system-x86_64 -drive file=srdos.qcow2
    4. A window should open and settle at a DOS C:\> prompt
    5. There is a spinrite.exe file on the drive, but it's an old pre-release version that will not do anything
    6. Type shutdown at the C prompt and the DOS window should close
    7. 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.
  1. Go to GRC.com and download your personal copy of SpinRite
    1. 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"
    2. Your Mac may automatically unzip the file, which contains one file called spinrite.img
    3. Move that file to the QEMU directory you created previously
    4. You now have two virtual drive files in that directory, one called srdos.qcow2 and one called spinrite.img
  2. Now you'll run a QEMU session to copy the spinrite executable
    1. From the Terminal window, cd ~/QEMU
    2. Type the following command (note the backslash as the line continuation character):
      1. sudo qemu-system-x86_64 \
        -M pc \
        -rtc base=localtime,clock=host \
        -hda srdos.qcow2 \
        -hdb spinrite.img \
        -boot c

      2. 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
      3. At the C prompt, type:
        1. C:\>copy d:spinrite.exe c:\
      4. You'll be asked if you want to overwrite spinrite.exe on the C drive; Yes, you do
      5. You can start spinrite from the C prompt, it should show your licensed copy
      6. Now you can shutdown from the C prompt
      7. Next steps: determining the Unix drive names for the drives you want spirit to operate on, dismounting them from MacOS, and then starting QEMU

Determining Unix drive names​

  1. You’ll need the device names of the physical drives on the system
  2. Open a Terminal session
  3. Run the command:
    1. diskutil list
  4. 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
  5. 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.
  6. Run the command:
    1. df -h
  7. This will show you the mounted partitions, and you must unmount them.
    1. EXAMPLE:
      1. 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:
        1. diskutil unmount /dev/disk1s1
        2. diskutil unmount /dev/disk1s4
      2. You should then unmount the physical and synthesized disks
        1. diskutil unmountDisk /dev/disk1
        2. diskutil unmountDisk /dev/disk0
  8. Alternatively, for unmounting after you've determined the device names, you can use the Mac Disk Utility
    1. Open the Disk Utility
    2. Go to the View Menu, and select "All Devices"
    3. 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
    4. For example, on my system:
      1. My external boot drive was /dev/disk2, showing synthesized drive of /dev/disk3
      2. My internal drive, which will be the SpinRite target, was physically /dev/disk0 with synthesized drive of /dev/disk1
      3. I used Disk Utility to unmount the container from the physical disk, which unmounted the synthesized drives

Running QEMU
  1. 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:
    1. 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
  2. Explanation:
    1. -M pc: sets the device type to what QEMU currently considers its baseline PC, which has:
      1. PS/2 mouse and keyboard
        2 PCI IDE interfaces with hard disk and CD-ROM support
        Floppy disk
    2. -rtc sets the realtime clock within the emulated system to use the date and time from the host
    3. -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
    4. -drive file=/dev/disk0,format=raw,media=disk,cache=none,index=1 mounts the target drive as the D drive
    5. -boot c says to boot from the C drive. Not really necessary
  3. After SpinRite runs, you can drop back to the C drive in the emulator and type shutdown
  4. 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:
  • Like
Reactions: DocZZZ
I have used the following:

sudo qemu-system-x86_64 -M pc -rtc base=localtime,clock=host -hda SpinRite61.img -drive
file=/dev/disk16,format=raw,media=disk,cache=none,index=1


It runs faster than my Zimaboard.

I created the bootable image ( SpinRite61.img ) myself from my USB drive I use on my Zimaboard. The image can be mounted on the mac to view, remove, or move the log files.

Thanks for the post.
 
I have used the following:

sudo qemu-system-x86_64 -M pc -rtc base=localtime,clock=host -hda SpinRite61.img -drive
file=/dev/disk16,format=raw,media=disk,cache=none,index=1


It runs faster than my Zimaboard.

I created the bootable image ( SpinRite61.img ) myself from my USB drive I use on my Zimaboard. The image can be mounted on the mac to view, remove, or move the log files.

Thanks for the post.
Thank you for testing!! I have updated the instructions to include the real time clock flag, great catch.

Question -- was the /dev/disk16 disk the internal drive on your system, or an external (USB or Thunderbolt) drive?
 
I just found this thread and have Spinrite running on my 2020 MacBook Pro (M1 chip).

Bash:
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/disk4,format=raw,media=disk,cache=none,index=1 -boot c

I didn't want to scan the Mac HD, but a USB drive I attached. Nice!
 
Thank you for testing!! I have updated the instructions to include the real time clock flag, great catch.

Question -- was the /dev/disk16 disk the internal drive on your system, or an external (USB or Thunderbolt) drive?
It is my USB drive i am testing
 
Scott, this looks awesome. As someone whose skills are a little rusty, it's a little intimidating, but the instructions are extremely clear.
I often use UTM on my Apple Silicon mac, often successfully, and always for its x86 emulation (UTM is basically a wrapper around QEMU, allowing some tasks to be done more easily). Is there anything fundamental about the steps described here that indicate that UTM on my Mac wouldn't work for using SpinRite on an external USB drive? My main concern is the need in these instructions for sudo, but there might be others.
Thanks for any insights.
 
My main concern is the need in these instructions for sudo, but there might be others.
Thanks for any insights.

It’s the need for sudo. As far as I can tell you can’t run UTM via sudo, which is why I outlined the command line process with QEMU.
 
  • Like
Reactions: jzsimon
Thank you for your clear instructions for installing Xcode command line tools, Homebrew package manager and QEMU. The process was simple for me, and I suppose for a person that knows their way around macOS, and with some experience with download and running programs from the terminal command line. The entire process was maybe 45 minutes until I had SpinRite running on my 2020 M1 Mac mini, and then, about 30 minutes to get it running on my 2024 M4 Mac mini. I had previously been successful with VirtualBox on my M1 Mac mini, but setting up QEMU following your guide was much easier, and seems to be better suited for Apple Silicon Macs. I highly recommend your process, and thanks again for the clear guidance.