Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does bootloader(e.g. grub,lilo... ) find kernel image? [closed]

For example, if use grub to boot system, there may be lines such as

root (hd0,6)
kernel /boot/vmlinuz-2.6.11-1.1369_FC4 ro root=LABEL=/
initrd /boot/initrd-2.6.11-1.1369_FC4.img 

in menu.lst.

My question is:

before the kernel image is loaded into memory, I think no file system info(such as file system type, super block) which can be used to locate the kernel image in the disk exist.

So how does bootloader know the CHS of the image in the disk?

I guess that bootloader could find the super block according to "root (hd0,6)"; if so, it must blindly detect all the possible file systems and find a matching one. Is it too complicated?

like image 760
Baggiobx Avatar asked Mar 25 '26 10:03

Baggiobx


1 Answers

I am gonna give you an answer using Lilo like example:

The reason that you have to run /sbin/lilo after installing a new kernel is that the LILO bootloader doesn't understand file systems it only knows about the lower level block structure of the disk. The /sbin/lilo program does understand file systems, and translates the kernel's path (i.e "/boot/vmlinuz-2.6.3") into a logical block address ie 3-4-123) so that the LILO bootloader can find the kernel image to load. Effectively, this is a big hack.

Source: http://courses.cs.washington.edu/courses/cse451/02wi/section/bootloaders.txt

like image 67
Sergio Troiano Avatar answered Mar 27 '26 16:03

Sergio Troiano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!