Installing Linux Kernel-2.4.16

Estimated build time:           3 minutes
Estimated required disk space:  132 MB

Installation of the Linux Kernel

We won't be compiling a new kernel image yet. We'll do that after we have finished the installation of the basic system software in this chapter. But because certain software needs the kernel header files, we're going to unpack the kernel archive now and set it up so that we can compile the packages that need the kernel.

The kernel configuration file is created by running the following command:

make mrproper &&
yes "" | make config &&
make dep &&
cd $LFS/usr/include &&
cp -a ../src/linux/include/linux . &&
chown -R root.root $LFS/usr/include/linux &&
mkdir asm &&
cp -a ../src/linux/include/asm/* asm &&
chown -R root.root $LFS/usr/include/asm

Command explanations

make mrproper: This will ensure that the kernel tree is absolutely clean.

yes "" | make config: This runs make config and answers with the default answer to every question the config script asks the user (it does this by simply doing the equivalent of hitting the Enter key, thus accepting the default Y and N answers to the questions). We're not configuring the real kernel here, we just need to have some sort of configure file created so that we can run make dep next that will create a few files in $LFS/usr/src/linux/include/linux, like version.h, among others, that we will need to compile Glibc and other packages later in chroot.

make dep: make dep checks dependencies and sets up the dependencies file. We don't really care about the dependency checks, but what we do care about is that make dep creates those aforementioned files in $LFS/usr/src/linux/include/linux we will be needing later on.

cp -a ../src/linux/include/linux . and mkdir asm && cp -a ../src/linux/include/asm/* asm: These commands copy the kernel headers in the $LFS/usr/include directory.

chown -R root.root $LFS/usr/include/linux and chown -R root.root $LFS/usr/include/asm: These commands change the ownership of the $LFS/usr/include/linux and the $LFS/usr/include/asm directories, plus all the files contained therein to the user root and group root.

Why we copy the kernel headers and don't symlink them

In the past, it was common practice for people to symlink the /usr/include/linux and asm directories to /usr/src/linux/include/linux and asm respectively. This is a bad idea as this extract from a post by Linus Torvalds to the Linux Kernel Mailing List points out:

I would suggest that people who compile new kernels should: 

 - not have a single symbolic link in sight (except the one that the 
   kernel build itself sets up, namely the "linux/include/asm" symlink 
   that is only used for the internal kernel compile itself) 

And yes, this is what I do. My /usr/src/linux still has the old 2.2.13 
header files, even though I haven't run a 2.2.13 kernel in a _loong_ 
time. But those headers were what glibc was compiled against, so those 
headers are what matches the library object files. 

And this is actually what has been the suggested environment for at 
least the last five years. I don't know why the symlink business keeps 
on living on, like a bad zombie. Pretty much every distribution still 
has that broken symlink, and people still remember that the linux 
sources should go into "/usr/src/linux" even though that hasn't been 
true in a _loong_ time.

The relevant part here is where he states that the headers should be the ones which glibc was compiled against. These are the headers which should remain accessible and so by copying them, we ensure that we follow these guidelines. Also note that as long as you don't have those symlinks, it is perfectly alright to have the kernel sources in /usr/src/linux.

Contents

The Linux kernel package contains the Linux kernel.

Description

The Linux kernel is at the core of every Linux system. It's what makes Linux tick. When a computer is turned on and boots a Linux system, the very first piece of Linux software that gets loaded is the kernel. The kernel initializes the system's hardware components such as serial ports, parallel ports, sound cards, network cards, IDE controllers, SCSI controllers and a lot more. In a nutshell the kernel makes the hardware available so that the software can run.

Dependencies

Linux-2.4.8 needs the following to be installed:


sh from the bash package

ar from the binutils package
as from the binutils package
ld from the binutils package
nm from the binutils package
objcopy from the binutils package

chown from the fileutils package
cp from the fileutils package
ln from the fileutils package
mkdir from the fileutils package
mv from the fileutils package
rm from the fileutils package

find from the findutils package
xargs from the findutils package

gcc from the gcc package

grep from the grep package

make from the make package

awk from the mawk package

depmod from the modutils package
genksyms from the modutils package

hostname from the net-tools package

sed from the sed package

basename from the sh-utils package
date from the sh-utils package
expr from the sh-utils package
pwd from the sh-utils package
uname from the sh-utils package
whoami from the sh-utils package
yes from the sh-utils package

cat from the textutils package
md5sum from the textutils package
sort from the textutils package
tail from the textutils package
touch from the textutils package
tr from the textutils package