The Answer Gang 79: How does LILO find the boot partition???

| Meet the Gang 1 2 |

# The Answer Gang

#### By Jim Dennis, Ben Okopnik, Dan Wilder, Breen, Chris, and... (meet the Gang) ... the Editors of Linux Gazette... and You!
Send questions (or interesting answers) to The Answer Gang for possible publication (but read the guidelines first)

### How does LILO find the boot partition???

From Super Simian

Answered By John Karns, Ben Okopnik

Greetings Answer Gang,

I've found the info you've given to others very useful in the not-so-distant past, and I like the Gazette in general, and I thought I might ask you a question to which I have looked for the answer to myself, and very recently plagued and tormented me:

> How does LILO find the boot partition???

> [Ben Okopnik] Quite tasty, thanks. Also rather cute and cuddly, but not quite the kind of thing one takes home to mother, if you know what I mean.

> [John Karns] Sorry, I'm on a bit of a hurry at the moment so am unable to write a detailed reply. But I can offer some hints.

Wait, first, here's what I'm running:

> `
> PIII dual proc
> RedHat 7.2
> 2 IDE disks, hda and hdc,
> 1 SCSI disk, sda`

Suppose that's all that's relevant to this question...

OK, so the scsi disk is a pretty new addition to the setup, and I already had a pretty good linux install on hdc, so I decided to move over to the scsi as my main disk. After a bit of fooling around, I decided that the easiest way was just to do a new install onto the scsi, and copy over some choice config files and all my data. This went smoothly, no problem.

Oh, I should probably mention at this point, I had LILO in the MBR of hda, and my boot partition was on hdc1...

So, about a week later, I still had my old linux installation on hdc2, as I was waiting to see if I had forgotten any vital info before I commited it to the abyss. Well, my roommate wanted to reinstall and format (WinXP, as it happens...) and he needed about 6 gigs of backup space, so I deleted my old linux installation on hdc2, and rewrote the LILO on the MBR without it, just to make sure everything was still cool, and it was. We moved the data to my system, he reinstalled, and we moved the data back.

So, then, I decided it was time for a little housekeeping, and repartitioned hdc as one ext3, and went to reboot, and... OH CRAP! My boot partition was on that drive!!!

So, I poped in my bootable "Super Rescue" cdrom, and decided to poke around a bit and see if I could get my system to boot again. I ran LILO again, no dice. I poked around for a while, and noticed I still had all of the data in `/boot` on sda1, and tried to figure out how to inform LILO about this, but I had no luck. I even recreated the boot partition on hdc1 and copied all the same info back onto it, and reran LILO, still no luck. After looking through some man pages and browsing through liniuxdoc.org, I still had no clue as to how to get things working again, so I made a new linux install on hdc, using the same boot partition (hdc1) and installing LILO to the MBR of hda again, modified lilo.conf in this new install to also boot the sda copy of RedHat, and everything worked.

So, my question to you, is how do I make LILO aware of the location of the boot partition or directory? How do I prevent this from happening again (aside form not deleting my boot partition

> [John Karns] With 3 hd's in the system, things can get a little complicated to explain, as there are so many ways to go about it. But for the time being, let's say that when you installed to sda the install properly set up everything on sda, and assumed that it was the only drive in the system. Then in order to boot from sda, you would have to make a change in your BIOS setup to tell the system to boot from SCSI. When there are both IDE and SCSI drives installed, the default is to boot from IDE. Most BIOSes I have seen in the past two years allow the option of booting from SCSI.

Oh, I thought it might be something in `/etc/fstab`, but to my feeble efforts, this proved to be a blind alley.

> [Ben Okopnik] Nope, wouldn't be there. That comes _way down the road, dealing with which partitions should be mounted and where.

> [John Karns] If you installed fresh to sda, then the fstab there should have the correct set up. However, if you copied the one from hdc, then you would have to change the partition references to point to sda.

I'm feeling a little lost, there doesn't seem to be anything in lilo.conf addressing this,

> [Ben Okopnik] Here's a bit from my "`/etc/lilo.conf`" (though admittedly not all the distros comment theirs this well):

>     # Specifies the boot device.  This is where Lilo installs its boot
>     # block.  It can be either a partition, or the raw device, in which
>     # case it installs in the MBR, and will overwrite the current MBR.
>     #
>     boot=/dev/hda

and I thought maybe fstab might help, as LILO should be able to find this file, as the `/` directory IS specified in lilo.conf, but please, help!

> [John Karns] You have to decide on what scheme you want to use to boot your system - i.e., whether you want to boot from lilo or use XP's boot mgr (lilo is easier to config for multi-boot IMO), and from which drive you want to boot. Gotta go.

> [Ben Okopnik] My recommendation to you is to take a good read of "`/usr/share/doc/lilo/Manual.txt.gz`", or wherever RedHat keeps its doc files (if I recall, it's that or something fairly close to it.) It's a well-written document that describes the boot process and LILO's place in it, as well as all about boot records and where they can be stored and how they can be accessed. Quite an education, all in one file (about 125kB, but, hey, it's a complete manual.)

Eagerly awaiting your replies,

--Super Simian

PS-I hope this email doesn't contain any html, I know you people don't like that, but it's hotmail and it might, and I can't find anywhere to turn it off!

Thanks again!

> [Ben Okopnik] It was fine, just plain text. Seems like Hotmail does the Right Thing in that regard.

Hello again,

OK, after reviewing the documentation under `/usr/share/doc/lilo`, I think I understand exactly what happened. Lilo was starting the boot process, but only got as far as "LI" because it couldn't find the files in `/boot`, which originally was a separate partition, hdc1. Even after recreating this partition, and copying the same data back to it, it still couldn't find `/boot/boot.b` because the info Lilo stores in the MBR points to the physical location on disk of boot.b, instead of using partition numbers and directories to locate it. That's why I couldn't find anywhere to specify the location of the boot partition, because Lilo gets this info from your filesystem when you execute `/sbin/lilo` to write a new MBR. So if you have, say, your root on hdc5, and hdc1 is mounted under `/boot`, then it actually stores the location of the files on disk (by sector, or some such), and if you remove hdc1 from your filesystem and just copy the files to `/boot` under hdc5, Lilo will still look for the info on hdc1.

Then, when I reran Lilo to try to get it to use the `/boot` directory on sda1, it still couldn't find `/boot/boot.b` because it was on a SCSI disk which was not addressable by BIOS during the early portion of booting, as I had my SCSI BIOS turned off to speed booting. I mistakenly thought that the stuff in the MBR was enough to get the computer into protected-mode.

So, thank you very much for pointing out that document, it has proved to be an excellent repository of informative Lilo goodness!

Oh, and do you see any flaws in my thinking? I'm fairly sure that the above is what was going on...

Thank you

> [Ben Okopnik] It all sounds very reasonable to me, at least according to The Holy Writ, erm, I mean `/usr/share/doc/lilo/Manual.txt.gz.` Sounds like you've read the docs and understood them - well done!

##### This page edited and maintained by the Editors of Linux Gazette Copyright © 2002
Published in issue 79 of Linux Gazette June 2002

###### HTML script maintained by Heather Stern of Starshine Technical Services, http://www.starshine.org/

| Meet the Gang 1 2 |