Why do we need boot loader or boot manager? GRUB, Lilo
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why do we need boot loader or boot manager? GRUB, Lilo
I understand that we need GRUB or Lilo to choose between different operating systems, like Windows and Fedora on one machine. However, my UNIX Academy DVD training, and "Administrator' handbook", both discuss configurations where booting choices are between different kernels/configurations. Neither of them discuss booting with Windows as an option. I'm not getting it. Why would we need different kernels/configurations of Linux installed on one computer? And what's the benefit of using boot manager if my Linux is the only OS on a computer? Why not to boot it directly from MBR?
Click here to see the post LQ members have rated as the most helpful post in this thread.
Firstly the kernel is too big for the MBR; you need something
(like lilo or grub) who can read the kernel on a linux filesytem,
drag it into RAM and start it's execution.
Secondly it's always a good idea to have several kernels in case
you update one, and it misbehaves ... it's much quicker and easier
to choose a working one from lilo/grub than booting off a rescue
CD and repairing stuff.
Why would we need different kernels/configurations of Linux installed on one computer? And what's the benefit of using boot manager if my Linux is the only OS on a computer?
If you install a new kernel, may be with security patches or bugfixes, it is always a good idea to keep the old kernel. The new kernel may have issues with your hardware configuration. If it is your only kernel you run into problems, with the bootloaders option to run the old kernel you don't have a problem if the new kernel doesn't work.
You also have the possibility to run more than one Linux version. For example, not long ago I had Debian installed for everyday use and Arch for gaming.
Quote:
Why not to boot it directly from MBR?
Because you can't. The MBR is only 512 Bytes in size, usable for the bootloader are only 446 Byte. The kernel is far to large for that.
1. what is the need for boot loader?
A. well try this:http://www.xs4all.nl/~lennartb/bootloaders/node3.html
and if linux is only OS on your computer than set waiting time of boot loader = 0 and it wont prompt for initial display but boot the default OS
but i think a little freedom of choice wont hurt
2. what is the need for choosing different kernel versions ?
A. Different distributions and individuals compile and use different versions of kernel or simply compile for same version for their specific needs and needs to install and test them what if any thing goes wrong , In this case you can always choose old working kernel and here boot loader like LILO and GRUB comes with a great help
perhaps a little google on 'kernel build and installation' will help
It is probably worth mentioning that there was a time when Linux did boot directly from the MBR, where it bootstrapped itself as it loaded. This is of course rather limiting, and makes it difficult to recover if you happen to get a non-working kernel.
Most end-users don't ever need to use multiple kernels or Linux versions. For those that do, the bootloader is the perfect way to support their requirement. Linux does have a habit of trying to get along with everyone, if possible. It is also a convenient way to try different kernel settings with little pain. The kernel takes arguments to modify some of its behaviors, such as setting IPs, and other kernel module options. Some/many/most bootloaders allow you to set the kernel argument commandline at boot time. I was recently able to use such a facility to try various options to make the cooling fan on a laptop work. Having discovered the correct magic incantations, I then made it a permanent default.
I don't know for sure, but my hunch is that some distro installer software uses the bootlaoader as a last line of customization of an installation, based on the particular hardware that it discovers. This would enable Linux distributors to create more generic kernels. It would be easy to imagine that distributors appreciate the bootloader splash-screen as an ideal place to announce their product.
So we need Grub or Lilo for having an option of booting old kernel if updated/upgraded kernel doesn't fly.
What about the other explanations? The kernel is too large for the MBR. All systems need a boot loader/manager in the MBR to launch the kernel. The one for Windows is NTLDR.COM.
So we need Grub or Lilo for having an option of booting old kernel if updated/upgraded kernel doesn't fly.
I guess I could call this a bit of an over-simplification, given the body of explanation provided. Since you specified, I'll take the time to point out as well, that Grub (in either of it's two incarnations) and Lilo are not the only bootloaders out there. To name a few others:
Obviously, I'm not Linux expert, but I had my hand on Windows and MBR was never intended for having there boot manager. MBR is a place for a primary boot loader. This primary boot loader is responsible for loading a larger loader with portions of Kernel, major drivers etc. My reading of Linux books confirms that the same scheme is true for Linux. Boot managers aren't unique to Linux, there are plenty of them for Windows. And to mention Windows itself features boot manager. Boot manager is an extra software that interrupts a natural sequence of booting and allows to substitute the default booting command to something else. So limited space in MBR isn't a reason for having Grub or Lilo, in fact I been playing with some Linux installation (can't remember which, I've been playing around with too many in last few days) which offered an option of been installed without boot manager. So I do believe at this point that major reason for having Grub (or Lilo) is to get a way around stale kernel.
I've been reading that Grub also helps if root password is lost. I also been reading that Grub allows loading any other kernel, because BIOS itself is unaware file system structure.
So I do believe at this point that major reason for having Grub (or Lilo) is to get a way around stale kernel.
I've been reading that Grub also helps if root password is lost. I also been reading that Grub allows loading any other kernel, because BIOS itself is unaware file system structure.
Well, you are free to believe whatever you want. However, you make the point that the bootloader may be used to recover from a lost root password. This is an example of the runtime modification of kernel arguments that I described earlier. By using the bootloader to append the argument 'single', most distributions will boot to a single-user (root user) mode, which gives you root access. You can reset the root password, among many other diagnostic and remedial tasks.
It is a fact that the MBR is too small to contain an effective bootloader for most Linux kernels. The bootloader-less mode you describe would still use the MBR to bootstrap a dedicated bootloader that would be built into the kernel itself. This was at one time the standard way to launch Linux, but has been all but abandoned.
A bit of understanding of the boot process can be gained by simply knowing the origin of the term 'boot'. There is an English phrase 'pick oneself up by the bootstrap', which is of course a literal impossibility. The implication of the phrase is that it might be possible to lift yourself up, by lifting yourself by the feet; in other words, by elevating without the benefit of any external assistance. The boot process is done by starting from almost nothing (the simplist of code in a BIOS, for example), through a series of stages that progressively increase the basis upon which to build. Grub embodies this process literally, being composed of a series of 'stages', strategically organized to give it enough knowledge to read from a variety of filesystems on a variety of hardware. Once again, the bootloader is a single small point of customization, providing distros and their installers with something that can launch a kernel that is generic.
This primary boot loader is responsible for loading a larger loader with portions of Kernel, major drivers etc.
And that is what grub and lilo do (specially lilo). Nothing states that they can't do other things as well.
Quote:
Originally Posted by kienlarsen
but I had my hand on Windows and MBR was never intended for having there boot manager
How does windows handle dual boot scenarios (e.g. WinXP and Win7 dual boot, no Linux involved)? Just curious but as this is possible, Windows also uses what you call a bootmanager and not a primary bootloader. Please correct me if I'm wrong here.
Last edited by Wim Sturkenboom; 05-19-2011 at 12:56 AM.
Which is more in use today: Grub or Lilo? I see more about Lilo in older books and more about Grub in up to date training. It is just my impression or Grub is unseating Lilo?
Which is more in use today: Grub or Lilo? I see more about Lilo in older books and more about Grub in up to date training. It is just my impression or Grub is unseating Lilo?
I'd say it depends on the distro. You are correct, more distros do seem to be moving towards grub. Grub does have more powerful features, but LILO is simpler to install and configure. It really comes down to a matter of choice. It is possible to take an installation that boots with Grub and switch it to boot with LILO, and vice versa.
Aside from displaying fancy boot menus, and whatever other bells and whistles it wants to, a bootloader pretty much follows the same procedure to boot a Linux kernel, regardless of which loader it is. It must first learn how to access a Linux filesystem, then it must find and load the kernel from that filesystem into RAM, often while decompressing it, then it tells the CPU to start executing code at the memory location the kernel was loaded into. From there on, the bootloader has little to no significance.
(Geeks: correct me if I'm wrong, but I think there still is a way to compile a "self-booting" kernel wherein the kernel image's first 512 bytes do indeed contain simplistic bootloader code... No room for kernel prameters or any rescue options when doing this, but I can see the applications in embedded systems, where rescue would typically involve some external hardware anyway. I remember booting 2.2 series kernels off floppy disks this way...)
Computers these days have a lot of onboard software in Flash-ROM, and the "old BIOS ways" of doing things have really been superseded in many ways. But the basic principle of loading an operating-system is generally the same: a small loader program is grabbed from somewhere (these days, most of the goodies are actually in the ROM...), and it loads some kind of a boot-loader, and this loader locates and initializes the operating-system.
Of the various Linux loaders, I think that GRUB has pretty well taken-over for LILO, because it is considerably more flexible. It doesn't have the problem of requiring you to execute a magic command before shutting-down the system in order to be assured of being able to start it up again.
I know several Windows developers who use GRUB as the first-stage loader on their development machines. (It is used to load the appropriate NTLDR or whatever-it-is, which subsequently loads the Windows version.)
It doesn't have the problem of requiring you to execute a magic command before shutting-down the system in order to be assured of being able to start it up again.
I use Slackware with Lilo and don't have to execute a magic command before rebooting. If I forget to update Lilo after building a new kernel I just boot into the old one, no problem here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.