views:

254

answers:

5

Is there anything that the kernel need to get from the boot loader.Usually the kernel is capable of bringing up a system from scratch,so why does it require anything from boot-loader? I have seen boot messages from kernel like this.

"Fetching vars from bootloader... OK"

So what exactly is the variables being passed? Also how's the variables being passed from the bootloader? Is it through stack?

+1  A: 

There are some parametres that the Linux kernel accepts from the bootloader, of which what I can remember now is the vga parametre. For example:

kernel /vmlinuz-2.6.30 root=/dev/disk/by-uuid/3999cb7d-8e1e-4daf-9cce-3f49a02b00f2 ro vga=0x318

Have a look at 10 boot time parameters you should know about the Linux kernel which explains some of the common parametres.

Alan Haggai Alavi
A: 

Linux accepts variables from the boot loader to allow certain options to be used. I know that one of the things you can do is make it so that you don't have to log-in (recovery mode) and there are several other options. It mainly just allows fixes to be done if there's an issue with something or for password changing. This is how the Ubuntu Live-CD boots Linux if you select to use another option.

indyK1ng
+1  A: 

The kernel accept so called command-line options, that are text based. This is very useful, because you can do a lot of thing without having to recompile your kernel. As for the argument passing, it is architecture dependent. On ARM it is done through a pointer to a location in memory, or a fixed location in memory.

Here is how it is done on ARM. Usually a kernel is not capable of booting the machine from scratch. May be from the bios, but then it is not from scratch. It needs some initialisation, this is the job of the bootloader.

shodanex
A: 

For the Linux kernel, there are several things the bootloader has to tell the kernel. It includes things like the kernel command line (as several other people already mentioned), where in the memory the initrd has been loaded and its size, if an initrd is being used (the kernel cannot load it by itself; often when using an initrd, the modules needed to acess storage devices are within the initrd, and it can also have to do some quite complex setup before being able to access the storage), and several assorted odds and ends.

See Documentation/x86/boot.txt (link to 2.6.30's version) for more detail for the traditional x86 architecture (both 32-bit and 64-bit), including how these variables are passed to the kernel setup code.

CesarB
A: 

The bootloader doesn't use a stack to pass arguments to the kernel. At least in the case of Linux, there is a rather complex memory structure that the bootloader fills in that the kernel knows how to parse. This is how the bootloader points the kernel to its command line. See Documentaion/x86/boot.txt for more info.

Andy Grover