13

I'm actually interested in how an OS works, from the POST over the Boot process to the Kernel, GUI, etc.

Well I have to start at the beginning: The bootsector

Most tutorials only specify how to get your .bin bootstrapper onto an USB stick for Linux users.

But as I'm using XP I would like to ask how do I get my 512 byte .bin onto the right position on my USB, and thats definitely not by copying it with explorer :D

Ant Swift
  • 20,089
  • 10
  • 38
  • 55
orossum
  • 133
  • 1
  • 4

2 Answers2

14

There's dd for Windows which I use regularly. http://www.chrysocome.net/dd

use it like so:

dd if=c:\my files\boot.bin of=\\.\z: bs=512 count=1

where 'z:' is the drive letter of your mounted USB drive, 'if' is the input file, and 'of' is the output device, bs is the block size, and the count is the number of blocks to copy

I do this about once a month to see how Haiku development progresses. They offer raw disk images that are written to a USB drive this way.

WARNING: Getting the drive letter wrong can destroy YOUR bootsector, so make sure you do a backup and become comfortable using dd first. I've lost a lot of data to it's power.

RandomInsano
  • 1,204
  • 2
  • 16
  • 36
  • @Randomlnsano: You get my +1 cos I never knew a dd existed for Windows! Cool! :) – t0mm13b Dec 12 '09 at 22:17
  • 1
    Should note that this writes to the beginning of the partition that Z: maps to, not the MBR (The question is a bit ambiguous) . If you want to overwrite the MBR boot sector then I think you'd have to use a newer version of chrysocome `dd` and use the `od` parameter to write relative to the beginning of the physical device (and not just the partition). This would overwrite the MBR `dd if=c:\my files\boot.bin od=z: bs=512 count=1` – Michael Petch Oct 30 '15 at 21:33
  • When you use Windows to format a USB drive by default it creates the equivalent of a harddrive with a single partition and marks that partition as bootable.Windows writes an MBR (Master Boot Record) that acts as a chain loader. When you boot from that USB the BIOS loads the MBR and jumps to it. The MBR code acts as a chain loader finds the partition marked bootable, loads the first 512 bytes of the partition to memory location 0x0000:0x7C00, and then jumps to it. The partition boot sector doesn't know it was chain loaded and it thinks the BIOS loaded it directly as if it had been the real MBR – Michael Petch Oct 30 '15 at 21:42
0

Maybe you could use rawritewin to do the job for you?

The other way is to use UNetBootIn but from my experience in messing with it, it requires an ISO to be burned onto a USB.. so that may not work in your case but you could try creating an ISO in preparation to be written to the USB...

t0mm13b
  • 34,087
  • 8
  • 78
  • 110