views:

50

answers:

3

Is there a way to write a code that may run when System starts while a operating system is not loaded?

I actually want to copy data of a particular partition, sector by sector, into another partition with the help of that code.

+3  A: 

Yes there is, lots of ways, but you'll have to learn a hell of a lot before starting. Also this isn't a serverfault question.

Chopper3
Ahaan. Sorry for that.
A: 

You could learn how to run pre-OS booting code by looking at existing software that does that:

  • GRUB boot loader
  • Truecrypt

Both of these are open source - so examine their code. GRUB is perhaps the simpler of the two to study.

Once you know how the code works and how they get to run before your OS boots, then you can write your specific program yourself based on their technique.

Rob
A: 

Assuming you're talking about x86 architecture here.

When starting up the machine will try reading the first 512 Byte. If the last two bytes are 0xAA55 the machine will execute this code.By that you can run any assembler instructions.

This all is more comfortable once you have an operating system.

Do you have to copy the bytes all the time the machine starts or only once? - For only once grab a live CD or put netboot.me on a floppy and boot that. Then you can do things in a way nicer way.

johannes