punkwalrus (punkwalrus) wrote,
punkwalrus
punkwalrus

LPI 102 Exam notes: 22 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!!!
___________

When I was a kid, I was in Cub Scouts. The "graduation" was the last step before you became a real Boy Scout. After gaining so many patches, badges, beads, and ribbons, I managed to achieve the highest badge you could get as a Cub. Past the Bobcat, Bear, Wolf, and Webelo. Only three people including myself got it out of the entire 300+ pack. "The Arrow of Light." Such a big deal was made about getting this patch as a Cub Scout. We had a ceremony and everything. My mother was given a gold pin.

But the truth was, as a Boy Scout, it was the first badge you got. It was back to the beginning, and wasn't such a big deal anymore. If I had just waited, I would have had it handed to me my first few months as a Boy Scout unless I seriously screwed up or something. While this isn't really why I quit scouts (I just didn't care for my fellow scouts, and our den leader wasn't very good), I was a little amused by the whole thing.

And that's how I feel about compiling a Linux kernel. In fact, when I *first* started working with Linux, it was only version .93 or something, and I was working with some technical guys to compile it on a new 16-bit Motorola chip platform for reasons I won't go into, unless at least one my readers wants to explain that day in 1994 in Fort Washington. Essentially, we failed and gave up. But I learned a little about what "compiling" was, and why you needed "libraries." It seemed so flippin' hard! Nothing would work, and the compiler we had for the platform (A Borland derivative, I think) was experimental at best for that platform. We didn't have enough RAM (only 1mb), and we couldn't compile it on another UNIX system and get it to the existing system because their floppy drives were incompatible (really). For many years, "Compiling" anything, especially an Operating System, was like the end-all-to-be-all in my head. Like if I could do that, I could do anything. Now I can compile them in my sleep, and depending on the resources, I might sleep though most of it; I had one Gentoo build that took 2 days.

But now it seems so simple and basic in the scope of things.

The Linux kernel is released in versions that are major.minor.patch-level. major is 1.x or 2.x. Each of those kernels are so far different from one another, it's not even funny. I don't know anywhere a 1.x kernel is still used, even though I am sure one is out there. Minor is point something, like 2.4 versus 2.6. Those are still vastly different. Then you have patch level, which is like 2.6.13 versus 2.6.18 or something. These represent bugfixes and new features.

In order to compile a kernel, you need a C compiler (usually gcc), assembler, linker, and make, which is a core tool for all this stuff. But even that's making it sound hard. Want to see how easy it is?

1. Download kernel source
2. Unpack it to /usr/src/$new_kernel_version
3. Run a few make commands
4. One of them will take you through to choose options
5. Compile (the long wait part)
6. Install, don't delete the old one, boot.

Viola! New kernel. Okay, it's got some extra steps. Step #4 will take the most brain power. You have three choices, no matter what config menu you want to use.

Yes, I want that feature compiled in the kernel. Some things just can't be loaded as a module, like your primary hard drive controller or filesystem. How would you boot to load a module if it can't read the hard drive?
Load as a Module. This is good for any module that doesn't HAVE to be loaded at primary boot, and is useful for when you want to change modules without rebooting the system (like a new sound card or something).
No, don't compile this. Why compile a tape drive controller if you have no tape drive? Your 686-based CPU won't ever use a 486 set of instructions. Of course, some people go gaga and trim the kernel down to the most minute fraction of operation. if you're not careful, you'll forget to compile something you may need that don't seem related, like SCSI for an IDE CD-ROM.

You have the option to make config (step by step y/m/n questions, very long, and very tedious), make menuconfig (a popular n-curses aka "DOS-like" menu interface), make xconfig (an exciting GUI with buttons and shadows), and make oldconfig (loads your old config, so all you need to do is make changes, which will save a lot of time in some cases). All this will make your ".config" file.

So, the usual order is this:
1. make clean - clean up old files and links. Always do this.
2. make mrproper - this will wipe out your settings. Only use this when you want to start from scratch.
3. make config/menuconfig/xconfig/oldconfig (depending on your choice)
4. make dep (made dependencies -- only for 2.4.x kernels, 2.6 doesn't need this anymore)
5. make bzImage (make a compressed Linux kernel image for boot loading)
6. make modules (compiles the modules you need)
7. make modules_install (installs the modules)
8. make install

Now you have a kernel in arch/i386/boot/bzImage. Copy that to /boot (cp -p, to preserve permissions), adjust your boot config (LILO or GRUB), don't erase the old kernel, reboot, and do whatever. You'll make a lot of mistakes at first, which will piss you off because of the long compile time, and you may be bummed out that all that work of removing every piece of unneeded kernel options saved a whopping 6k of memory or something.

Oh, how do you add to LILO and GRUB? I'll cover that later. This post is long enough.
__________
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.
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