[Techtalk] Kernel Building (was Re: Simply Hardware 3B)
Kai MacTane
kmactane at GothPunk.com
Tue Aug 20 22:48:24 EST 2002
At 8/20/02 08:56 PM , Andrew wrote:
> As the guy who started this thread I am now scared to the
> bone...that's two references to building a kernel...(-: (-; :-) whhaat
> am I in for????
Hi, Andrew. Building a kernel is actually not nearly as scary as people
generally make it out to be. Not that it's a walk in the park, but it's not
brain surgery, either.
If you look at the Kernel HOWTO, at
<http://www.tldp.org/HOWTO/Kernel-HOWTO.html>, it will give you a general
idea of what's involved in the process. Basically, it's going to look like
this:
make menuconfig (or xconfig, or just plain config, as desired)
make dep
make
make bzImage
cp arch/i386/boot/bzImage /boot/some-name-you-choose
make modules (optional)
make install
make modules_install (optional)
vi /etc/lilo.conf
lilo
[cross fingers]
shutdown -r now
I'm not going to go into all of those in detail -- that's what the Kernel
HOWTO is for, and it does it better than I could, anyway. But I will point
out a few things that are fairly important in doing a kernel compile, both
personal qualities and steps to perform:
1) The ability to *carefully* and *precisely* follow directions.
Forgetting or mistyping any step in this process can easily leave your
machine non-bootable. Even after this, it can probably still be recovered
-- but it really sucks. A screw-up will likely mean you have to go back to
the starting point, and that's after you manage to get back to a bootable
configuration at all.
2) The ability to keep your cool and not panic.
If anything *does* go wrong, it's very easy to think, "Ohmigod, I've nuked
my entire machine!" It's also very easy to think "I'm *completely* in over
my head; I have *no clue* what to do next!" Don't give in to these
thoughts. Just take a few deep breaths, and calmly back out to a
last-known-good configuration.
3) Do *NOT* abandon your old kernel!
You can keep your old kernel around while making the new one the default to
boot from. Then, if something goes wrong, you can just Ctrl-Alt-Del twice
and select the old kernel at the LILO prompt. This is a total lifesaver.
4) Before doing anything involving /usr/src/linux*, make sure you
know if that directory is real or a symlink!
Generally, only one of the /usr/src/ directories is real, and the others
are symlinks to it. Be real careful about deleting, or even about running
"make clean"; you can accidentally wipe out the wrong source tree. This
will not crash your machine or anything, but can force you to re-download
many megabytes of source, which is annoying and inconvenient.
5) Don't forget to re-run LILO!
After editing /etc/lilo.conf, you need to run lilo (just "lilo", on its
own, from a command prompt; no arguments necessary). This makes it actually
read the changes you've made and apply them to its map file in the boot
sector. Otherwise, on your next boot, LILO will get as far as "LI" and
hang. Easy to forget to do, and easy to diagnose when you see it happen,
but rather difficult to recover from.
6) Have some spare boot media around.
I recommend LinuxCare's Bootable Business Card (BBC), which fits on one of
those micro-CDs and has everything you need to recover a non-bootable
system. Information, FAQ and ISOs available at http://www.lnx-bbc.org/.
(For one thing, this is what you can use to fix the situation caused by
forgetting to re-run LILO. This is also what saved my bacon once when I
tried a new kernel, and it froze, and then when I tried to back out to the
previous one, I found that LILO wouldn't take any keyboard input! Without a
BBC, I'd have been very screwed.)
As you might guess, the last three points are ones I've learned from
personal experience. However, I've also learned from personal experience
that building your own kernel is something that the average Linux user
*can* do. My first kernel build came only a few months after my first Linux
install, though I'll admit it sure helped that I had an experienced
sysadmin helping me through it. But, since that first one, I've done at
least three or four others, including one where I'd applied a third-party
patch to 2.4.1 to add in large IDE drive support. It can be done, and not
just by kernel hackers and uber-l33t d00ds, but even by us mere mortals.
But let's get all the way through your BIOS routines first... :)
--Kai MacTane
----------------------------------------------------------------------
"Three o'clock in the morning/It's quiet and there's no-one around,
Just the bang and the clatter/As an angel runs to ground,
Just the bang and the clatter/As an angel hits the ground."
--U2,
"Stay (Faraway, So
Close)"
More information about the Techtalk
mailing list