Booting DOS from a USB flash drive

**UPDATE 2014/02/21: Times have changed and you might want to check out the Rufus utility I mention here as an alternative to these technical instructions.**

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.

Instructions for the FreeDOS direct boot method:

  1. Download and extract the makebootfat and SYSLINUX software packages.
  2. Download and extract (or burn the CD image) a copy of the FreeDOS system (such as the “fdbasews” cd image) which includes the kernel source code.
  3. Create a working directory on your system which you can use to assemble all the files needed. You’ll also need a subdirectory called “root” which will become the root of your flash drive.
  4. Copy the “makebootfat.exe” file from the makebootfat package into your working directory.
  5. Copy the “mbr.bin” file from the “mbr” subdirectory of the SYSLINUX program into your working directory. Note that there is a MBR file which comes with makebootfat but in my experience that file did not work correctly.
  6. From the FreeDOS kernel source code package (if using the fdbasews distribution this is in “FREEDOSPACKAGESSRC_BASEKERNELS.ZIP” file) copy the “fat12.bin”, “fat16.bin” and “fat32lba.bin” files into your working directory. Rename each of these three files so the extension is .bss instead of .bin
  7. From the FreeDOS distribution copy at least the “command.com” and “kernel.sys” files (may be found in “FREEDOSSETUPODIN”) into the “root” directory under your working directory. You can include other files from FreeDOS or DOS applications here now or copy them directly to the USB drive at a later time.
  8. Format your flash drive from the command line:

    FORMAT F: /fs:FAT32

    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 substituting

    FORMAT F: /fs:FAT

    instead.

  9. Remove all other USB drives (hard drives as well as other flash drives) from the computer. Failure to do so may cause them to be damaged as FreeDOS is installed to them instead. Then run the makebootfat program from a command line inside of your working directory.

    makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin root

    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.

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:

  1. Download and extract the SYSLINUX software package.
  2. Download and extract (or burn the CD image) a copy of the FreeDOS system (such as the “fdbasews” cd image) which includes the kernel source code.
  3. Create a working directory on your system which you can use to assemble all the files needed. You’ll also need a subdirectory called “root” which will become the root of your flash drive.
  4. Copy the “syslinux.exe” file from the “win32” folder of the SYSLINUX package into your working directory.
  5. Format your flash drive from the command line:

    FORMAT F: /fs:FAT32

    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 substituting

    FORMAT F: /fs:FAT

    instead.

  6. From the FreeDOS kernel source code package (if using the fdbasews distribution this is in “FREEDOSPACKAGESSRC_BASEKERNELS.ZIP” file) copy the “fat32lba.bin” file into the “root” directory under your working directory. Rename each of this file so the extension is .bss instead of .bin Note that if you have formatted the flash drive as FAT instead of FAT32 you’ll need the “fat16.bin” file instead of the “fat32lba.bin” file and rename it with the .bss extension. You will also need to substitute fat16.bss for fat32lba.bss in the “syslinux.cfg” file created below.
  7. From the FreeDOS distribution copy at least the “command.com” and “kernel.sys” files (may be found in “FREEDOSSETUPODIN”) into the “root” directory under your working directory. You can include other files from FreeDOS or DOS applications here now or copy them directly to the USB drive at a later time.
  8. Create a text file in the “root” folder under your working directory called “syslinux.cfg”. The file must contain:

    timeout 1
    default fdos
    prompt 0label fdos
    BSS fat32lba.bss
    append –

    Later on you can add and expand this file to include other operating systems and options for booting. Save and close the file.

  9. Run the syslinux program from a command line inside of your working directory.

    syslinux -ma F:

    Where F is the drive letter assigned to your flash drive.

  10. Copy the files from the “root” folder under your working directory to the root of your flash drive.

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.

34 Comments.

  1. Hi.
    This guide have I been locking for some time now. Now I have linux and FreeDos to boot from the same USB pen :).

  2. It’s a good way to to boot this way from a USB drive. I have linked to this post of yours you may visit my blog and comment on it.

  3. Great Guide —

    Unfortunately, I when I try to boot from my 128 MB USB key, I get past the SYSLINUX Copyright message, and past the disk warnings, but it dies suggesting it can’t find command.com. Any ideas? Thanks!

    FYI – here is text of the messages I receive:

    SYSLINUX 3.51 2007-06-10 EBIOS …

    (copyright message)

    – InitDisk WARNING: using suspect partition Pri: 1 FS 0b: with calculated values 0-1-32 instead of 0-1-1
    WARNING: using suspect partition Pri:1 FS 0b: with calculated values 941-2-15 instead of 14-254-63
    C: HD1, Pri[ 1], CHS= 0-1-32, start 0 MB size= 117 MB
    Bad or missing Command Interpreter: command.com /P /E:256
    Enter the full shell command line:

  4. John, I don’t know that I have a good answer for you other than to say that USB sticks (and USB in general) were not well designed for booting and in some cases certain combinations of sticks and motherboards do not seem to work. I would suggest trying the stick in a different computer and trying a different stick in both that computer and another to see if you can locate a specific piece of hardware that is causing the problem in this case.

  5. First, THANK YOU. This was the guide I needed to get my FreeDOS USB stick working.

    I had some modifications to the “direct boot” method that I amended to the freedos wiki page that links here. Hopefully repeating the text here will do some good for a future user of the guide:

    The above link and instructions are wonderful. Following the “direct boot” method I was able to (finally) get a bootable FreeDOS USB flash drive. I have three modifications to the instructions though. First, step 8 is not required (I have no FORMAT command executable from BASH anyway) and is somewhat confusing. Step 9 destroys anything done in step 8 as far as I can see. Second, makebootfat can be downloaded from its project page here:
    http://advancemame.sourceforge.net/boot-download.html
    (my APT repository didn’t have it). The commands for building it were:
    tar -xvf makebootfat-1.4.tar.gz
    cd makebootfat-1.4
    ./configure
    make
    make install
    Third, consider this step 10: Copy the contents of freedossetupodin to the root of the USB disk. You may also want to create your config.sys and autoexec.bat files before booting to the USB.

  6. I had only 1 problem renaming the .bin file to .bss HOW DO YOU DO IT!!!!!! im practically gone crazy

  7. Hello and thanks very muh for this article. I have been trying for many hours now to get a USB thumbdrive to boot. Supermicro provided a utility to flash a bios that (1) needs to write a log, so no chance of using a CD and (2) does not fit on a floppy drive.

    Anyhow, I followed your instructions to the letter for method 1. When I try to boot, the message:

    Loading FreeDOS

    appears in the upper left corner of my screen, and then thats as far as it gets.

    The BIOS does have support for booting from a USB key and the bios even seems to understand that there is a bootable USB device plugged in (when I do setup).

    Any ideas?

    Thanks very much…

    Jim

  8. Can the direct boot method be used with a linux kernel?

    I have an old 4GB flash drive that I would like to run linux from, but syslinux won’t work because it has a 2048 sector size. Do you know if the direct boot method will work in this case? Thanks for the help.

    Steve

  9. Thanks for the excellent description. I used “SYSLINUX chained booting method” which works great to boot using FreeDOS.

    The USB pen drive boots as drive C:

    Is there a way to boot using a USB pen drive such that it appears as a floppy drive A: ?

    Thanks very much!
    The reason is to be able to configure a “virgin” PC.

  10. Vern,
    My understanding is that this would require special support from the BIOS and might be called something like floppy drive emulation (something similar can be done with CD-ROMS). There are problems with this, most notably operating systems such as DOS (which I assume is what you would be using as you are mentioning A: which is a DOS convention) are often limited to 1.44MB or 2.88MB in floppy emulation mode. This means that even if your drive was 2GB or even 64MB (or 650MB in the case of CD-ROM discs) the floppy emulation partition could only be 1.44MB which severely limits the usefulness of doing this. I understand you may have a special situation which you want to emulate a floppy for but in general it is much more useful to emulate a hard drive.

    In fact, you might be better served with a CD-ROM and floppy emulation mode which is well supported by systems if this is what you want to do. Note this suffers from the size limit as well. Much effort actually goes into creating bootable CD-ROMs which act like hard drives instead of floppies which then must load a CD-ROM driver so it’s generally seen as beneficial that the USB drives can act like hard drives instead.

    -Ben

  11. I’ve tried a few times booting from USB flash drive. Unfortunately, I wasn’t successful. Dunno what I am doing wrong. 🙁

  12. I have found some really useful information and simple tutorials on booting from a pendrive at http://www.pendrivelinux.com

    Hope this helps!

  13. Search Google for SP27608, which is the HP USB Disk Storage Format Tool, v2.1.8. It makes the process of formatting the pen drive and moving DOS boot files to the pen drive a breeze. And it’s free.

    No links provided since they move stuff around so much, but my search for “SP27608” turned up 3 pages of hits.

  14. I had the exact same thing as Jim. Boots up with “Loading FreeDOS” and thats as far as I got, unless it takes more than 5 minutes and I was just being impatient of course….

    cheers
    Hayden

  15. Thx alot this guide worked for me. I have been strugling with this usb booting for many hours now.
    Again Thank you very much.

  16. I folowed the steps for freedos and copy kernel.sys and command.com into the stick. When try to boot it displys Loading FreeDos and hang. Does this mean the kernel not found? Because it hapend when i installed freedos on a partition located on another hard disk (slave D) the bootstrap loader tries to boot the kernel from the first disk (master C) so I had to put the kernel.sys and fdconfig.sys in drive C to get it to work. How can I configure the bootstrap loader to find the kernel in the usb stick partiton instead of locking for it somewhere else? Thanks.

    Regards

    rbash walker

  17. Search HP.com for SP38418, which contains the HP USB Disk Storage Format Tool, v2.2.2, a newer version than mentioned above.

  18. oh yeah? you think your rant is better than mine? well I’m gonna have to start ranting more often.

    Hey, maybe you can help me out with something. I got my usb to boot multiple OS from 1 linux loader and syslinux.cfg (some recommendations online are waste of time they tell you to use grub4dos which is basically launching a menu just to run a menu to get to the actual os) it launches Ubuntu, Fedora, Acronis, Memtest, DSL

    Prob is when i choose to launch Acronis at first I get error msg “err 8” in some weird ascii box with “data” on left column and “program” on right column” and then I press “Enter” and it starts up anyway and does perfectly fine.

    Here’s how I created acronis boot.
    I used Acronis software’s menu to create usb boot disk. then I copied those files to the usb which I wanted to launch it from and also created .bss file (512 bytes for bootsector) from the original acronis installed usb. and in the syslinux.cfg I added “BSS acronis.bss” to tell syslinux to use the bootsector file to launch acronis which obviously works but I can’t figure out what that err is or how I can tell syslinux to continue on error

  19. never mind. figured out the problem.

    it’s the weird funky thing Ubuntu does when you run syslinux installer with it.

    It does something to the bootsector that makes it show error msg. I know that sounds weird but it really is ubuntu’s boot sector.

    when I tried using fedora to install bootsector I get no error msgs when I try to launch acronis from the syslinux.cfg.

  20. An other way to make a USB-FDD is with HxD http://mh-nexus.de/en/
    Hex edit a bootable FDD and copy all code to a also edited USB-flash drive and finito!
    Your USB of 1.4 MB is ready

  21. My BIOS does not support booting via usb 🙁 Is there any possibility to run freedos on usb?[for ex via floppy, and then from usb]

  22. what are the options 1, 2 , 3 you have provided in the makebootfile command for the three .bss files… that command doesnt seem to work. It gives the following msg.

    makebootfat -o /dev/sdb1 -E 255 -l fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin root
    Unknown option `?`
    makebootfat v1.4 by Andrea Mazzoleni
    Usage: makebootfat [options] dir

  23. Hello sir i want to install xp but my cd rom is bad and i dont have a floppy disk drive. i realy do not understand this part of your howto – “Then run the makebootfat program from a command line inside of your working directory.
    makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin root”

  24. Mat,
    go to start > run, type “cmd” (without quotes) and hit enter. this is the command line

    from here, access your working directory, and then run makebootfat by typing all that stuff in the guide (makebootfat -o usb etc)

    if you’re not sure how to use the command line google for some online guides – there are plenty

  25. Works! If you have faced the Loading FreeDOS problem it might be because you did include the mbr.bin.

  26. jayanta baishya

    how i make my pen drive bootable by using hp usb disk storage format tool show the step

  27. Matt Rosenthal

    I get the response:
    C:WD>makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr
    .bin root
    Error reading the file fat12.bss

    I’m stuck can you help?

    My working directory is WD with a sub
    directory of root

  28. Great tutotial. Worked first time out. My problem is I want to use Hiren’s boot disk with this usb bootable flash drive, but the autoexec.bat, config.sys and startup.bat files don’t work with this DOS application. I imagine they have to be converted in some way. Any IDEAS!!!!

    The Hankster

  29. Thank you very much for that wonderful and detailed guide! Its the best one i ever read to make bootable dos usb stick. After the first try i got “Loading FreeDos” and then its hang &((. As a solution i moved kernel.sys and command.com up to directory where makebootfat resides and changed “makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin root” into “makebootfat -o usb -E 255 -1 fat12.bss -2 fat16.bss -3 fat32lba.bss -m mbr.bin -c kernel.sys -c command.com -i -v root”. Now its work like a charm %))

  30. This works great! I have my USB on a dual menu option to either call an .exe to wipe out a hard drive or to begin a new image on a PC using Zenworks.
    Great info. / Thanks, Alex

  31. I installed the SYSLINUX chained booting method. Excellent guide. After spending a few days learning how to work with the syslinux.cfg file I managed to create my own custom boot menu. The syslinux step to make the drive bootable was the most valuable, since it opened the door for everything else. There was one step where the command line had to run as administrator, but everything else worked well. I don’t know why but command.com disappears when its copied into my usb’s root directory, but it’s still there (when I try to copy it again it says it’s replacing itself).

    Also, after the USB is made bootable, instead of putting all these other files on it you can copy the live files of other programs whose liveCDs boot using syslinux.cfg. For example I copied GParted’s live CD onto the USB and it worked just as well as if I were running their live CD (this could come in handy the next time I need to run a liveCD but don’t have a blank CD around!)

    An extremely useful site for making the syslinux cfg file is the syslinux website http://syslinux.zytor.com/wiki/index.php/SYSLINUX which describes many of the commands usable in syslinux.cfg, its biggest flaw for me was its lack of applied examples. To this end I’m copying my simple syslinux cfg file (The syslinux.cfg file from GPartedLIVE is similar but too long to post here)

    # See http://syslinux.zytor.com/wiki/index.php/SYSLINUX
    # for full descriptions. By Stephen Simms, 12/24/2009

    # Display Menu of boot options (menu of the label names)
    UI menu.c32

    # 30 seconds until default boot
    timeout 300
    prompt 0
    noescape 1
    allowoptions 1
    menu title Bootable Applications

    label FreeDOS
    menu default
    BSS fat32lba.bss
    text help
    Load freeDOS which runs DOS .exe files. Easy access to
    standard apps by typing “chdir freedossetupodin”.
    Full install with “setup” after load.
    endtext

    # mt400 is .bin file wo/extension
    label Memtest86+ 4.00
    kernel mt400
    text help
    Run memory test using Memtest86+ v4.00 (mt400)
    endtext

    label Custom file (press tab)
    kernel File_name_here
    text help
    Boot custom file, .bs, .bss, .c32, .cbt, and .com are
    supported [and .bin files wo/extension]
    endtext

  32. what i dont understand is i download fdbasews.iso and use magiciso to extract all the files. however there is no fat12.bin”, “fat16.bin” and “fat32lba.bin” files. when i goto “FREEDOSPACKAGESSRC_BASEKERNELS.ZIP”, there is no files, but there is 3 more folders labeled “doc”, “packages” and “source”. i have looked through out all three folders and even used the search option on the entire main folder and there are none of those three .bin files. i have downloaded the iso file many times and it is complete but yet these files are not in there.

  33. The easy way to do this:

    Clonezilla is a disk imaging linux distribution that uses syslinux and includes FreeDOS for ease of BIOS flashing. It’s very easy to install and it’s handy for making backups of your computer to a USB drive or network share.

    Download clonezilla from clonezilla.org. Format the pendrive FAT32 and copy all the files onto the root of the pen. From Windows open cmd.exe and change to utils/win32 and run makeboot.bat or from Linux terminal cd to utils/linux and run makeboot.sh to make the pen bootable. Copy the applications you want to use from DOS onto the pen.

    Boot the pen and select FreeDOS. A: will be the FreeDOS operating system image and C: will be the root of the pen.

    If you only want FreeDOS and not clonezilla, edit syslinux/syslinux.cfg so that it’s the only menu option and delete the excess files.

  34. Like Chris Merchant stated none of the FreeDOS iso files have those 3 fat bootsector bin/bss files in them. I’m trying to make an 8GB Corsair Flash Voyager into a multi standard usb bootable flash (USB-HDD-FDD-ZIP) but I can’t figure out what to use for the -b option. If I use the included mbrfat.bin with the -b option the drive formats, reads, writes correctly. However attempting to boot it on my Acer Aspire 1410 Core 2 Solo Netbook produces the msg “HDDno operating system” and the system doesn’t do anything after that.