How To: Run SpinRite on a UEFI-only machine (Part 3B of 5 - Linux as base OS)

  • 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
154
41
This How To article is split into multiple parts:
  1. Introduction
  2. Using Windows to Go as the base OS for your bootable VirtualBox system
  3. Using Kubuntu Linux as the base OS for your bootable VirtualBox system
    1. Part 3A - Setting up the Linux drive, Installing VirtualBox
    2. Part 3B - Creating a SR VM, Mapping the Host drives to the SR VM, Moving your Linux drive to a new Target Machine (this article)
  4. Using MacOS as the base OS for your bootable VirtualBox system
  5. Downloading or Creating your VM and moving files in and out of the virtual drive

C. Setting up the base SpinRite Virtual Machine​

  1. You could do either of the following:
    1. Part 5A - Download a pre-built Virtual Machine instead of creating your own, or
    2. Part 5B - Creating your own Virtual Machine
  2. Using the pre-built Virtual Machine does not require access to a Windows PC but does entail some command line work
  3. Once you've completed one of those processes, come back here to configure access to the target system drives

D. Configuring access to target system drives​

  1. Reference: https://docs.oracle.com/en/virtualization/virtualbox/7.0/user/AdvancedTopics.html#rawdisk
  2. You’ll need the device names of the physical drives on the system
  3. Open a Terminal session
    1. Run the command:
      1. lsblk
    2. This will show all the block devices (drives) on the system, and their mountpoints if mounted
      1. You may see a lot of loop devices; you can ignore those.
      2. Try and pick out the actual drives by looking at the capacity and matching that to your knowledge of the target system
    3. Note the name(s) of the drive(s) and partitions underneath them
    4. Drive names may be something like: sda or nvme0n1
    5. Some internal drives and their partitions, MAY BE MOUNTED. You MUST UNMOUNT the drives and partitions in order to proceed safely!
      1. Note the name of the Partition you need to unmount
      2. Use the umount command to unmount the partition
      3. For example, if I have a drive sda with a mounted partition, sda1, enter:
        1. sudo umount /dev/sda1
      4. For another example, if I have a drive nvme0n1 with a mounted partition, nvme0n1p4, enter:
        1. sudo umount /dev/nvme0n1p4
  4. From the terminal window
    1. cd ~/'VirtualBox VMs'
    2. For each drive you want accessible to SpinRite you’ll create a special .VMDK file that VirtualBox will use to access the real drive. For example, if the first drive you want to use as noted from lsblk , is sdc, you’d reference it in the VBoxManage command as /dev/sdc:
      1. sudo VBoxManage createmedium disk --filename DISK0.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/sdc
    3. If the next one was nvme0n1, the command would be:
      1. sudo VBoxManage createmedium disk --filename DISK1.vmdk --format=VMDK --variant RawDisk --property RawDrive=/dev/nvme0n1
  5. For each drive on the system, you’ll want to give a unique filename, and adjust the RawDrive parameter to refer to the correct Physical Drive
  6. When you’ve created the needed .vmdk file(s), exit from the command prompt
  7. Now start VirtualBox
  8. Go to Settings, then Storage
  9. Decide whether to attach your virtual drives to either the IDE controller or the AHCI controller
    1. IDE Controller (listed as PIIX4 in the VM Settings)
      1. Pros:
        1. Faster operation (SpinRite native IDE driver works)
      2. Cons:
        1. Can only add up to 3 drives, as IDE only supports 4 total
        2. Logs will not be written until after the SpinRite session ends
    2. AHCI Controller
      1. Pros:
        1. Can have up to 30 drives (ports 0 to 29)
        2. Can log during operation
      2. Cons:
        1. Drives are seen as BIOS attached; SpinRite native AHCI doesn't work for some reason
        2. BIOS access may be an order of magnitude slower than IDE (or the same speed, you need to test and see!!)
  10. Attach the drives
    1. NOTE: The Host drive does NOT have be an actual AHCI connected SATA drive; access is just by block address
    2. The Medium Selector screen should be aware of the vmdk files you made, highlight one and select Choose
    3. Repeat as necessary to add all your vmdk files
  11. Now start your VirtualBox session
  12. At the C:\> prompt start spinrite
  13. C:\>spinrite
  14. After the memory check, SpinRite should enumerate the boot virtual drive, as well as all of the VMDKs you’ve attached
  15. And that’s it!! Perform whatever SpinRite operations you want on the attached drives

How do I use this disk on another PC?​

  1. Boot up the new target PC with the Linux USB drive
    1. If the new PC is running with Secure Boot on, you must re-enroll the MOK key, then reboot:
      1. Open a Terminal window
      2. sudo mokutil --import /var/lib/shim-signed/mok/MOK.der
        1. The system will prompt you for the MOK password during the install
        2. It doesn't have to be the same as the last time you ran it, but it still needs to be at least 8 characters. You'll enter the password twice; REMEMBER IT!!
    2. Once the install is finished, exit the terminal
    3. Reboot – as before, on first boot you will be prompted to install the MOK keys, follow the same steps as before
  2. Start VirtualBox
    1. Go into Settings and REMOVE the prior VMDK files from the AHCI controller
    2. You should now CLOSE and DELETE any prior VMDK files referring to drives from a different system.
      1. You’ll use the VboxManage closemedium command for this:
      2. Reference: https://docs.oracle.com/en/virtualization/virtualbox/7.0/user/vboxmanage.html#vboxmanage-closemedium
      3. Open an Terminal window
        1. Change to the VirtualBox VMs directory
        2. cd ~/'VirtualBox VMs'
        3. do an ls command to see the .VMDK files
        4. ls
        5. Use VBox Manage to delete any prior VMDK files.
        6. sudo VBoxManage closemedium DISK0.vmdk --delete
  3. The vmdk files will be deleted, AND removed from VirtualBox’s registry of known drives
  4. You can now add the drives from the new system you are testing
 
Last edited:
What's the intent behind some of the steps in part C? I ask because I don't have a PC handy with which to make my own SpinRite-FD.IMG, I only have spinrite.img downloaded from GRC, and VirtualBox can't seem to use that as floppy, hd, or optical disk image. I'm trying to get the gist of the strategy you describe so I can manage the same thing a little differently, but don't know what I can skip or try achieving another way vs. what is essential.

I can mount spinrite.img on my Mac and copy files to a virtual drive. Frustratingly, I wasn't able to get VirtualBox to create another virtual hard drive (why?! it's such a frustrating tool), so I tried turning the C: drive, the one you mentioned would only be needed for logs, into a bootable spinrite disk. But I'm unfamiliar with everything in VirtualBox as well as in DOS and naturallly I'm missing something.

Have you any anyone else on these forums have any tips if starting from FD13BOOT.IMG and spinrite.img directly off of GRC, that would be a huge help.

And BTW, I'm trying to run Spinrite within VirtualBox on my 2019 Intel MacBook Pro and set it loose on some external USB drives, I'm not expecting to be able to apply it to my Mac's boot drive.


Oops. Posted to the wrong thread in the wrong browser tab. I think I need a browser with side tabs ;^) I'll be following the recommendation to follow the tips on https://forums.grc.com/threads/how-...-machine-part-5-of-5-using-pre-built-vm.1619/ and will followup there with questions I might have.
 
Last edited:
This is the Linux instructions. You state that you have a Mac so try this thread.
@Bplayer, yes these are the Linux instructions but you pointed @jpmhouston to the instructions for running FreeDOS natively on a Mac. On a 2019 Mac, that's not possible, so @jpmhouston is doing the right thing by running VirtualBox with SpinRite within it. @jpmhouston , looks like you've chosen to boot from a Linux host OS; that's fine if you're comfortable with Linux.

@jpmhouston , I'd suggest following the instructions in Part 5 of this post to download a pre-built virtualbox VM, rather than build your own (which does require getting the bootable floppy made from the Windows SpinRite executable. Then the only hard part is getting the actual spinrite executable onto that drive. I'm working on revising the directions for that to hopefully eliminate the need for a Windows machine, but in the meantime just see if you can get VirtualBox to boot up to a C drive.

Also question for you, @jpmhouston ; you say you don't have access to a PC, but my instructions for making a bootable Kubuntu drive rely on Rufus on a PC, so how did you do it (your query was in the Linux section so I assume that's what you're running)? Or are you running VirtualBox on your regular MacOS installation, just to get to the external USB drives?
 
Also question for you, @jpmhouston ; you say you don't have access to a PC, but my instructions for making a bootable Kubuntu drive rely on Rufus on a PC, so how did you do it (your query was in the Linux section so I assume that's what you're running)? Or are you running VirtualBox on your regular MacOS installation, just to get to the external USB drives?
Thanks. I'm in fact running macOS on my laptop, not Linux, and I indeed just lost track of which browser tab was which and posted my question to the wrong thread. I'll try the pre-built VM post mentioned above, and if I have further questions then I'll repost questions on the right thread (this time), perhaps with more explanation for what I've tried so far.
 
Thanks. I'm in fact running macOS on my laptop, not Linux, and I indeed just lost track of which browser tab was which and posted my question to the wrong thread. I'll try the pre-built VM post mentioned above, and if I have further questions then I'll repost questions on the right thread (this time), perhaps with more explanation for what I've tried so far.
I've updated the instructions for the pre-built VM so that if you don't have a PC handy to run the SpinRite executable to generate the boot floppy image, you can convert the VM hard drive to a .IMG file which can be mounted in MacOS as a drive. You could then download the spinrite file from GRC and just copy it into the drive.

I just wrote up the directions, so give it a try if you like. Honestly it's easier to mount the floppy image but if you can't generate it at least there's an alternative
 
I get to the point where I need to use the lsblk command. This gives me output, but no internal drives. I get a lot of loopx (where x is a number) and one sda that is partitioned into sda1 and sda2. This sda with it's partitions seems to belong to the USB I booted with. So where are my internal drives? If I don't see the internal drives here I guess I cannot proceed any further? Or did I miss a step that resulted in this?
 
I get to the point where I need to use the lsblk command. This gives me output, but no internal drives. I get a lot of loopx (where x is a number) and one sda that is partitioned into sda1 and sda2. This sda with it's partitions seems to belong to the USB I booted with. So where are my internal drives? If I don't see the internal drives here I guess I cannot proceed any further? Or did I miss a step that resulted in this?
Apparently I had to change storage mode from RST to AHCI in BIOS. Only then Linux would see the drives. But it was even better: when changing to AHCI I could then (and only then) also change from UEFI to Legacy which I could not do any other way on my Lenovo laptop (it wasn’t even a visible/greyed out option). This way I could just boot with a Spinrite USB the normal way instead of using the Virtualbox method.

I also had secure boot disabled earlier. Which I enabled again after having used Spinrite on the disk.

The BIOS gave a message that I would lose all my storage data when changing from RST to AHCI (and back afterwards) but after doing some reading about that (and having a backup) I felt lucky. And I was. It’s probably the BIOS maker being very cautious when nothing is actually happening to the data on your storage device.
 
Apparently I had to change storage mode from RST to AHCI in BIOS.
Based on this reply to someone asking which mode they should use, you may be better off with AHCI on all the time anyway:

 
  • Like
Reactions: humke
I followed the steps and it all worked pretty much as explained. I have kubuntu 24 on a USB. I booted into it, installed virtual box, set up a FreeDos SpinRite VM. I want to run spinrite on the first drive on the host. The drive has 4 partitions with Windows on one of the partitions. It showed up in lsblk. I unmounted and then created a VMDX, attached as an IDE HDD to the VM. On running spinrite, it sees the drive but I get this. The message says "Invalid partition for drive size". This may have nothing to do with virtualization so I can post on another forum if this is not the place.
 

Attachments

  • Screenshot_20240613_233541.png
    Screenshot_20240613_233541.png
    99.2 KB · Views: 87
  • Screenshot_20240613_233443.png
    Screenshot_20240613_233443.png
    181.8 KB · Views: 125
@RobertBlumen , you are indeed running SpinRite 6.0 per the second screen shot. SpinRite 6.0 does partitions, SpinRite 6.1 does not.

The error message for drive 1, MBR followed by EFI, means drive 1 is GPT formatted. SpinRite 6.0 is NOT compatible with GPT.

SpinRite 6.1, however, is fully compatible with GPT drives. SpinRite 6.1 would have no problem with drive 1.
 
Last edited:
@DanR you are correct. I was trying to save a step where I copied the spinrite exe into the VM so I used a SpinRite + FreeDOS VM I had created earlier, not realizing it was SR 6.