Booting a non-multiboot kernel with GRUB2
grub, osdev, x86
Solution
See the documentation:
Multiboot (see Multiboot Specification) is the native format supported by GRUB. For the sake of convenience, there is also support for Linux, FreeBSD, NetBSD and OpenBSD. If you want to boot other operating systems, you will have to chain-load them (see Chain-loading).
So for your non-multiboot kernel you'll have to use the chain-loader feature. Chain-loading means GRUB will load the first sector (512 bytes) of the specified harddisk partition and boots it like the BIOS would boot a MBR. This means the CPU is in real mode and your boot sector is loaded at 0x7C00.
And yes, you could boot your kernel using the `linux` command, by making it compatible with the Linux boot process, but that would be more complex than simply making your kernel multiboot-compliant.
Problem
I want to boot a custom kernel (non-multiboot) with GRUB2, I've read that I need `grub.cfg` like this: ``` menuentry "custom kernel" { set root=(hd0,0) chainloader +1 } ``` So, I have some questions: - How grub detect kernel? (with multiboot spec I used `kernel /boot/kernel.bin`) - How my kernel must look like (sorry for my bad english)? Must it be 512 bytes at all (like custom bootloader, which loaded into 0x7c00)? - `(hd0,0)` is hard drive partition and what I must put if I use CD? Maybe `(cdrom0,0)`? - To boot Linux kernel we can use `linux` command, can I use it to boot my custom kernel (with some changes)? - Will Grub enter `Protected mode` or not?