Copying Your Bootsector to a Hard Drive

Copying Your Bootsector to a Harddrive

First, you should read the Copying Your Bootsector to a Floppy Disk tutorial if you haven't yet.

The requirements for a bootsector that's installed on a harddrive are the same as those for a bootsector on a floppy:

  1. Your bootsector is exactly 512 bytes long.
  2. Your bootsector ends with 0xAA55.
  3. Your bootsector is compiled as a flat binary.

Now, the BIOS(Basic Input Output Sytem) will look only on the first harddrive for a bootsector(most BIOSes do this, though apperently some allow you to chose which harddrive to look on) so we need to copy our bootsector to the first harddrive. In Linux, the first harddrive is /dev/hda and in PartCopy, it is h0.

Copying Under Windows With PartCopy

This is is pretty much the same as copying a bootsector to a floppy disk with PartCopy(in this example the bootsector is called bootsec.bin):

partcopy bootsec.bin 0 200 -h0

We start at the very beginning of the first harddrive(the first harddrive is specified with the -h0) and continue to the 512 byte mark(512 bytes = 0x200).

Before you do that, you might want to back up the old bootsector so that you can restore it. The command below saves the old bootsector into a file called oldboot.bin:

partcopy -h0 0 200 oldboot.bin

Copying Under Linux With dd

First, our bootsector is called bootsec.bin. Under Linux, the first harddrive is /dev/hda. We want to write our bootsector as one block of 512 bytes. bs=512 sets up the size of 1 block and count=1 specifies that we want to only write 1 block:

dd if=bootsec.bin of=/dev/hda bs=512 count=1

Before you do that, you might want to back up the old bootsector so that you can restore it. The command below saves the old bootsector into a file called oldboot.bin:

dd if=/dev/hda of=oldboot.bin bs=512 count=1

This tutorial was written by K.J. - May 6, 2002

Related

Report issues via Bona Fide feedback.

2001 - 2024 © Bona Fide OS Development | The Goal | Contributors | How To Help |