From FreeDOS
Jump to: navigation, search

This article describes how to create a USB boot "disk" using FreeDOS. A DOS bootable USB stick still comes in handy for various maintenance tasks, but creating a DOS bootable USB "disk" is not always very straightforward. Hopefully this will help.

Partition the USB stick


If using Windows, your USB stick is mounted as something like E:. All operations must be performed as Administrator (right click, Run as Administrator) using Windows Vista, or Windows Server 2008. The Windows Preinstallation Environment (WinPE) 2.x should also work, for those that need it.


Then enter the following diskpart commands:

list disk
select disk {disk number}
create partition primary
select partition 1
format fs=fat32


Linux uses the /dev meta-filesystem to list devices, so the USB disk may be something like /dev/sdb. You can use parted to prepare the boot disk on this device:

[root@roque ~]# parted /dev/sdb mklabel msdos
 Warning: The existing disk label on /dev/sdb will be destroyed and all data on
 this disk will be lost. Do you want to continue?

 Yes/No? yes
 New disk label type?  [msdos]?
 Information: Don't forget to update /etc/fstab, if necessary.

[root@roque ~]# parted /dev/sdb print
 Model: FlashDis Flash Disk (scsi)
 Disk /dev/sdb: 65.5MB
 Sector size (logical/physical): 512B/512B
 Partition Table: msdos

 Number  Start  End  Size  Type  File system  Flags

 Information: Don't forget to update /etc/fstab, if necessary.

[root@roque ~]# parted /dev/sdb mkpart primary fat16 0 64MB
[root@roque ~]# parted /dev/sdb toggle 1 boot

Depending on the size of your USB stick, you may need to replace fat16 by fat32, to use larger partition sizes.

If you see an error message like Partition Table: loop then be careful since it doesn't support the "bootable" flag. To fix, you will need to run mklabel to change the label to msdos, then make a partition.

Install a boot loader


It is probably easiest to use SYSLINUX. To do so, simply download and extract the archive. Let's say you put it in C:\syslinux, and your USB stick is E:. Change to the location where you extracted SYSLINUX, and run it:

cd /d C:\syslinux\win32
syslinux.exe -fma E:

Create a new file E:\SYSLINUX.CFG as follows:

prompt 1
ontimeout q
default f32
timeout 1200

label f32
  kernel fat32lba.bss
  append -

# cancel and try next boot device
label q
  localboot −1
        kernel /memdisk
        initrd /fdodin06.144

Copy the boot files from the FreeDOS "full" CD-ROM image (fdfullcd.iso) to your USB stick. In the following, assume the CD-ROM drive is mounted as D:.

md E:\ODIN

Extract source\ukernel\boot\fat32lba.bin from D:\FREEDOS\PACKAGES\SRC_BASE\KERNELS.ZIP to the root of your USB drive and rename it to fat32lba.bss


Under Linux, you can install the bootloader using SYSLINUX or GRUB; I tried GRUB, with some help from a SYSLINUX file (memdisk.) To use GRUB, mount the USB stick (for example, as /mnt), then create the grub.conf configuration file:

# mount /dev/sdb1 /mnt
# cp -r /boot/grub /mnt
# cp /usr/lib/syslinux/memdisk /mnt
# cd /mnt/grub
# echo '(hd0)     /dev/sda' >
# cat <<EOF > grub.conf
title FreeDOS
        kernel /memdisk
        initrd /fdodin06.144

Do this to install a small FreeDOS "ODIN" image to the USB stick:

# cd ..
# wget -c
# unzip fdodin06.144 
   inflating: fdodin06.144

To install GRUB into the MBR (master boot record), enter these commands into GRUB:

grub> find /grub/stage1
 find /grub/stage1

Note there's two entries listed here, and you'll probably see the same; that's quite normal. The first one (0,0) is from /dev/sda, the main hard disk. You'll have to go to the correct partition (1,0):

grub> root (hd1,0)
 root (hd1,0)
  Filesystem type is fat, partition type 0xe
grub> setup (hd1)
 setup (hd1)
  Checking if “/boot/grub/stage1″ exists… no
  Checking if “/grub/stage1″ exists… yes
  Checking if “/grub/stage2″ exists… yes
  Checking if “/grub/fat_stage1_5″ exists… yes
  Running “embed /grub/fat_stage1_5 (hd1)”… failed (this is not fatal)
  Running “embed /grub/fat_stage1_5 (hd1,0)”… failed (this is not fatal)
  Running “install /grub/stage1 (hd1) /grub/stage2 p /grub/grub.conf “… succeeded

Boot and test

Your USB key should now boot directly into FreeDOS. You can modify the contents of the USB stick directly as you like.