Page 1 of 1

Having trouble booting my kernel in an emulator...

Posted: Sun Jan 02, 2011 4:57 pm
by monsterhunter445
Hi, I'm new to OS development but not new to programming. I have a question after I've compiled my NASM code, and C code, and link them together to a *.bin file. How do I boot it with GRUB?

PS. I don't have a floppy drive, and the emulator I'm using is Bochs. Also I've attached the Kernel.bin which is compressed as a tarball.

Re: Having trouble booting my kernel in an emulator...

Posted: Sun Jan 02, 2011 5:17 pm
by gerryg400
monsterhunter445 wrote:Hi, I'm new to OS development but not new to programming. I have a question after I've compiled my NASM code, and C code, and link them together to a *.bin file. How do I boot it with GRUB?

PS. I don't have a floppy drive, and the emulator I'm using is Bochs. Also I've attached the Kernel.bin which is compressed as a tarball.
If your kernel is multiboot compliant there should be no problem. What happens when Grub tries to load it ?

Re: Having trouble booting my kernel in an emulator...

Posted: Sun Jan 02, 2011 5:28 pm
by monsterhunter445
Its not that GRUB can't boot my kernel, is just that I don't know how to get GRUB to boot my kernel. I've the GRUB.img which is the floppy disk image that contains GRUB, and I have the binary file that contains my kernel. So, my question is how do I use GRUB to boot my kernel. Do I have to link GRUB with my Kernel, or is it something else, because all the tutorials I've read only teaches you how to write a bootloader and a kernel, but not how to load it in an emulator or in an actual computer.

PS. Sorry for the neophyte question, I also know that the command 'kernel' loads the kernel with GRUB.

Re: Having trouble booting my kernel in an emulator...

Posted: Sun Jan 02, 2011 5:45 pm
by gerryg400

Re: Having trouble booting my kernel in an emulator...

Posted: Sun Jan 02, 2011 9:14 pm
by monsterhunter445
Thanks for those links they were very helpful, but one more question. No I've decided to boot my kernel in an emulator called QEMU because it comes built with its very own bootloader. So I used the command below:

Code: Select all

qemu -L . -kernel Kernel.bin -boot c
And I got this error:

Code: Select all

A disk image must be given for 'hda' when booting a Linux kernel
So what does this error mean...oh and thanks for the help I appreciate it.

Re: Having trouble booting my kernel in an emulator...

Posted: Mon Jan 03, 2011 12:26 am
by Tosi
I'm not sure since I don't use QEMU, but when you pass the option "-boot c", QEMU expects there to be a harddrive with the letter C, which becomes hda under linux.

What you need to do is use a loopback device to mount your grub image, put your kernel on the floppy and edit the menu.cfg to tell GRUB where your kernel is.
In case you are using Windows there are tools to create virtual drives as well. All of this is documented on the wiki.