How To: Run SpinRite on a UEFI-only machine (Part 5C of 5 - Copying files to and from the VM Hard Drive)

  • 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
115
33
This How To article is in 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
  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
    1. Part 5A - Download a pre-built Virtual Machine instead of creating your own
    2. Part 5B - Creating your own Virtual Machine
    3. Part 5C - Copying files to and from the VM hard drive (this article)

Copying files to and from the VM "C" drive​


This information is so that you can mount the virtual hard drive within the host system and perform read and write file operations (including copying your own copy of the SpinRite executable to the drive)

There are three main steps to work with files on the VM virtual C drive from within your host OS:
  1. Convert the virtual C drive to a format that's readable by the Host OS
  2. Mount the virtual C drive from the host OS and perform your file manipulations
  3. Unmount the virtual C drive before starting VirtualBox

Converting the virtual C drive to a format that's readable by the Host OS​

  • If you already did this when creating or importing your Virtual Machine, you obviously do not need to do it again
  • When you created or imported your virtual machine, the hard drive can be in one of a variety of formats that VirtualBox supports. For easy manipulation in the Host OS, it should be in one of two formats:
    • .VHD file, if Windows is the Host OS
    • .IMG file, if Linux or MacOS is the Host OS
  • Reference: https://docs.oracle.com/en/virtualization/virtualbox/7.0/user/vboxmanage.html#vboxmanage-clonemedium
  • The following instructions assume your Virtual Machine is in a directory called SRDOS underneath the VirtualBox VMs directory
  • With VirtualBox NOT running:
    • On the Windows base OS, you'd want to convert the file to a .VHD file:
      • Open your terminal, and change directory to the VirtualBox VMs\SRDOSdirectory
      • cd "C:\Users\Admin\VirtualBox VMs\SRDOS"
      • do a dir and look at the files. If you see a .VDI, .VMDK, instead of a .VHD, you can convert it
      • "C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonemedium disk SRDOS-disk001.vmdk SRDOS.vhd --format VHD
      • Note: .VDI, .VMDK and .VHD formats are all compressed, so they will only be between 1 and 3 MB for the 100 MB hard drive
    • On the MacOS or Linux base OS, you'd want to convert the file a .IMG file. Instructions for both MacOS and Linux are identical
      • Open the console or terminal, and change to the VirtualBox VMsdirectory (not the SRDOS directory just yet)
      • cd ~/'VirtualBox VMs'
      • Change the permissions on the SRDOS directory
      • sudo chmod 777 SRDOS
      • Change into the SRDOS directory
      • cd SRDOS
      • do a lsand look at the files. If you see a .VDI, .VHD or .VMDK instead of a .IMG, you can convert it
      • sudo VBoxManage clonemedium disk SRDOS-disk001.vmdk SRDOS.img --format RAW
      • When that's done, you'll change the permissions so that you can mount the .IMG file from the standard user's account
      • sudo chmod 666 SRDOS.img
      • Note: the --format RAW switch makes an UNCOMPRESSED disk image file, which will be about 100 MB
    • Now start VirtualBox the normal way for your platform (graphically for Windows and Linux, sudo virtualboxfor MacOS
      • In the Settings for the SRDOS Virtual Machine, detach the original disk and attach the new .VHD or .IMG file to the IDE controller
      • Start the VM; once you know it works, go into the Media Manager and delete the original hard drive file (.VDI or .VMDK)

Mounting and unmounting the drive in the Host OS​


Note: Because this drive is a FAT16 drive, it does not have long file name support. If you create files with names that go beyond the DOS 8.3 file name convention, the names will be truncated when viewed in FreeDOS.

With VirtualBox NOT running:
  1. For Windows, use the Computer Management app
    1. Go to Windows Tools
    2. Select Computer Management; Right click on it, and Run as Administrator
    3. Open Disk Management
    4. On the Actions Tab, Attach VHD
    5. Browse to the file (C:\Users\Admin\VirtualBox VMs\SRDOS\SRDOS.VHD) and choose Okay
    6. You may then see the Disk mounted but Offline in the Disk Management app
    7. Right click on the Drive descriptor in the drive pane, and move the Drive Online; it may ask you what Drive Letter you'd like to assign
    8. Perform whatever file operations you want
    9. When you're done, Detach the VHD file in the Disk Management app
    10. If you Attach that VHD file again, it will normally be online and get the same drive letter as last time
  2. For MacOS:
    1. In the Finder top menu, select Go | Go to Folder; type a ~/ and navigate to the VirtualBox VMs folder; click and then select SRDOS folder
    2. Right click (Ctrl-click) on the SRDOS.img file. Go to Open With, and select DiskImageMounter
    3. The Image file will now show up on the desktop looking like a Drive icon, possibly named NO NAME
    4. Open up the "drive" and perform whatever file operations you like
    5. Close the finder window, and drag the drive icon to the trash to "Eject" it just like a USB drive
  3. For Linux:
    1. Open the Discover application store app and install the Gnome Disks app
      1. Search for disks
      2. Find the Disks app, the "Disk management utility for Gnome"
      3. Click on it, and in the upper right of the Discover app, click Install
    2. Once it's installed, open it (just called Disks) from the Application Menu
      1. From the top "hamburger" menu (the 3 horizontal lines), select "Attach Disk Image"
      2. Work your way through the folder hierarchy from Home until you get into the VirtualBox VMs/SRDOS folder
      3. Click on the SRDOS.img file
      4. UNCHECK the box in the lower left that says "Set up read-only loop device"
      5. Click on Attach.
    3. Now open the Dolphin File Manager
      1. Now within the Dolphin File Manager, you'll see the device in the Devices section (on mine it says 99.9 MiB Internal Drive).
      2. Click on the drive to see the disk contents.
      3. Perform whatever file operations you want
      4. Close the Dolphin File Manager
    4. Now back to the Disks application
      1. You'll see the drive listed on the left; on mine it showed up as "105 MB Loop Device"
      2. Click on the drive
      3. On the top of the app, toward the right side, is the icon typically used for Eject. Click on it.
      4. The .IMG file is now unmounted, and when you start VirtualBox you should see the results of your changes on the C drive
 
Last edited:
This is an impressive amount of text you have put up on this forum to show people how to virtualize spinrite. I congratulate you!
How does this impact spinrites ability to access the drive as it would is physically running on a physical computer?
Even though you are connecting to the raw disk through virtualbox, is there not still a virtual barrier between the physical disk and the virtualized spinrite.

I haven't used spinrite much at all in the past 10 years because I have only had laptops with no ability to connect disks other than through USB.
I wonder if a USB connected RAW disk to virtualbox would view the same as a sata connected raw disk to virtualbox.
Would spinrite see them the same, or access them the same?

Has anyone actually ran a failing hardisk in virtualbox with raw disks on spinrite and had it successfully repair the disk?
 
I wonder if a USB connected RAW disk to virtualbox would view the same as a sata connected raw disk to virtualbox.
Would spinrite see them the same, or access them the same?
I think the answer to that is a "Definite Maybe". It appears that some BIOS emulations will see USB connected drives in full, but some will only see the first 2.2TB. A definite case of YMMV.
 
I think the answer to that is a "Definite Maybe". It appears that some BIOS emulations will see USB connected drives in full, but some will only see the first 2.2TB. A definite case of YMMV.
Not quite. When running under VirtualBox, the "BIOS" is the VirtualBox written BIOS code, which can definitely handle drives larger than 2.2 TB, regardless of whether the host's native firmware can handle drives that big or not. The VirtualBox "BIOS" talks to the host OS drivers, completely bypassing the host OS's firmware.
 
I was able to perform most of the steps and get the expected result.
  • Starting with converting the VMDK to an IMG file,
  • installing Gnome Disk,
  • navigating to the IMG file,
  • attaching the IMG to the host using Gnome Disk.
  • I did remember to uncheck the "read-only loop device" checkbox.
According to the Gnome Disk UI, the IMG file is assigned an entry in the /dev folder. There are no error messages on any of the steps. I don't have a great understanding of this area but Gnome Disk does not indicate that it recognizes a file system on the attached IMG file.

However it does not show up in the Dolphin file manager as either a device or a removable device.

Any advice on how to debug further would be appreciated.
 
Did you start the virtual machine from the downloaded and imported VMDK file to ensure that FreeDOS booted?

And after converting to IMG format, did you mount the IMG file and, again, see if FreeDOS could boot?
 
Did you start the virtual machine from the downloaded and imported VMDK file to ensure that FreeDOS booted?

And after converting to IMG format, did you mount the IMG file and, again, see if FreeDOS could boot?

I scrapped everything I had, went back to the start and went through the entire process again and it worked. I must have made an error somewhere along the way.