e3cc
![]() |
|
|
|
|
|||||||
| Howtos & FAQs (Moderated) Would you like to share some of your solutions for certain problems? Tips or tricks? Post here. All new topics are automatically moderated. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
There are a number of guides online that show one how to create DOS bootable USB floppy disks, but these all follow the same theme:
The problem with that is that you're stuck with two things:
The other problem is that a lot of these guides are written for Windows. This one is for FreeBSD! I've had more than one occasion where a firmware update simply couldn't fit into 1.44 MB, even after deleting everything but io.sys, msdos.sys, and command.com. So I decided to figure out how to create a bootable DOS hard disk manually. One key difference between a hard disk and a floppy disk in this context is that the hard disk has an MBR and so can have multiple partitions - one for your bootable DOS image, another for the rest of your USB stick. The other difference is that hard disk partitions can be much larger than 1.44 MB. By setting up your USB stick like this you could even have multiple OSes installed with a boot manager to select between them, or just have a small DOS partition and another for your normal data. So the first thing you need to do is setup your MBR and partition table. There are some limitations with DOS in that its boot partition can't start beyond a certain offset on the disk. For simplicity I'll only be showing you how to set things up with your DOS partition at the beginning of the disk, but feel free to experiment. All commands assume your USB disk is at /dev/da0. Adjust accordingly. Before you begin you will need:
Step 1: Wipe your disk # dd if=/dev/zero of=/dev/da0 bs=1m count=2Step 2: Create MBR and partitions I'll be creating a 64 MB FAT16 partition. If you experiment with the size you might need to adjust the partition type. See here for a guide on partition types. I'm also using the basic, active partition chainloading boot manager at /boot/mbr, but you could try /boot/boot0 too. # gpart create -s MBR da0# gpart add -s 64m -t \!6 da0# gpart set -a active -i 1 da0# gpart bootcode -b /boot/mbr da0Results: Code:
# gpart show da0
=> 63 32014017 da0 MBR (15G)
63 131040 1 !6 [active] (64M)
131103 31882977 - free - (15G)
Decompress the attached bootsect.gz file: # gunzip bootsect.gzIt's important that you follow the next few steps precisely. Veering off from these instructions may cause the file system to be created incorrectly. Take note of the start offset of the partition you created above. In this example it is 63. Create the file system: # newfs_msdos -B /full/path/to/bootsect -o 63 /dev/da0s1You'll notice above the partition offset goes in the "-o" parameter. Make sure you specify a full path to the bootsect file or else newfs_msdos(8) will look in /boot. Mount your file system: # mount_msdosfs /dev/da0s1 /mntSetup system files root directory entries: # cd /mnt && touch IO.SYS MSDOS.SYS COMMAND.COMThe order of the files above and their uppercase names is crucial. Copy valid system files to your file system: # cp io.sys msdos.sys command.com /mnt/(I haven't shown you where/how to get the above system files on purpose - they could come from many sources...) Unmount: # umount /mntYou're done for now. You should be able to boot up with your USB stick now. More details coming... |
|
#2
|
|||
|
|||
|
This is just one example for obtaining the above DOS system files, but it's probably the easiest too.
Go to http://www.bootdisk.com/bootdisk.htm and look for the section labeled "Non-Windows Based Image Files". Download a DOS 6.22 image. This will likely be a Zip file, so extract it: $ mkdir /tmp/boot$ cd /tmp/boot$ tar xzf /path/to/zip/fileInside /tmp/boot you'll see a file that is approximately 1.4 MB in size. That's the image you're after. Mount it: # mkdir /tmp/dos# mount_msdosfs /dev/$(mdconfig -a -t vnode -f /path/to/image/file) /tmp/dosNow if you look in /tmp/dos you'll see all the DOS files that are in the image. The most important ones are io.sys, msdos.sys, and command.com mentioned in the previous post, but you might want to grab all the others too... especially since you have plenty of disk space now.
|
|
#3
|
|||
|
|||
|
The only minor annoyance left is to fix the volume label of your DOS partition. Unfortunately you can't specify one with "-L" to newfs_msdos(8) as that will cause it to create a root directory entry before the 3 system files. This will break bootability so the volume label has to be changed after creating your boot disk in post #1.
If anyone knows of a tool to rewrite volume labels in FreeBSD, please let us know. Otherwise the only option is to use a Windows box, sorry. ![]() Ok, so there's a half fix for those confident with a hex editor: # dd if=/dev/da0s1 of=/tmp/bs bs=512 count=1Open /tmp/bs in your hex editor and modify offsets 0x2B to 0x35 inclusive (11 bytes). For labels less than 11 characters, use spaces as padding (0x20). Save your changes and then: # dd if=/tmp/bs of=/dev/da0s1 bs=512 count=1This is a half fix because it doesn't create a volume label entry in the root directory structure further down in the file system. Some systems only bother to read the volume label from the boot sector though. If you're really obsessed you could create that entry with a hex editor too - let us know how it went.
|
|
#4
|
|||
|
|||
|
This information might be handy in future, so here goes.
The bootsect file attached in post #1 is a slightly modified DOS floppy disk boot sector. I started with the floppy image referenced in post #2, but I imagine others will work too. Following on from post #2, copy the boot sector out of the floppy image: # dd if=/path/to/image/file of=/tmp/bootsect bs=512 count=1Open the resulting file in a hexeditor and modify offset 0x24 - change it from 0x0 to 0x80. You can also modify the OEM string if you like. It's at 0x3 to 0xA inclusive (8 bytes) and is space padded (0x20). I set it to "FREEBSD" in the file attached in post #1. The bootsect file is useless as is - you need to feed it to newfs_msdos(8) when you create your file system. |
|
#5
|
|||
|
|||
|
These two sites were indispensable when creating the above:
http://www.ata-atapi.com/hiwdos.html http://homepage.ntlworld.com/jonatha...ter-block.html |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help making bootable CD | waveaura | Installing & Upgrading | 38 | May 29th, 2011 22:00 |
| Hard disks not recognized | floomby | Installing & Upgrading | 3 | June 9th, 2010 22:32 |
| Still Cant mount hard disks.. | skmpz | General | 4 | October 31st, 2009 14:40 |
| how can I mount usb hard disks? | sugar | Peripheral Hardware | 9 | March 8th, 2009 20:49 |
| making a bootable installation usb flash while running linux | rimas | Installing & Upgrading | 11 | January 24th, 2009 18:07 |