There are solutions under both systems but whichever one you choose, just remember: these are potentially dangerous utilities. A mistake with them could mangle your disk drive. Be very careful when using them, and if you are doing the same operation repeatedly (which you probably will), put your invocations of them in a script so as to minimize the risk of a typo.
In Linux, there is a standard utility, dd(1), which can be used to raw-write a boot sector. Assuming you are writing to the file 'bootldr' to fd0, then the arguements should be:
dd if=bootldr of=/dev/fd0 bs=512 count=1
Check the man and texinfo pages for more details on the syntax and usage. It is not a very typical Unix utility, as you can see, and the
Jargon File entry on it suggests that the syntax was meant as a joke.
On Windows, there is no standard utility for this purpose, but there are several you can download for free which will work. The two that seem to be the most popular are
RawWrite, which comes in both console and GUI versions, and
Partcopy, a console program. There are ports of dd as well, one of which I believe can be gotten with
DJGPP.
I generally use either dd or partcopy. For partcopy, the command line syntax is:
PARTCOPY <source> <source_offset> <length> <destination> {<destination_offset>}
the <source> argument refers to the file, or disk, where the data should be copied from, and <destination> refers to the file or disk to copy the data to. <source_offset> is the location, in bytes, to begin copying from; the optional <destination_offset>, thus, is the location to begin copying the data to, and <length> is the size of the data to be copied. all of these numbers are in hex.
The batch files I use (with some slight changes) are like this:
makeimage.bat:
Code: Select all
partcopy bootldr 0 200 boot.img 0
partcopy sndstage 0 200 boot.img 200
makedisk.bat:
I build the boot image separately first, then test it under Bochs, before testing it with a live disk. I'll have to adjust the size arguments as the sndstage file grows or changes; later, when I have a file system, it will be removed, as the second stage loader will then be set up as a file, rather than a raw sector.