I wanted to post this here for posterity, and in case anyone else needs it. I am having trouble with a TrueNAS drive, and wanted to Spinrite it. However, I can't get it to boot FreeDOS. So, I took the drive out of the computer, and put it into an external drive connector, which allows it to connect to my main computer (Linux) over USB3. Getting it to work with Spinrite 6.1 in a virtual machine was difficult, but i eventually got it figured out. The hard part was making the hard drive visible inside the virtual machine.
Setup:
- External drive connector
- Suspect hard drive
- FreeDOS
- Spinrite
- VirtualBox
- Running on Ubuntu
1. Attach the suspect hard drive to the working computer
Plug it into your SATA/IDE cable, or use an external connector. Make sure it is NOT mounted in the file system, so it doesn't interfere with Spinrite
2. Setup a virtual machine for FreeDOS
In my case, I had a Spinrite.img file, not an ISO, and I couldn't figure out how to get one. So, I downloaded FreeDOS. If you do have a Spinrite ISO, you can use that to create the virtual machine directly and skip step #3.
Create a regular DOS virtual machine in VirtualBox. Give it a 300MB+ hard drive for FreeDOS to install it. Once created, attach the FreeDOS ISO in Settings>storage as an optical disk. Save the changes and boot it up. Make sure you get to a DOS prompt. Make note of the FreeDOS menu. Default runs after a few seconds.
3. Create Spinrite ISO (if required)
Since I didn't have a Spinrite ISO, and the VirtualBox method of "attaching folders" didn't work. I wrote the Spinrite.img file to a USB thumbdrive, mounted it as a drive in my computer, and used K3B (CD making program) to create an ISO with all the files on the USB drive. FreeDOS understands CD-ROMs, so this is an easy method to get files into the file system.
I then shutdown the virtual machine, went into Settings>storage, detached the FreeDOS ISO, and attached the Spinrite ISO. I booted up FreeDOS, and copied all the files from the D:\ drive (ISO) to the C:\ drive, to have them in the file system. This is important because we'll lose CD-ROM access when running Spinrite.
Note: Spinrite does not work due to some memory management that FreeDOS has. I'll address that later.
4. Create a virtual disk pointer file
This is the tricky part. We have to make a bridge between the actual hard disk hardware, and VirtualBox, in a way that it can understand. VirtualBox really only understands virtual hard drives, so we're going to create a virtual hard drive file which is a kind of pointer to the real hard drive.
This is the command to create the virtual hard disk file (VMDK):
sudo VBoxManage internalcommands createrawvmdk -filename "sdb.vmdk" -rawdisk /dev/sdb1
In my case, my suspect hard drive is /dev/sdb. It may be different for you.
Note that I am referring to /dev/sdb1 (first partition). Using fdisk, I was able to see that this hard drive had one partition, and 1 is its designation. I first tried to use /dev/sdb, but Spinrite couldn't see it. If you have multiple partitions, make sure you create a VMDK file for each.
That is all that's required, but we have to be aware of permissions. VirtualBox is running under your user account, and the VMDK file was created by root. So, execute the following commands:
sudo chmod 777 sdb*.vmdk
sudo chmod 777 /dev/sdb*
Again, adjust to your own files and devices. This will make the hard drive and the VMDK file read/writable for your user account.
5. Connect the virtual disk file to the virtual machine
Now that we have one or more VMDK files which link to the read hard drive, it needs to be put into VirtualBox. Go to FreeDOS' Settings>storage and for the IDE/SATA controller (same as the FreeDOS virtual drive), add a new hard disk (should be an icon that looks like a hard drive). In the next window, click Add. Navigate to your new VMDK files, and add them all (one at a time). Then save settings.
Note: If you shut off the real hard drive, the UUID that your computer assigns to it may change, and that means the VMDK files will no longer work. You can detach and remove them from the media manager in VirtualBox and delete the files from disk, but I found that still wasn't enough. I had to create new filenames completely.
6. Run Spinrite
We are finally ready to test this drive. Start FreeDOS in VirtualBox. When you see the FreeDOS menu (4 boot items), choose #4. This disables all memory management. It also disables CD-ROM access. At the prompt, navigate to where you stored spinrite, and run it.
Spinrite should start normally, and when it goes to detect the hard drives, you should see your drives there.
Happy Spinrite-ing!
Setup:
- External drive connector
- Suspect hard drive
- FreeDOS
- Spinrite
- VirtualBox
- Running on Ubuntu
1. Attach the suspect hard drive to the working computer
Plug it into your SATA/IDE cable, or use an external connector. Make sure it is NOT mounted in the file system, so it doesn't interfere with Spinrite
2. Setup a virtual machine for FreeDOS
In my case, I had a Spinrite.img file, not an ISO, and I couldn't figure out how to get one. So, I downloaded FreeDOS. If you do have a Spinrite ISO, you can use that to create the virtual machine directly and skip step #3.
Create a regular DOS virtual machine in VirtualBox. Give it a 300MB+ hard drive for FreeDOS to install it. Once created, attach the FreeDOS ISO in Settings>storage as an optical disk. Save the changes and boot it up. Make sure you get to a DOS prompt. Make note of the FreeDOS menu. Default runs after a few seconds.
3. Create Spinrite ISO (if required)
Since I didn't have a Spinrite ISO, and the VirtualBox method of "attaching folders" didn't work. I wrote the Spinrite.img file to a USB thumbdrive, mounted it as a drive in my computer, and used K3B (CD making program) to create an ISO with all the files on the USB drive. FreeDOS understands CD-ROMs, so this is an easy method to get files into the file system.
I then shutdown the virtual machine, went into Settings>storage, detached the FreeDOS ISO, and attached the Spinrite ISO. I booted up FreeDOS, and copied all the files from the D:\ drive (ISO) to the C:\ drive, to have them in the file system. This is important because we'll lose CD-ROM access when running Spinrite.
Note: Spinrite does not work due to some memory management that FreeDOS has. I'll address that later.
4. Create a virtual disk pointer file
This is the tricky part. We have to make a bridge between the actual hard disk hardware, and VirtualBox, in a way that it can understand. VirtualBox really only understands virtual hard drives, so we're going to create a virtual hard drive file which is a kind of pointer to the real hard drive.
This is the command to create the virtual hard disk file (VMDK):
sudo VBoxManage internalcommands createrawvmdk -filename "sdb.vmdk" -rawdisk /dev/sdb1
In my case, my suspect hard drive is /dev/sdb. It may be different for you.
Note that I am referring to /dev/sdb1 (first partition). Using fdisk, I was able to see that this hard drive had one partition, and 1 is its designation. I first tried to use /dev/sdb, but Spinrite couldn't see it. If you have multiple partitions, make sure you create a VMDK file for each.
That is all that's required, but we have to be aware of permissions. VirtualBox is running under your user account, and the VMDK file was created by root. So, execute the following commands:
sudo chmod 777 sdb*.vmdk
sudo chmod 777 /dev/sdb*
Again, adjust to your own files and devices. This will make the hard drive and the VMDK file read/writable for your user account.
5. Connect the virtual disk file to the virtual machine
Now that we have one or more VMDK files which link to the read hard drive, it needs to be put into VirtualBox. Go to FreeDOS' Settings>storage and for the IDE/SATA controller (same as the FreeDOS virtual drive), add a new hard disk (should be an icon that looks like a hard drive). In the next window, click Add. Navigate to your new VMDK files, and add them all (one at a time). Then save settings.
Note: If you shut off the real hard drive, the UUID that your computer assigns to it may change, and that means the VMDK files will no longer work. You can detach and remove them from the media manager in VirtualBox and delete the files from disk, but I found that still wasn't enough. I had to create new filenames completely.
6. Run Spinrite
We are finally ready to test this drive. Start FreeDOS in VirtualBox. When you see the FreeDOS menu (4 boot items), choose #4. This disables all memory management. It also disables CD-ROM access. At the prompt, navigate to where you stored spinrite, and run it.
Spinrite should start normally, and when it goes to detect the hard drives, you should see your drives there.
Happy Spinrite-ing!
Attachments
Last edited:

