| « Open Source CD Recording in Windows | Mounting Floppy Disk Images in Windows » |
USB flash drives also called USB keys, pen drives and an assortment of other names can make quite handy reusable boot disks. Today I found myself in need of a DOS boot disk to upgrade the firmware on some hard drives and CD/DVD drives but didn't want to burn a bunch of bootable CDs or try to find a USB floppy disk drive. I remembered that most newer BIOSs including the one on this system support booting from USB drives so I thought I would investigate that as an option. Unfortunately I found that, being an afterthought, boot support is not an easy thing to do and presents several challenges.
First and foremost is that while there is some information on how to accomplish this on the Internet, there is comparatively little and what information does exist is not as clear or definitive as would be useful. Secondly, there are a number of different methods and tools for accomplishing this and not all methods work with all BIOS implementations of bootable USB. For example, USB flash drives may be booted as fixed disks, floppy drives or USB-Zip drives each of which requires different methods of preparation and the requisite support in the BIOS. Both of the methods I will describe hear treat the flash drive as a fixed disk which seems to be the best method if your BIOS supports it and appears to be becoming the standard for new BIOSs. While these methods are based on readings of other guides and howtos I was unable to find something as simple as I describe here so this method was developed on my own though research based trial and error (and lots of reboots) over the better course of a day.
In its simplest description booting from a flash drive as a fixed disk works almost exactly like booting from a hard disk does. The BIOS invokes the boot sector and master boot record (MBR) on the flash drive which loads the operating system kernel. It would initially seem that it should be no problem to make this work, after all DOS based operating systems worked this way for years. The trick is getting the boot sector and MBR on the flash drive. In ye old DOS days when you wanted to install DOS from a floppy disk onto a fixed disk it was common to invoke the FDISK and SYS commands to create a MBR, boot sector and copy the required system files. The problem is that in most cases the USB flash drive is being prepared from within a recent copy of Windows such as Windows XP which no longer has these commands available for this use. On the other hand if you booted DOS from a floppy disk or bootable CD and had access to FDISK and SYS you would not (normally, without drivers) have access to the USB flash drive to install the files.
After reading the information that was available on the Internet I determined it would be reasonably easy to create a bootable DOS USB flash drive in Linux and possible, yet convoluted and confusing to do so from Windows. I wanted to avoid requiring the use of Linux because the average user of such a drive may not have access readily available to a Linux system. Most of the solutions for creating the drive in Windows either used a creation utility from HP (questionable availability and suitability) or a slew of command line utilities and requiring a floppy drive (or emulator) which seemed like an unnecessary and complicated hack to me. The solutions I present may require you to download a few software packages from the Internet but each only requires one command line utility and should be fairly straightforward. As an added bonus all of the software is free and open source.
Note that these methods were specifically designed for installing FreeDOS, an open source DOS. Similar methods may work for installing MS-DOS, DRDOS or other DOSs; however you will need to obtain the boot sector (probably either from source or via extraction from a floppy disk or disk image) and system files specific to your version of DOS. I recommend using FreeDOS whenever possible as it is generally compatible and provides many additional features not found in vintage DOSs.
The first method described is the FreeDOS direct booting method. The advantages of this method are that the drive boots directly into FreeDOS and requires no files on the flash drive root other than the FreeDOS system files (kernel.sys and command.com). The disadvantage is that you must download an additional software package and FreeDOS is the only OS you may boot from the flash drive.
The second method is the SYSLINUX chained booting method. Advantages to this method include more configuration and customization options and the ability to boot floppy disk images and/or other OSs from the same flash drive using a boot loader menu and chained boot loading. None of these enhancements are covered here, this document will only help you get FreeDOS up and running, for information on booting other OSs from the same drive see the SYSLINUX documentation. The disadvantages of this method include three additional files in the flash drive root (can be moved into other directories, see SYSLINUX documentation) and a slightly more complicated (though transparently so) boot process.
Follow up:
Instructions for the FreeDOS direct boot method:
Where F is the drive letter assigned to your flash drive. Note that some BIOSs do not support booting from FAT32, in these cases you can run through this procedure again substitutingFORMAT F: /fs:FAT32
instead.FORMAT F: /fs:FAT
Note that you may be able to read the makebootfat documentation and change the "-o usb" option to install FreeDOS while other USB drives are attached to the system but that is beyond the scope of this document.makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin root
FreeDOS should now be installed on the USB flash drive and with the BIOS set to boot from a USB flash drive you should be able to boot into a working FreeDOS environment. Other applications, FreeDOS programs and configurations files may be added to the environment simply by copying them onto the flash drive as you would normally do. As long as the command.com and kernel.sys files are in the root of the drive and the MBR and boot sector are not rewritten the drive should remain bootable.
Instructions for the SYSLINUX chained booting method:
Where F is the drive letter assigned to your flash drive. Note that some BIOSs do not support booting from FAT32, in these cases you can run through this procedure again substitutingFORMAT F: /fs:FAT32
instead.FORMAT F: /fs:FAT
Later on you can add and expand this file to include other operating systems and options for booting. Save and close the file.timeout 1
default fdos
prompt 0label fdos
BSS fat32lba.bss
append -
Where F is the drive letter assigned to your flash drive.syslinux -ma F:
FreeDOS and the SYSLINUX boot agent should now be installed on the USB flash drive and with the BIOS set to boot from a USB flash drive you should be able to boot into a working FreeDOS environment. Other applications, FreeDOS programs and configurations files may be added to the environment simply by copying them onto the flash drive as you would normally do. As long as the command.com, kernel.sys, syslinux.cfg, ldlinux.sys and fat32lba.bss files are in the root of the drive and the MBR and boot sector are not rewritten the drive should remain bootable.
Regardless of the method you may notice a warning during the FreeDOS boot process "Warning: using suspect partition ... with calculated values ... instead of ..." My understanding is that this comes from the flash drive not having the cylinders, heads and sectors (CHS) drive geometry expected from a fixed disk by FreeDOS though it has caused no problems for me and FreeDOS works as expected.
This post has 2 feedbacks awaiting moderation...