This is for my own reference more than anything else; periodically I find myself needing to boot DOS. Usually because I want to upgrade a BIOS and the upgrade tool only works with Windows or DOS. Yes, I’m aware of flashrom, but the scary messages about toasting laptops means I’m much happier going the DOS route there. So I need a writable medium with a DOS boot image. The easy way to do it is to find a DOS floppy image and write that to a USB stick with dd, but it’s basically a one off and means you can’t fit a whole lot on the image. I wanted to do a native USB boot. The following did the trick for me.
Firstly, this is all on a Debian testing box, in particular with dosfstools (3.0.9-1), mbr (1.1.11-4) and syslinux (2:4.04+dfsg-2). I don’t think I’m using anything particularly new from these tools, so I suspect Debian stable will work just fine.
In the below my USB stick is on
/dev/sdb, I’ve got a copy of FreeDOS in
~/FreeDOS/ (I extracted the files from a
balder10.img floppy image that’s easy enough to find, but all you need is
command.com), and I wanted things neatly in their own subdirectories so I could try and keep the key for repeated use and know which bits I wanted to keep and which were transient. I also added a copy of the Debian Installer for convenience; it would need a copy of the netinst ISO dropped into the root to actually be useful, as there’s not enough to do a full netboot from the wider Internet using just the HD initrd.
# Create a single bootable LBA VFAT partition spanning entire stick.
echo 0,,C,* | sfdisk /dev/sdb
# Format as VFAT and give it a disk label.
mkfs.vfat -n 'DOS BOOT' /dev/sdb1
# Install an MBR
# Mount it and create some directories for our files.
mount /dev/sdb1 /media/DOS\ BOOT/
cd /media/DOS\ BOOT/
# Copy the chain.c32 syslinux tool over.
cp /usr/lib/syslinux/chain.c32 boot/syslinux/
# Copy FreeDOS over and move the important bits to /
cp ~/FreeDOS/* FreeDOS/
mv FreeDOS/command.com .
mv FreeDOS/autoexec.bat .
mv FreeDOS/fdconfig.sys .
# Add the Debian Installer
# Install syslinux
syslinux -d boot /dev/sdb1
I made a
boot/syslinux.help file containing:
Available boot options are: FreeDOS d-i
Initial testing was done using kvm which was a lot easier than constantly rebooting my laptop.
Hopefully this is of help to someone. The only neat bit that I didn’t see elsewhere when I was looking was the use of
chain.c32 to load
kernel.sys rather than having to use a FreeDOS provided boot sector image.