Running SpinRite from CLI with VirtualBox and VNC

Bradley Noyes published on
3 min, 498 words

If you don't have the luxury of having a dedicated machine to run SpinRite to scan hardrives, perhaps this recipe will help you. It only scans drives through the USB interface, which is (at least) one layer removed from the ATA layer, but its better than nothing, and anecdotely it seems to work.

Since the virtual machine requires access to the raw usb decices, you'll probably need to run the following recipe as a privilaged user, i.e. root.

Install VirtualBox🔗

This link should get you going in the right direction.

https://www.virtualbox.org/wiki/Downloads

Create new VM🔗

VBoxManage createvm --name SpinRite --ostype "WindowsNT" --register
VBoxManage modifyvm SpinRite --memory 2048 --vram 128

I used the "WindowsNT" ostype which worked, but if you want to try something else feel free; there only a few dozen options, try running vboxmanage list ostypes to get a list. The second line increases the memory to 2 GiB for the VM, way more than necessary for SpinRite, but I did this because I was also using this VM to boot SystemRescue.

Create disk controller and USB raw disk🔗

The following assumes your USB disk is connected to /dev/sdd, update your commands with your device node as needed. Use dmesg or lsblk or ls /dev/disk/by-* to determine your USB device node.

VBoxManage internalcommands createrawvmdk -filename ~/usb_rawdisk_sdd.vdi -rawdisk /dev/sdd
VBoxManage storagectl SpinRite --name "SATA Controller" --add sata --controller IntelAhci
VBoxManage storageattach SpinRite --storagectl "SATA Controller" --port 0 --device 0 --type hdd --mediaum ~/usb_raw_disk_sdd.vdi
VBoxManage modifyvm SpinRite --ioapic on

Attach the SpinRite ISO🔗

VBoxManage storagectl SpinRite --name "IDE Controller" --add ide --controller PIIX4
VBoxManage storageattach SpinRite --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium ~/SpinRite.iso
VBoxManage modifyvm SpinRite --boot1 dvd --boot2 disk --boot3 none --boot4 none

Configure boot order🔗

VBoxManage modifyvm SpinRite --boot1 dvd --boot2 disk --boot3 none --boot4 none

Setup Remote Display to Enjoy Anywhere🔗

VBoxManage modifyvm SpinRite --vrde on
VBoxManage modifyvm SpinRite --vrdemulticon on --vrdeport 10002

Fire it up!🔗

VBoxHeadless --startvm SpinRite

You'll need to connect to port 10002 with a VNC client, and you may also need to open that port to allow remote connections.

Complete Recipe soup-to-nuts🔗

    VBoxManage createvm --name SpinRite --ostype "WindowsNT" --register
    VBoxManage internalcommands createrawvmdk -filename ~/usb_rawdisk_sdd.vdi -rawdisk /dev/sdd
    VBoxManage storagectl SpinRite --name "SATA Controller" --add sata --controller IntelAhci
    VBoxManage storageattach SpinRite --storagectl "SATA Controller" --port 0 --device 0 --type hdd --mediaum ~/usb_raw_disk_sdd.vdi
    VBoxManage modifyvm SpinRite --ioapic on
    VBoxManage storagectl SpinRite --name "IDE Controller" --add ide --controller PIIX4
    VBoxManage storageattach SpinRite --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium ~/SpinRite.iso
    VBoxManage modifyvm SpinRite --boot1 dvd --boot2 disk --boot3 none --boot4 none
    VBoxManage modifyvm SpinRite --vrde on
    VBoxManage modifyvm SpinRite --vrdemulticon on --vrdeport 10002
    VBoxManage modifyvm SpinRite --memory 2048 --vram 128

    VBoxHeadless --startvm SpinRite

Check to make sure that port 10002 allows for incomming connections from the firewall.