Header Shadow Image

Create DOS Bootable Flash or CD Disk in Linux

Here we will go over the steps of creating a DOS bootable flash disk for use for updating firmware on controllers and on motherboards.  Keep in mind for UEFI installed systems, the preference is to use UEFI USB flash disks that is out of scope of this post.  We will do this by demonstrating two methods.

WARNING: Ensure that the device you use, /dev/sdX or in this case /dev/sdj is an empty USB flash disk or at least has data that you do not care about.  Also find a folder under which you can do all of this.


For this method, we will use the help of virtualization to create one:

  • Get a flash disk and connect it to a USB port of your Linux system.
  • Mount it on Linux after connecting it.  In our case it will be /dev/sdX . 
  • First, zero out the disk to DESTROY or OBLITERATE anything that's there: dd if=/dev/zero of=/dev/sdX
  • Download a freedos /fdos ISO or any DOS mountable ISO or image you can find. (We won't be modifying this image.)
  • Check if the image is truly bootable by getting the MBR record of the image using dd if=dos.image of=mbr.dat count=1 bs=512 then run the mbr.dat through xxd like this: cat mbr.txt | xxd .  Output at the end similar to this should appear ending with bytes 55aa ( End of MBR mark in DOS / FAT . ):






    00001a0: 4e6f 6e2d 5379 7374 656d 2064 6973 6b20  Non-System disk
    00001b0: 6f72 2064 6973 6b20 6572 726f 720d 0a52  or disk error..R
    00001c0: 6570 6c61 6365 2061 6e64 2070 7265 7373  eplace and press
    00001d0: 2061 6e79 206b 6579 2077 6865 6e20 7265   any key when re
    00001e0: 6164 790d 0a00 494f 2020 2020 2020 5359  ady…IO      SY
    00001f0: 534d 5344 4f53 2020 2053 5953 0000 55aa  SMSDOS   SYS..U.


  • Next install either VMWare player (free) or Bochs .
  • Create a VM similar to the following image below mounting the above DOS image / floppy disk as the VM Machine Floppy disk.  






    DOS Boot Floppy Setup Image


  • Next, add the USB as a physical disk to the virtual machine you created above.  Be careful here, ensure the device really maps to your USB Flash Disk.  If you pick a drive you care about, you'll loose the data on it.






    Verify Disk Selected:

    [root@mbpc-pc by-id]# pwd
    [root@mbpc-pc by-id]# ls -altri|grep Generic_Flash_Disk_E122D517
    432971 lrwxrwxrwx. 1 root root   10 Feb 18 01:56 usb-Generic_Flash_Disk_E122D517-0:0-part1 -> ../../sdl1
    432937 lrwxrwxrwx. 1 root root    9 Feb 18 01:56 usb-Generic_Flash_Disk_E122D517-0:0 -> ../../sdl
    [root@mbpc-pc by-id]#

    udevadm info –query=all –name=/dev/sdl  

    Options are: 

    IDE (recommended)
    Use Physical Disk (For Advanced Users)
    Use Entire Disk

    DOS Physical Disk Mapping


  • Boot up the machine and put on your DOS hat.   ( For those of you who never worked with DOS, this is gonig to feel old and possibly overly simplistic. )  You will be on the virtual floppy disk: A:\>
  • Run fdisk and follow the onscreen instructions to create a primary partition on the available virtual physical disk ( This disk is your flash disk you connected above.  cool  )
  • Once done with above, exit to the A:\> prompt then type format c: /s followed by fdisk /MBR .  Remember, you need to run fdisk /mbr ON the disk you want to fix for booting, in this case you need to run it on C:\>.  Can also use sys c: to do the same as above but you would still need to run format c: before that.  Once you format the disk and a basic boot image is created via /s option of sys c: command, copy all the files off the A:\> attached DOS floppy disk to C:\> using A:\> copy *.* c:
  •  You now have a bootable flash disk.  But before you celebrate, we have to test this image out.  Shutdown the virtual machine and go back to the Linux prompt and your work folder.
  • Here you can either remove the floppy disk from the virtual machine you created then booting up the virtual machine just off the hard disk that's really your flash disk, by selecting the physcial device again, or you could get the image off the flash disk then attaching it as the floppy disk to your virtual machine in vmplayer.  In either case, your new image should now boot up. (If it doesn't, either post below or repeat the above steps. )
  • (Optional) Run dd if=/dev/sdX of=newdosdisk.img  then run dd if=/dev/sdX1 of=newdosdisk-partition.img .  Why two?  Because you will be able to use the second as a floppy disk to VMWare and the first will NOT boot as an image but when written to the USB Flash Disk directly, it WILL boot if it is on a physical device.  Haven't been able to figure that piece out but that's how it works.  
  • Mounting the newdosdisk.img above using mount -o loop newdoskdisk.img ./mnt can result in this error, which is fine but does not indicate the image is bad in anyway:






    mount: you must specify the filesystem type

    and if you try to specify the filesystem type option with -t vfat etc. you'll get this:

    mount: wrong fs type, bad option, bad superblock on /dev/loop0,
           missing codepage or helper program, or other error
           In some cases useful info is found in syslog – try
           dmesg | tail  or so

    This is all fine and does not indicate your image is bad in anyway.  Read on for how to mount it under Linux. 

  • To properly check the image, use the following commands:

[root@mbpc-pc dosdisks]# losetup /dev/loop1 ./newdosdisk.img
[root@mbpc-pc dosdisks]# mdadm
build level=0 force raid-devices=1 /dev/md1 /dev/loop1
mdadm: array /dev/md1 built and started.
[root@mbpc-pc dosdisks]# mount /dev/md1p1 mnt
[root@mbpc-pc dosdisks]# cd mnt
[root@mbpc-pc mnt]# ls
[root@mbpc-pc mnt]#

  •  Cleanup the above devices when done so you do not leave them hanging around for unsuspecting victims ( or for you )


    umount mnt
    mdadm –stop /dev/md1

    losetup -d /dev/loop1

    Use dd if=newdosdisk.img of=/dev/sdX to write the image to your USB Flash Disk then mount it for copying your firmware drivers to it.  Alternately, remount the image using the previous 4-5 steps then copy to the same image, and subsequently your USB Flash Disk.  The choice is yours.  If you get an IO error, try something like this:

    dd if=qlogic-newdosdisk.img of=/dev/sdh bs=5M count=20


Here are a few additions and commands that can help you with creating a bootable DVD or CD or USB Flash Disk.

  • If you wish to write your image to a CD as a bootable CD / DVD bootable image, use the below command. (The below was tested with FreeDOS. )

mkisofs -o ../freedos-biosupdate.iso -q -l -N -boot-info-table -iso-level 4 -no-emul-boot -b isolinux/isolinux.bin -publisher "FreeDOS – www.freedos.org" -A "FreeDOS Firmware Image" -V FDOS_BETA9 -v .

  • Write the image to the USB disk using:

dd if=../freedos-biosupdate.iso of=/dev/sdX

  • Or write the image to a CD / DVD using:

dd if=../freedos-biosupdate.iso of=/dev/cdrom1
dd if=../
freedos-biosupdate.iso of=/dev//dev/cdrw4

A few sources / credits to tap into as you work to creating a bootable USB / CD image.


Loop mounting partitions from a disk image:


If you are pressed for time or just want a writable / bootable 125MB USB Flash Disk for firmware upgrades / updates that's big enough for your firmware but not too big that it can't fit on most USB Flash disks, use the link below to download the one I created using the steps above.  Both of the below disks will decompress to approximately 125MB:

100 MB USB Flash Disk Image (DOS 6.22)
100 MB USB Flash Disk Image (DOS 6.22 Partition)  ( Partition Only for use in Virtual Emulators as virtual removable disk like a floppy. )


Leave a Reply

You must be logged in to post a comment.

  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License