[syslinux] how to create bootable FreeDOS HDD or USB flash drive?

Martin T m4rtntns at gmail.com
Mon Jun 25 16:44:09 PDT 2012


Hello,

there is a "fdboot.img" floppy drive image included with FreeDOS ISO
file. It's a floppy image file:

root at debian64:~# file -s /home/martin/FreeDOS/isolinux/fdboot.img
/home/martin/FreeDOS/isolinux/fdboot.img: x86 boot sector, FREE-DOS
BEta 0.9 Bootloader KERNEL.SYS, code offset 0x40, OEM-ID "FreeDOS ",
sectors/cluster 2, root entries 112, sectors 720 (volumes <=32 MB) ,
Media descriptor 0xfd, sectors/FAT 2, serial number 0x1ce95c55,
unlabeled, FAT (12 bit)
root at debian64:~#

One can boot to DOS prompt with this floppy image. For example "qemu
-fda /home/martin/FreeDOS/isolinux/fdboot.img -boot a -m 128m" allows
one to access content of this floppy image:
http://i.imgur.com/8Vtic.png

I would like to add few files(few 128KB ones and one 2MB one) to this
image file. What I did:

1) Created 10MB raw file:

root at debian64:~# dd if=/dev/zero of=10MB bs=10M count=1
1+0 records in
1+0 records out
10485760 bytes (10 MB) copied, 0,02243 s, 467 MB/s
root at debian64:~#

2) Created partition table to MBR using fdisk. Results are following:

root at debian64:~# fdisk -lu 10MB
You must set cylinders.
You can do this from the extra functions menu.

Disk 10MB: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x3009589f

Device Boot      Start         End      Blocks   Id  System
 10MB1   *           1     1606499      803249+   6  FAT16
root at debian64:~#


3) Mounted this 10MB file with 32256 offset:

root at debian64:~# echo 63*512 | bc -l
32256
root at debian64:~# losetup --offset 32256 /dev/loop1 10MB
root at debian64:~#

4) Created FAT16 file system:

root at debian64:~# mkdosfs -F 16 -v /dev/loop1
mkdosfs 3.0.9 (31 Jan 2010)
Loop device does not match a floppy size, using default hd params
/dev/loop1 has 64 heads and 32 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 20416 sectors;
file system has 2 16-bit FATs and 4 sectors per cluster.
FAT size is 20 sectors, and provides 5085 clusters.
There are 4 reserved sectors.
Root directory contains 512 slots and uses 32 sectors.
Volume ID is e2c98373, no volume label.
root at debian64:~#

5) Umounted 10MB image:

root at debian64:~# losetup -d /dev/loop1
root at debian64:~#

6) Copied MBR boot code to 10MB disk image:

root at debian64:~# dd if=/usr/lib/syslinux/mbr.bin of=10MB bs=1
count=440 conv=notrunc
440+0 records in
440+0 records out
440 bytes (440 B) copied, 0,000622907 s, 706 kB/s
root at debian64:~# file -s 10MB
10MB: x86 boot sector; partition 1: ID=0x6, active, starthead 0,
startsector 1, 1606499 sectors, code offset 0x31
root at debian64:~#


7) Installed syslinux to 10MB1 partition(that is the reason I used
32256 byte offset):

root at debian64:~# syslinux --install --offset 32256 10MB
root at debian64:~#

8) Mounted this 10MB1 partition:

root at debian64:~# mount 10MB /media/10MBfiledir/ -o loop,offset=32256
root at debian64:~#

9) Copied files from fdboot.img floppy image and few additional ones:

root at debian64:~# ls /media/10MBfiledir/
atiflash.exe  CHOICE.EXE   DEVLOAD.COM	ELTORITO.SYS  FDCONFIG.SYS
fdisk.ini	 HD5870.rom  KERNEL.SYS   MDISKCHK.COM	SHSUCDX.COM
UIDE.SYS	 USB2	       XMSSIZE.COM
AUTOEXEC.BAT  COMMAND.COM  EDIT.EXE	FDAPM.COM     FDISK.EXE
GETARGS.COM  jemmex.exe  ldlinux.sys  SHSUCDHD.EXE	TDSK.EXE
UPDATE.BAT  vmsmount.exe
root at debian64:~#

10) Unmounted 10MB image:

root at debian64:~# umount /media/10MBfiledir
root at debian64:~#


As much as I understand, everything is done- 440 byte boot code in MBR
is present, partition table in MBR is present, syslinux is installed
to first partition, FAT16 file system is created to first partition
and finally all the files from floppy image are copied to this 10MB
image. However, I'm not able to boot into DOS with qemu. If I execute
qemu with "qemu -hda 10MB -boot c -m 128m" I end up with:

Booting from Hard Disk...
Missing Operating System.
No bootable device.

Image as well: http://i.imgur.com/G45gj.png


Any suggestion what am I doing wrong?

regards,
martin



More information about the Syslinux mailing list