2009
03.19

SpinRite Over PXE Booting

My company has about 100 employees now and, as a small IT department, we are constantly trying to find ways to streamline things to reduce repitition, downtime, etc. One thing I’ve been wanting to do for a while now to facilitate this is implement PXE boot menus to allow us to launch some pre-os utilities like SpinRite and MemTest for basic troubleshooting of PC’s in place. Memtest was easy, since it’s packaged into a bootable image already. SpinRite was going to prove harder since it needs a DOS environment to run in. We got it working though and I have to say the results are sweet.

Let me give a brief PXE overview just for getting oriented. If you aren’t familiar with PXE(Preboot Execution Environment), it’s a spec developed by Intel that allows for booting a computer over a network right after the POST by allowing you to specify the location of bootable image files in your DHCP packets. You set this up on the PC side in the BIOS by changing the boot order to make “Network” the first in the list. This will make your PC call out to the network for a DHCP server to get an IP address and basic network boot information. Here are the basic steps that happen:

  1. Computer POSTS.
  2. BIOS passes execution to the PXE boot rom.
  3. PXE broadcasts for a DHCP server.
  4. DHCP server gives back an address packet
  5. PXE extracts the TFTP server address and boot filename from DHCP packet
  6. PXE downloads the boot file from the TFTP server and executes it

So the basic idea is that every time a machine on the network boots up, it first grabs a PXE boot image from the network and executes it. In our case, this just presents a basic menu to the user written in PXELINUX’s menu language. If no menu selection is made, it times out very quickly(3 seconds) and the computer is booted from the local drive like usual into Windows. But for us, as network admins, we put a link on the menu to Memtest and SpinRite. The full topic of setting up PXE is best covered here, so check it out first to get a working PXE setup. But, enough theory! Here’s how to make SpinRite work.

First, go buy SpinRite if you don’t own it already so Steve can buy some more PDP-8’s. :) Corporate users will need to buy four licenses in order to get a site license for commercial use. Then, download the FreeDOS bootable floppy image from the FreeDOS website. The FreeDOS boot image gives you a fully bootable image with a DOS environment that can be booted by PXELINUX’s memdisk program. The trick is getting the spinrite.exe executable onto the image and launching it automatically when the DOS environment loads. Here’s how in Linux:

dave@localhost$> mkdir mnt/loop
dave@localhost$> mount -t vfat -o loop fdboot.img mnt/loop
dave@localhost$> cp spinrite.exe mnt/loop
dave@localhost$> pico -w mnt/loop/freedos/fdauto.bat

[...add a call to "spinrite.exe" in here...]

dave@localhost$> pico -w mnt/loop/fdconfig.sys

[...remove all the config.sys menu language...]

dave@localhost$> umount mnt/loop
dave@localhost$> mv fdboot.img spinrite.x86

What we just did is mount the FreeDOS boot image as a loopback device, add spinrite.exe to it’s filesystem, remove all the config.sys menu garbage and add a call to spinrite.exe to the autoexec file. This process is very easy to do under Linux as long as you have loopback block device support compiled into your kernel. Most people should. This leaves us with the equivelant of a bootable spinrite floppy disk in a single file named spinrite.x86. We can now drop this in our TFTP boot folder and put a call in the PXE boot menu file like this:

LABEL spinrite
  menu label ^SpinRite
  kernel memdisk
  append initrd=spinrite.x86

Just make sure you have copied the memdisk file over to your TFTP boot directory as well and you’re good to go. Now you can boot any machine on your network and run SpinRite without having to lug discs around or bring it back down to the computer room. The beauty of this technique is that it’s so expandable. Any DOS program can be run this way. Also, you could even setup BIOS time of day auto-power-up and have all your PC’s automatically boot at a certain time of night, scan themselves with SpinRite, then shut down when finished. You’d have to swap in a specially crafted version of the PXE boot files and spinrite.x86 with a cron job maybe once a month. This is all assuming that SpinRite accepts command line arguments for autoscanning, which I’m not sure about. Sounds plausible though.

I was excited about this project and it turned out great. I hope this helps someone else as well. I’ll post a YouTube video later showing it in action.

Switch to our mobile site