Question

I've created simple bootloader which looks like this:

[BITS 16]   
[ORG 0x7C00]    

MOV AL, 65
CALL PrintCharacter
JMP $       ;Infinite loop


PrintCharacter: 
MOV AH, 0x0E    
MOV BH, 0x00    
MOV BL, 0x07    

INT 0x10    
RET     

TIMES 510 - ($ - $$) db 0   ;Fill the rest of sector with 0
DW 0xAA55           ;Add boot signature

Then I compiled it with nasm -f bin -o boot.bin bootloader.asm. The next step I took was testing it on VirtualBox using new virtual system (I've choosen type:other).

I've created an iso file using mkisofs -no-emul-boot -boot-load-size 4 -o boot.iso -b boot.bin isodir/ It booted correctly and character A was displayed as I wanted to.

Next I wanted to test this simple boot code on physical machine. I didn't want to overwrite my MBR so I decided to use a USB stick as boot device (my BIOS supports this).

First I used dd if=boot.iso of=/dev/sdb1 conv=notrunc bs=512 count=1 seek=0. It did not work, nothing showed up, just a black screen and cursor.

My question is how should I properly prepare MBR on USB stick. Or how can I change code to try writing only first 446 bytes with boot code(like dd if=boot.iso of=/dev/sdb1 conv=notrunc bs=446 count=1 seek=0) because next 4*16 bytes are partition table + 2 bytes for boot signature.

Thanks in advance.

Était-ce utile?

La solution

I've found a solution.Like nodakai said /dev/sdb1 points to first partition,so I should have write to /dev/sdb because it points to physical drive. But not only this was wrong but also I had to remove TIMES 510 - ($ - $$) db 0 and boot signature 0xAA55 to run it properly(to not overwrite partition table). I'm just curious now why I just could not write the partition table like I was doing it (fill with 0)?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top