raven ioctl

Installing Debian on a machine via USBstick when you've nothing but an XP workstation

ioctl.org : unix bits and pieces : debian install

Chicken and egg: running SYSLINUX on Windows XP on a USB memory stick

This is just a brief summary (because I couldn't find one anywhere) of how I got Debian Linux onto a "media PC"-style machine, using only (!) Windows XP.

The "media PC" was a friend's (let's call this friend "James", which stands for "Just a moment's easy solution", and refers to his unfortunate history of having five-minute tasks in the hobbyist computing field rapidly turn into nightmare epics - not through his own fault, either, but generally because five minute tasks take a lot longer when you try to follow a route that's repeatable and doesn't involve "here's one I did earlier") mini-ITX low-power job. It's a natty little device, but has no CD drive, and no floppy drive. It can, however, boot from a USB flash stick quite happily (USB 1.1 or USB 2.0, it claims). So my suggestion when asked was to do a USB boot and network install of Debian.

Why Debian?

I've had no end of hell installing various distributions in the past. Unlike many Linux "users", I don't reinstall the latest and greatest distribution every other day: it doesn't strike me as a productive thing to be doing. So I'm always at a bit of a loose end when it comes to a Linux install. The only distribution that I've had a 100% success rate with on install, considering things like: hardware support, getting going on a laptop with no problems, etc., is the "primitive" Debian installer. So I suggested that.

The second reason I suggested it is that the friend in question has no previous experience with Linux - although his ambitions are limitless - so I wanted a distribution that was easy to maintain. Most importantly, I wanted to avoid him getting into RPM dependency hell. Hence Debian.

Why USB and network install?

Simplest way to get this going would, of course, have been to whip the drive out of the media PC and into somthing else with a few more useful things (like, say, a floppy drive). However, we avoided that route because the drive is one of those mini-ATA jobs and that'd have involved all sorts of cable jiggery-pokery. Similarly, a PXE boot and install was out of the question because it raises the bar a little too high when the only other machine available is a stock XP box and the user in question's not (yet) a Unix whiz.

So instead we went for the approach of using a boot device that the media PC could talk to with no extra pieces required (the USB memory stick) and the network install followed automatically because the stick in question was too small to fit any of the "fairly full" ISOs onto.

The initial plan

The initial plan was to follow the scheme laid out by Pascal Le Bail. This basically involves grabbing the appropriate boot disk files for a netboot of Debian, slapping them onto a cheap USB memory stick, then making it bootable using the SYSLINUX tool.

Problem one

The first problem was that the instructions there were written principally assuming you already had a working Linux distribution from which to launch SYSLINUX. Which is the principal chicken-and-egg source of our frustration: when you come to install Linux for the very first time, you don't have a pre-existing platform to bootstrap off. In our case, we had the Windows XP workstation that belonged to James. Not to worry, however, because the SYSLINUX distribution comes with a DOS executable version too.

Problem two

This is where five minutes became five hours. It turns out that for some reason, XP doesn't let a 16-bit executable read or write the boot sector of a USB memory stick. This is the case even if you run with local administration privileges. Now, personally at that point I would have given up and used a local instance of a Unixalike in order to talk to the memory stick. However, we wanted the procedure to be "repeatable" (although I pray I'll never have to repeat it) from James' situation: that is, of having one fully-peripheralled up Windows XP PC and one media PC and not mucking around with throwing internal drives into different machines.

If you search for the error report that SYSLINUX gives you, which I reproduce here so that this page might be found and indexed: ERROR 3246: Boot sector read failed, then you'll see that you aren't alone in that situation. Several people report the problem; no solutions are offered. So the workaround we used is presented here.


NOTE: I've had feedback indicating that the companion application, syslinux.exe, ought to work under Windows XP (providing compatibility mode is configured correctly). You may have more luck with this than I did; my XP SP2 installation still balked with bootsector problems. If you get this working, I'd love to hear from you.

NOTE: I've also had feedback from Raoul Wittick who says that he had similar problems. He managed to get syslinux working by running it from inside cygwin. If you've got that installed it'll probably be less palaver.


Plan two

The SYSLINUX error reports led us to find Puppy Linux, another minimalist distribution. One of the useful tips the Puppy folks have is what to do if your PC can't boot from USB or CD. They suggest using a boot floppy (bear with me here) with FreeDOS on it. The FreeDOS contains a driver which makes a USB stick look like an ordinary drive. From there, one can boot off the USB stick.

Well, that wasn't quite what we wanted, but it was pretty close. So the plan became this: we'd cheat a little. We didn't want to damage the Windows XP machine, but we could boot it into FreeDOS and use the drivers on the Puppy Linux boot disk to make the USB device visible. From that 16-bit environment (which doesn't "protect" the boot sector like XP does) we could complete the SYSLINUX process to make the USB stick bootable. At that point we could use it in the media PC and actually begin to install the operating system we were after.

Problem three

Having the plan, we were pretty much on the home straight. At this point we'd relocated to my place (where the SYSLINUX task would have been trivial). However, we now had the bit firmly between our teeth and wanted to determine completely that the process we'd outlined (which was theoretically reproducible on James' setup) could be made to work.

Thus the issues we faced from that point onwards are much more mundane. James described my approach as "the black arts" but frankly it's just a question of being systematic. OK, the problem then: how many floppy disks do you have hanging around? Turned out I had a total of three, and they were all years old. Two of them failed. Luckily the third succeeded. I could have used rawrite.exe but instead I'd already fetched a copy of fdimage.exe which is the floppy image writing tool (which fortunately works under XP!) that I was used to from the FreeBSD project.

Problem four

Here we get onto the truly systematic part. All you can do in these situations is have patience and trust that things will come good.

The PC I was using to boot into FreeDOS is a slightly older Dell box. It only has USB1.1 capability; in addition, it can't boot from USB (so after preparing the memory stick the only place we had available to try it out wa the media PC itself). The 64MB stick we had was a USB2.0 device. I'm not sure if it was the Dell controllers or the drivers that the FreeDOS boot disk supplied, but (as luck would have it) we didn't get the USB stick to be recognised.

Fortunately, I had a handy USB1.1 device knocking around which we were able to use. Again, it didn't work right the first time. We had to use a systematic process of unplugging all the other USB devices from the machine and trying the memory stick in every USB socket before we found one that worked properly; rebooting into FreeDOS each time. Your mileage, as they say, may vary, particularly if you have a slightly newer machine. We might have had better luck had I updated the machine's BIOS, but I wasn't going to try that unless everything else failed.

Success

The following is the process that we eventually used to create the bootable USB device:

Problem five

After that palaver, it's worthwhile recording the final problem we encountered. I have a slightly older keyfob-style USB memory stick. The USB port was right bang smack next to the VGA output on the media PC. In a nutshell, it was impossible to fit both the USB memory stick and the VGA cable into the machine at the same time.

Fortuantely, we're not all thick in chez Jan and my girlfriend pointed out that I had a USB extension cable (with neat, thin ends) plugged into the XP machine. Which saved me from having to whittle the USB stick, so that was a win.

Conclusion

Once this overly complex process was over and our "five-minute" preliminary complete, I'm happy to report that the little media PC booted perfectly, found the network, and we were able to complete a Debian installation painlessly. (With one caveat: neither of the two local mirrors we selected appeared to carry the "stable" distribution, so we went with "testing".)

I only hope that this page helps others cut to the chase if they find themselves in a similar situation. If you know of a way to get SYSLINUX working properly on Windows XP, I would love to hear from you.