Kompiling the Kernel

A presentation by

Tyson A. Tucker B.S.

Who am I?

UN*X Admin

Began using Linux in 98

Primary OS ever since

Agenda

Kernel basics

Configuring and Compiling

Installation

Kernel Basics

Kernel (n) : a central or essential part

Interface between user programs and computer hardware

Its like the force – it holds the universe together inside your machine

Architecture

monolithic vs. microkernel

The Tanenbaum-Torvalds debate

Linus decided on monolithic kernel

It is/was the 'Old' way

Simpler – Less IPC overhead – Just Works(TM)

contrast Mach/HURD, Windows

POSIX compliant for portability

All bits built at once

Modules

Drivers implemented as removable bits of code

Can (usually) remove driver, recompile, re-insert

Mix & match between kernels

Doesn't have to be for hardware

crypto support

ipv6

Things that aren't modules

Core bits such as processor type, memory layout (<1gig, 4gig, 64gig), etc

Configuration bits within modules

To module or not to module?

Pros

Kernel Size

Memory

Cons

Modules cause problems

Some drivers work better compiled in (3c509)

Booting - if you don't use initrd's you need fs, block devices (hard drive) compiled in

Configuring and Compiling

make config|menuconfig|xconfig|gconfig|oldconfig

make dep (only for <= 2.4)

make

The Configers

xconfig/gconfig – qt/gtk widgets

menuconfig – ncurses interface

config – original text/console interface

oldconfig – like config but only asks about new kernel options

.config

Example of the Tao of Linux

Contains all configuration of the kernel

Can be edited by hand, options are either included, not included or selected to be modules:

CONFIG_EFI=y

# CONFIG_MATH_EMULATION is not set

CONFIG_ACPI_BATTERY=m

Kernel option exists to make the running kernels' config available via /proc/config.gz

Configure new kernel

tar -xjvf linux-new.tar.bz2

cd linux-new

copy /old/config/file .config

make oldconfig

-- or --

zcat /proc/config.gz > .config

make oldconfig

Patching

Normally:

cd linux-<ver>

patch -p1 < /path/to/patch

--or--

zcat /path/to/patch.gz | patch -p1

-mm tree

tons of patches not yet accepted into main tree

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6

Compiling

Since ~2.6

make

<= 2.4

make dep

make bzImage

make modules

Help and Clean

make help

Lists lots of useful options.

make clean

Removes .o files, leaves .config.

make mrproper

Like some source packages distclean/realclean options. This will delete .config.

Doing a make clean or mrproper sometimes fixes compile bugs.

Installing

two steps:

make modules_install

make install

Installs to:

/lib/modules/<version>

/boot/vmlinuz-version

/boot/initrd-vmlinuz-version

If you love the pain

If make install doesn't work, this covers all distros:

cp arch/i386/boot/bzImage /boot/vmlinuz-<ver>

vi /etc/lilo.conf || vi /boot/grub/menu.lst

lilo	# only if you use lilo

mkinitramfs || mkinitrd	# only if you use initrds

Packages?

make deb-pkg

make rpm-pkg

make targz-pkg

3rd party:

debian: make-kpkg

module-init-tools

Transition from 2.4 to 2.6 (usually) requires the package module-init-tools:

http://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/

How to be bleeding edge

Patch from the -mm tree.

Or pull from Linus's git tree. http://linux.yyz.us/git-howto.html

Review

Kernel basics

Configuring and Compiling

Installation

links

ftp://ftp.us.kernel.org/pub/linux/kerne/v2.6

http://www.oreilly.com/catalog/opensources/book/appa.html

ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6

http://ftp.kernel.org/pub/linux/kernel/people/rusty/modules/

http://linux.yyz.us/git-howto.html

http://en.wikipedia.org/wiki/Wildebeest

2006-07-07T21:42:19