punkwalrus (punkwalrus) wrote,
punkwalrus
punkwalrus

LPI 102 Exam notes: 21 days until the exam

Since I goof off and LJ so much, I have decided to hijack the process and write my study notes and thoughts. But they are probably totally boring for those not interested in Linux. These notes may be very long and disjointed, so... I put them...

For those interested, think there needs to be corrections, have neat trivia, or have some things to say: COMMENTS ARE ENCOURAGED!!!
___________
LILO and GRUB

It's pronounced "LIL-LO," by the way, because it stands for LInux LOader. I think everyone calls it "GRUB" like the bug, but I am sure the guy who did our Virtuozzo training who pronounced it "Lee-NUX" and "SEN-toss" would call it "GEE-RUB" or "GROO-BEE" GRUB stands for "GRand Unified Bootloader," for those keeping score.

Almost no one uses LILO these days. But you have to know it for the LPI, so I will cover it here. Well, the first part of that statement may not be true, because I have to use LILO on this one box I have where the IDE channel is messed up (it was a prototype motherboard). I could install CentOS, but it wouldn't boot. If I booted it from a rescue CD and installed LILO as a package, then it worked. So maybe that will happen to you if you have some weird-assed hardware.

So. LILO. There are two things you need to know about LILO. The first is that the config file is in the /etc directory as /etc/lilo.conf. It's a fun little text file with NAZI-like rules. The basic lines for a kernel are simple:

image=/boot/vmlinuz-custom-kernel-U-made
label=MyCustomKernel
root=/dev/sda
read-only


Now, if you are the clever sort, you might suddenly wonder, "How can it read fron an /etc directory at boot when /etc won't be mounted yet?" Yeah, see that's the thing, isn't it? So we have to do a very important, usually forgotten step 2, which is to run the command "lilo" which is usually in /sbin/lilo. Otherwise, you'll boot and not see your kernel listed for selection. Shows you! So remember that adding a kernel in LILO requires TWO STEPS:

1. Edit /etc/lilo.conf
2. Run lilo

LILO is pretty simple, but not very flexible. Oh, sure, there are lots of options you can put in lilo.conf, but that whole two step shenanigans started some people thinking there was a better way. And so they came up with GRUB.

Now, the study guide I have barely covers GRUB for the 102, but the online test I took asked GRUB questions, and I got no LILO/GRUB questions at all during the 101. The LPI specs are a little vague, so I will cover some of the basics here.

GRUB, in its standard vanilla form, has a config file in /boot/grub/menu.lst which has all the options. Debian, for instance, puts it here. However, all Red Hat based distros puts it in /boot/grub/grub.conf and in addition, has a symbolic link /etc/grub.conf for those who were used tio LILO back in the day. Not knowing this during a repair crisis will fuck you up. So remember:

Default install on most distros: /boot/grub/menu.list
RedHat, CentOS, Fedora distros: /boot/grub/grub.conf and a link in /etc/grub.conf

Same file, different name.

GRUB is a lot more flexible, has a rescue shell, and can display graphics at boot time. As far as installing a new kernel, it's about the same, but there are more options available. But since this study guide really only goes to how to add a kernel, I won't go through install stuff.

GRUB thinks of hard drives as items in /boot/grub/device.map, which can be checked if you find you're booting off the wrong drive. It doesn't care about IDE or SCSI, either. GENERALLY, it will map to IDE then SCSI, but it looks at devices a little more differently. The GRUB device maps look like this:

(hd0) /dev/cciss/c0d0

In this case, the first hard drive is a SCSI card. It could also be:

(hd0) /dev/hda

The first IDE device.

GRUB looks are devices in it own order, and follow the pattern hdx,n where x= device, and n=partiton. Unlike devices in /dev, which start at 1, GRUB starts at 0. So:

hd0,0 = first partition on the first drive
hd0,2 = third partition on the first drive
hd1,1 = second partition on the second drive

Sometimes this confuses those used to thinking of those as /dev/hda1, hda3, and hdb2. A grub.conf kernel entry will look like this:
title CentOS (2.6.18-92.1.10.el5)
        root (hd0,0)
        kernel /vmlinuz-2.6.18-92.1.10.el5 ro root=LABEL=/
        initrd /initrd-2.6.18-92.1.10.el5.img

title is what it will be labeled on the menu on boot. Make it as desriptive as possible, yet remain brief. "Cust 2.6.13 Kernel w/new expr SCSI controller" or something.

root is the root partition (in this case, the first partition on the first drive). This will be /boot in most cases.

kernel this is the new kernel you compiled, with the path relative to /boot. Don't make the mistake pf putting it like /boot/vmzlinuz-blah because then GRUB will look for it in /boot/boot/vlinuz-blah, and fail. You add your kernel options here, too. The "ro" causes the kernel to mount the drive "read-only" initially; later the drive will be remounted read/write. This is generally done so fsck can run on / at bootup. "root" tells line in the fstab that will be your root partition to start from once the kernel has booted. There are a LOT more options available here. I set my vga=791 so that my console text is not as huge and chunky.

initrd is "initial RAM disk." It's generally used for loading modules required to initialize your root filesystem. If you have these modules compiled directly into the kernel then it's not necessary to have one, but you need to change references to LABEL= in your /etc/fstab and /boot/grub.conf to the actual devices. Some people debate whether it's necessary these days, but it's added by default in many cases.

But make sure you save the entry (and files in /boot) of your OLD kernel in case your new kernel shits the bed. Manm, some people do "rpm -u" (upgrade) with new kernels on Red Hat instead of "rpm -i" (install) and then it dies, and they don't have an old kernel.

Don't be that guy.

So now, that wasn't so hard, was it?

__________
Disclaimer: While I have been managing Linux systems for almost 10 years now, but I am mostly self-taught. I have a RHCT certification, but I am taking the LPI and CompTIA Linux+ exams to "flesh out" some of the gaps that occur from too much real-world experience versus my lack of good old fashioned book learnin'. This entry in no way assures you my thoughts are correct, I will have frequent misspellings, and they may or may not help you pass the LPI. HUGE parts of the exam will be missing because I already know half of it by heart, so using me as your only study guide is a terrible idea. Please read this entry with a healthy amount of skepticism, and PLEASE feel free to correct or add comments! My ego is hardy enough to admit when I am wrong.
Tags: bootloader, grub, lilo, linux, lpi
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments