When it comes to Linux,
the real right of passage is to build your
kernel. But for some people it is a terrifying thing to
contemplate. So we have prepared for you the beginner\’s guide to
configuring and building the kernel. You can down-load the most
recent kernel at
href=\"http://www.kernel.org\">www.kernel.org
First of all you need to do most of this work as root. I recommend
logging in as your self and then using the su command to become
root.
> su
Password: XXXXXXXX
#
Now you are dangerous.
The following steps are used to remove the current Linux directory
in /usr/src, unpack the new kernel version and then recreate the
symbolic link for the Linux directory. This is very useful so you can
keep multiple copies of the kernel source, but always know that
/usr/src/linux will take you to the most current one.
# cd /usr/src
# rm linux
# tar -zxvf ~/linux-x.x.xx.tar.gz
# mv linux linux-x.x.xx
# ln -s linux-x.x.xx linux
# cd linux
Once we have done that, are going to go in and start reconfiguring
the kernel. The first step we will do is to remove any shreds of the
last build or configure.
# make mrproper
Next we want to start the configuration menu. For this example we
will use the X version of the config tool
# make xconfig
This will start up the X based configuration menu and will give you
the opportunity to select the features of the kernel that you want to
include. Here are some tips to remember
- Zip drives need …
- PPP dial up access needs …
- Printer support needs
- Disable ISDN, IR, Watchdog, etc
- Only your Ethernet
Go through all the sections and when in doubt refer to the help
button.
Once you are complete, store your config file by clicking on the
store button and entering the full path to where you want to store
it. I recommend /usr/src/month-day-year.config that way you can keep
future copies separate. After that, click Save and Exit. You\’ll be
given a little guide as to the next steps. Next we need to make the
file dependencies
# make dep
This will make the files needed to begin making the actual
kernel. Our next step is to compile the kernel itself. Your best bet
is to make a bzImage. This is a compressed version of the kernel that
is uncompressed at boot time. At one time it was possible to compile
an uncompressed kernel, but now the kernel, even stripped down, is a
little too big for this. After we make the kernel we are going to make
the modules as well.
# make bzImage
# make modules
Now for the real tricky part. First we have to move the new kernel
image from the directory it was made in to the boot directory. Plus we
have to move the current modules out of the way do we can install the
new ones.
# cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-test
# cp /usr/src/linux/System.map /boot/System.map-test
# move /lib/modules/x.x.xx /lib/modules/x.x.xx.old
# make modules_install
After the modules get made, you will need to do a few things to get
the system ready to reboot. First you need to reconfigure lilo and
then re-run it. Also, if you are using Red Hat you need to do a little
extra.
Edit your /etc/lilo.conf and look at the primary Linux section. We
want to add another section just like it except change the names a
little
image=/boot/vmlinuz-x.x.xx
label=linux
root=/dev/hda8
read-only
image=/boot/vmlinuz-test
label=linux-test
root=/dev/hda8
read-only
Then simply rerun lilo
# lilo
Added linux *
Added linux-test
Now for the Red Hat users, you will need to do one last thing. You
need to create a file in the /lib/modules/x.x.xx directory called
.rhkmvtag. To do this just copy the contents of /proc/vers.rhkmvtag
ion.
# cat /proc/version > /lib/modules/x.x.xx/.rhkmvtag
And that\’s it. Now simply execute the shutdown command and when
your machine boots back up, press the TAB key when you see LILO start
and type in \’linux-test\’ and your new kernel will start up. If it
boots up OK, use it for a while and make sure things are OK. Once
things are running smoothly, just do a little file renaming in the
/boot directory and things will be OK.
# mv vmlinuz-x.x.xx vmlinux-old
# mv vmlinuz-test vmlinuz-x.x.xx
# mv System.map System.map-old
# mv System.map-test System.map
Change your /etc/lilo.conf to reflect the change and rerun
lilo.
image=/boot/vmlinuz-x.x.xx
label=linux
root=/dev/hda8
read-only
image=/boot/vmlinuz-old
label=linux-old
root=/dev/hda8
read-only
# lilo
By keeping the old kernel setup in lilo if anything should crop up
after a while you can always start up your old kernel again.
If you kernel didn\’t work, try to note where it failed during boot
up and just restart the system. Start up the original kernel and start
over with your previous configuration.
# cd /usr/src/linux
# make xconfig
Open your previous config file /usr/src/month-day-year.config, and
go looking for the components you still need. And then following all of
the steps again.
Once you get it right you will have a kernel compiled just for your
system. The true test of a Linux novice.
Suggested readings:






























