Writing MBR

There are different ways for doing that. You can take reference to www.osdev.org for details.

The easy way for me was going with linux and extracting MBR for drives:

1. Backup first

    dd if=/dev/sda of=~/[original_bootloader.bin] bs=512 count=1

    2. Disassemble the bootloader

    ndisasm -b16 -o7C00h ~/[original_bootloader.bin] > ~/[original_bootloader.asm]

    3. Make your modifications and reassemble

    nasm ~/[original_bootloader.asm] -f bin ~/[modified_bootloader.bin]

    4. Overwrite the bootloader

      dd if=~/[modified_bootloader.bin] of=/dev/sda bs=512 count=1

      ‘sda’ is your default primary (bootable) drive. You can modify the .bin file and test in your development enviroment and deploy the successfully edited bootloader  to system.

      Comments

      Leave a Reply

      Your email address will not be published. Required fields are marked *