LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux kernel booting (http://www.linuxquestions.org/questions/linux-newbie-8/linux-kernel-booting-932555/)

beyond 03-03-2012 03:12 PM

linux kernel booting
 
Plz. do rectify me at all the wrong points!!!

when bootloader in bios executes its code, it do POST and other things...then as I read from somewhere kernel does initrd to load some basic modules so as to mount the root file system and then removes initrd filesystem to make the space .....
1.how does kernel do initrd as the kernel(vmlinuz) itself is present on the harddisk ....i mean how the control is transferrred to the kernel(present in hdd) from the bios????
--at initial point drivers(i mean the protocol to access the harddisk) is not known then how the MBR is accessed ??
2.can we put the kernel (even though very small part of it) in the bios itself??



Regards,,
saurabh

Doc CPU 03-03-2012 03:30 PM

Hi there,

quite a sophisticated process that you're trying to understand!
The boot process is actually more complicated than you think. Your understanding is more or less correct, but incomplete.
  1. BIOS does self-test and a basic initialization of hardware (HDD controller, display, keyboard)
  2. BIOS looks for a valid boot media, usually the first HDD (could also be a USB storage device)
  3. BIOS loads the first physical sector of the boot drive into memory (not knowing anything about file systems), assumes that it contains machine code, and executes that code. Usually this sector is the beginning of the bootloader (e.g. GRUB) which takes over now. GRUB contains file system drivers for the configured boot partitions.
  4. The boot code usually loads more code (a few more sectors), as much as it takes
  5. The bootloader analyzes the boot configuration, displays the boot menu and waits for the user to select an item
  6. The bootloader loads the selected kernel plus the associated initrd (if any), and hands control to the loaded kernel

Quote:

Originally Posted by beyond (Post 4617763)
2.can we put the kernel (even though very small part of it) in the bios itself??

In theory, that's possible, and something like that is often done in embedded systems. But then the kernel is usually located in a Flash memory, which is mounted like it was a Readonly-HDD.

[X] Doc CPU

Tinkster 03-03-2012 03:37 PM

For all it's worth (assuming you're using something that uses GRUB):
http://docs.redhat.com/docs/en-US/Re...ub-whatis.html


Cheers,
Tink

beyond 03-03-2012 04:09 PM

thanks Tinkster and Doc CPU,,,
one more question:
1.does the meaning of bootloader is limited to any code that cause the booting of os??
2.the bios also does a similar thing(not activating the OS,, a lot of initiallisation and other things),, is it also a (sort of)bootloader???

Tinkster 03-03-2012 04:33 PM

Ad 2)
The BIOS reads the first few bytes (I think 512) of the first sector
of the boot device into memory, and point the execution pointer of the
CPU at it.
Ad 1)
I don't really understand what you're saying, but:
The boot loader (part of which sits in those 512 bytes above) will then
try to load the kernel (or the "other OSes" equivalent), and have it
carry on with execution in the same way - setting the CPUs execution pointer
at the memory location into which it loaded whatever it slurped of the disk.



Cheers,
Tink

beyond 03-05-2012 05:40 AM

So sir,
1.can i say that after the initiallisation that the bios do, the bios code can access all the peripherals completely???

2.I mean that from the bios code only,, can i acess the harddisk completely..specifically the kernel bcz. If i have accessed the MBR!! which is in harddisk, so can i access the remaining part of it too ??

3.if not. Then is it possible to extend the size of MBR(just asking) so as to fit the kernel in it(it will initiallise all the peripherals and other things ) thus removing the bootloadr??

Tinkster 03-05-2012 01:17 PM

Quote:

Originally Posted by beyond (Post 4618812)
So sir,
1.can i say that after the initiallisation that the bios do, the bios code can access all the peripherals completely???

You can say that, but it's wrong. =o)


Quote:

Originally Posted by beyond (Post 4618812)
2.I mean that from the bios code only,, can i acess the harddisk completely..specifically the kernel bcz. If i have accessed the MBR!! which is in harddisk, so can i access the remaining part of it too ??

No you can't. From BIOS you can access what's in MBR. Full stop. Period. End
of BIOS' responsibility.


Quote:

Originally Posted by beyond (Post 4618812)
3.if not. Then is it possible to extend the size of MBR(just asking) so as to fit the kernel in it(it will initiallise all the peripherals and other things ) thus removing the bootloadr??

No. MBR is 512 bytes (unless you write your own BIOS and flash it to your motherboard),
that's all you get to play with. And no, I don't think you can write a replacement kernel
that will fit in there and do all the work.


Cheers,
Tink

Doc CPU 03-05-2012 03:51 PM

Hi there,

let me add a few words to what Tinkster said.

Quote:

Originally Posted by beyond (Post 4618812)
1.can i say that after the initiallisation that the bios do, the bios code can access all the peripherals completely???

No, definitely not. The BIOS won't initialize and care for sound cards, TV cards, integrated modems, let alone special hardware like CAN cards or something. It initializes just a basic set of peripherals, like VGA, keyboard, HDD controller and disks, FDD controller (if present), serial and parallel ports (if present) and USB controllers. I may have forgotten something, but I think that's it more or less.

Quote:

Originally Posted by beyond (Post 4618812)
2.I mean that from the bios code only,, can i acess the harddisk completely..specifically the kernel bcz. If i have accessed the MBR!! which is in harddisk, so can i access the remaining part of it too ??

BIOS contains functions to access hard disks on a sector-by-sector basis, not knowing anything about file systems. So yes, basically it could also read any other part of the hard disk. But standard implementations just read the very first sector, which contains the boot record and the partition table. Usually they leave anything else to the operating system that's about to be started.
On newer computers that support GPT partitioning, the GUID partition table can be several sectors long, starting after the traditional MBR.

Quote:

Originally Posted by beyond (Post 4618812)
3.if not. Then is it possible to extend the size of MBR(just asking) so as to fit the kernel in it(it will initiallise all the peripherals and other things ) thus removing the bootloadr??

No. You're confusing hardware matters and software structures. The MBR (Master boot record) is a part of the very first sector. That's by definition. But well, one could, in theory, create a very specialized operating system that starts directly from the MBR. But I don't know any system that actually works this way.

[X] Doc CPU

beyond 03-06-2012 07:51 AM

thanks Doc CPU and Tinkster,, for clearing some of my doubts...



Regards,


All times are GMT -5. The time now is 06:24 PM.