Copying boot.bin to sectors on Linux

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Vladaz

Copying boot.bin to sectors on Linux

Post by Vladaz »

Hello, I have a problem:
I am using linux, and i want to copy boot.bin to bootable sector of floppy. I use like this: dd if=boot.bin of=/dev/fd0 , it writes me that it copied, but when I try to emulate it with bochs or with my real pc, it does not load. On bochs it writes:
[BIOS ] BIOS panic at rombios.c, line 1558

On my real pc it just skips and loads GRUB menu where I choose to load linux or windows. Can someone help me with that please?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Copying boot.bin to sectors on Linux

Post by Candy »

Did you include a boot signature (0x55 0xaa) at the end of the first sector? If not, no computer is going to see your disk as bootable and thus complain.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Copying boot.bin to sectors on Linux

Post by Pype.Clicker »

Vladaz wrote: On bochs it writes:
[BIOS ] BIOS panic at rombios.c, line 1558
What about Using the Source ? get the sources package for your distribution, locate bios/rombios.c, head yourself to line 1558 and read the comments around there to know what you should try to fix ?
Curufir

Re:Copying boot.bin to sectors on Linux

Post by Curufir »

Not really helpful Pype. That particular part of rombios.c is a hack to make sure the panic message gets written out. The error itself probably happened way back in the code.
Vladaz

Re:Copying boot.bin to sectors on Linux

Post by Vladaz »

You see, my bootloader even doesn't boot on my real pc. I think there's a problem copying bootloader to boot sector. On windows everything is OK, but on linux there's that problem.
Im sure, that my boot.bin is ok. Because when i tried to boot it straight from bochs, it booted, and it worked, but using floppy it isn't. I think that there is some problem copying to floppy :/
Maybe you know any OS that has installation for linux, so i could just copy that os to floppy and then try?
Curufir

Re:Copying boot.bin to sectors on Linux

Post by Curufir »

No need to get that complicated.

Code: Select all

dd if=boot.bin of=/dev/fd0
dd if=/dev/fd0 of=boot.bin.bak bs=512 count=1

md5sum boot.bin boot.bin.bak
Or something similar if all you want is to verify that the 512 bytes of your bootsector did in fact get copied.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Copying boot.bin to sectors on Linux

Post by Pype.Clicker »

Curufir wrote: Not really helpful Pype. That particular part of rombios.c is a hack to make sure the panic message gets written out. The error itself probably happened way back in the code.
well, not being sure i had the same bochs here, that was the best i could suggest ...
Curufir

Re:Copying boot.bin to sectors on Linux

Post by Curufir »

Apologies, read that again and it sounds...odd.

I meant the code wasn't particularily helpful, the suggestion was sound.
Vladaz

Re:Copying boot.bin to sectors on Linux

Post by Vladaz »

I've tried that code that Curufir posted.
boot.bin.bak is 0 bytes sizes. So I think it doesn't copy that boot.bin.
And one more thing, when i copy i get the result like this:
1+0 records in
1+0 records out
512 bytes transferred in 0,496871 seconds (1030 bytes/sec)
.
But there is one thing, when it is copying my boot.bin, fdd does not make any noise, that you can hear always when you are copying any data to floppys.
Vladaz

Re:Copying boot.bin to sectors on Linux

Post by Vladaz »

Sorry guys for bothering you ;D
The problem was in my floppy disc :) It wasn't working :)
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Copying boot.bin to sectors on Linux

Post by Pype.Clicker »

Vladaz wrote: fdd does not make any noise, that you can hear always when you are copying any data to floppys.
The way linux uses the FDD is different from the way BIOS uses it, which means you may not recognize typical noises ...

Moreover, when writing to a floppy in linux, the actual data write may be postponed or may continue even after the program terminates. Usually, you should umount or sync to make sure the move is completed ...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Copying boot.bin to sectors on Linux

Post by Candy »

Pype.Clicker wrote: Moreover, when writing to a floppy in linux, the actual data write may be postponed or may continue even after the program terminates. Usually, you should umount or sync to make sure the move is completed ...
Only when writing to a mounted device. If you write to the device file itself (/dev/fd0) you do get a direct write.
Post Reply