Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This 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!


  Search this Thread
Old 12-29-2015, 05:00 AM   #1
LQ Newbie
Registered: Sep 2007
Posts: 13

Rep: Reputation: 0
Question Lilo's second stage code loading


As I know LILO is a two stages boot loader. Suppose we install it in the MBR so the first stage is loaded into MBR by "lilo"
command. But what about the second stage code? Some sources say that it's being written in the /root partition of the system from which lilo" command is executed and in such a case is loaded by looking through the partition table (located int MBR) for an active partition and then just executing the code in the partition's boot record. Other sources say the second stage code is "written somewhere on the hdd" and it's location is just hard-coded in the first stage code.
So which explanation is the correct one?
Old 12-29-2015, 08:17 AM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,713

Rep: Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279Reputation: 1279
The second one.

It has been a while since I actively used LILO, and never used the EFI addition. But the MBR bootblock contains the block numbers where the rest of LILO resides. The lilo command identifies these block numbers from the filesystem it resides on to get those block numbers.

One of the early limitations of LILO was that those blocks had to reside within the area that the BIOS functions could load, and there were a limited number of them.

Note: The first stage is in the MBR, the second stage is is in the boot extension area. Both of these are loaded using the BIOS, the first is loaded, and started (where the L output comes from), That program (has to fit within 218 bytes) then directs the BIOS functions to load the extension area. NOTE: actual limitations depend on which boot format are being used... And it varies depending on the block size of the disk as well.

The above only gets LILO loaded, not the kernel. Once the two parts of lilo are loaded you have the option to select a kernel to load... each having its own list of blocks to be read into memory.

Much (or most?) of the complexity has been due to the original IBM layout. In the "good old days", the boot block was exactly 512 bytes, and had only the code to tell the disk controller what sector to start reading on, and the number of sectors to read. The kernel was in a contiguous sequence of blocks on disk, thus loading a kernel only took ONE read command. In the "not quite good old days" (meaning about 10 years advance) the kernel was replaced by a "boot" program that understood the filesystem enough to load a block list taken from a given files metadata. This "boot" program had to fit within one block (software defined block, usually 4k in size, or 8 sectors. And the BIOS took over most of these functions due to the complexity of various filesystems (different metadata, different storage...). And that extended strange coding for where the boot information could be stored...

Last edited by jpollard; 12-29-2015 at 08:29 AM.


lilo, linux boot

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help - deleted partition: GRUB loading stage l.5, Grub loading, please wait Error 17 rokkoschik Linux - General 1 01-07-2011 06:24 AM
Grun Loading stage 1.5, Grub loading - Error 22, won't boot from bootdisk susancorless Linux - Newbie 7 12-06-2010 11:51 PM
GRUB loading stage 1.5 Rameses Linux - Server 4 07-08-2010 04:05 PM
Grub Stage 2 Loading.. OrangeBicycle Ubuntu 2 04-08-2009 01:17 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration