Insert boot loading code into MBR of virtual disk
Posted: Mon Apr 27, 2009 6:15 am
Hi all, I have some problem with performing this operation.
I've done the following things:
dd if=/dev/zero of=disk.img bs=1024 count=100000
parted disk.img mklabel msdos
parted disk.img mkpartf primary fat32 0 70
parted disk.img set 1 boot on
fdisk -ul disk.img give me a correct output
So I have a virtual disk well formated (I think). And I want to put a code (a bootloader) compile with nasm -f bin stage1.S -o stage1 that fit in 446
bytes (with times 446-($-$$) db 144).
I put the stage1 file binary on the MBR code area with this command:
dd if=stage1 of=disk.img bs=446 count=1
And just after an fidsk -ul disk.img give me nothing, like if I broke the partition table.
The bootloader only works when stage1 is 512B with the aa55 signature:
dd if=/dev/zero of=disk.img bs=1024 count=100000
parted disk.img mklabel msdos
parted disk.img mkpartf primary fat32 0 70
parted disk.img set 1 boot on
dd if=stage1 of=disk.img bs=512 count=1
And the bootloader works, but I erase the partition table of the disk .
Am I doing something wrong.
I've done the following things:
dd if=/dev/zero of=disk.img bs=1024 count=100000
parted disk.img mklabel msdos
parted disk.img mkpartf primary fat32 0 70
parted disk.img set 1 boot on
fdisk -ul disk.img give me a correct output
So I have a virtual disk well formated (I think). And I want to put a code (a bootloader) compile with nasm -f bin stage1.S -o stage1 that fit in 446
bytes (with times 446-($-$$) db 144).
I put the stage1 file binary on the MBR code area with this command:
dd if=stage1 of=disk.img bs=446 count=1
And just after an fidsk -ul disk.img give me nothing, like if I broke the partition table.
The bootloader only works when stage1 is 512B with the aa55 signature:
dd if=/dev/zero of=disk.img bs=1024 count=100000
parted disk.img mklabel msdos
parted disk.img mkpartf primary fat32 0 70
parted disk.img set 1 boot on
dd if=stage1 of=disk.img bs=512 count=1
And the bootloader works, but I erase the partition table of the disk .
Am I doing something wrong.