Create a FreeDOS bootable USB flash drive

titorick

Geek
Pinoy Techie
First I'd like to point out why this may be useful; I needed a working DOS system to use many hardware manufacturers' firmware flash and diagnostic tools but all their pre-built utilities were for Windows only - using this method I was able to use a pure Linux environment to create my DOS boot disk. Additionally I ran into many howtos that were incomplete or simply did not produce working results; the following is what has worked for me as of 20140831.

Before getting started, make sure you have syslinux, parted, and dosfstools installed.

Partition and format your USB flash drive which will be assumed to be /dev/sdb throughout this guide:
~$fdisk /dev/sdb

press 'o' for new DOS partition table.

then 'n' for new partition, press Enter to accept the defaults until you return to the main prompt.

Finally press 'w' t owrite the changes and exit fdisk.

Create a new FAT32 file system on the freshly created partition:
~$ mkdosfs /dev/sdb1

Use Parted to set the boot and lba flags:
~$ parted /dev/sdb
(parted) set 1 boot on
(parted) set 1 lba on
quit


Grab a copy of FreeDOS 1.1, the installer with out live CD will do just fine:
http://www.freedos.org/download/

Mount the installer and the USB flash drive:
~$ mkdir /mnt/{freedos,usb}
~$ mount -o loop,ro/fd11src.iso /mnt/freedos
~$ mount /dev/sdb1 /mnt/usb

Decompress and extract a base install of FreeDOS:

NOTE: it is important that you create the directory “fdos”, do not try to replace it with another name as FreeDOS has hardcoded this path in several critical configuration files without pulling from a variable instead.

~$ mkdir /mnt/usb/fdos
~$ unzip /mnt/freedos/freedos/packages/boot/syslnxx.zip -d /mnt/usb/fdos
~$ find /mnt/freedos/freedos/packages/base/*.zip | xargs -l unzip -d /mnt/usb/fdos

Adjust DOS config:

There should be an autoexec.txt and a config.txt located under /mnt/usb/ go ahead and adjust the file extensions to .bat and .sys respectively.

We need to install and configure syslinux to get a bootable USB flash drive:
~$ syslinux -i/dev/sdb1

This will add some additional boot code to the MBR:
~$ dd conv=notrunc bs=440 count=1 if=/usr/share/syslinux/mbr.bin of=/dev/sdb

Lastly, create a file on the root of /dev/sdb1 called: syslinux.cfg

Here is a barebones config to get you started but you can expand to include a lot of other stuff:

default freedos
prompt 1
timeout 10

label freedos
menu label freedos
com32 /fdos/bin/chain.c32
append freedos=/fdos/bin/kernel.sys

At this point you can add whatever DOS applications you like - including firmware flashing utilities - to the fdos/bin/ directory and you'll be able to call them once you're booted into FreeDOS. A great way to get around Windows centric utilities.

On some systems I would run into an issue where I would receive the following error:

Bad or missing Command Interpreter: command.com /P /E:256

Enter the full shell command line:
I'm not entirely sure what is breaking down here; I surmise there is a configuration tweak that is needed in either autoexec.bat or config.sys but for now the workaround I've been using is simply to enter the full path to command.com as such:
C:\fdos\bin\command.com /P /E:256
 

Similar threads


Latest posts

Top Bottom