Welcome to the new location of Alien's Wiki, sharing a single dokuwiki install with the SlackDocs Wiki.
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | linux:kernelbuilding [2008/04/12 12:00] – Fix typo alien | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ===== Building a Linux Kernel from source ===== | ||
+ | ----------------------------------------------- | ||
+ | **This is a short recap of how I build my 2.6 kernels.** | ||
+ | |||
+ | ==== X and su ==== | ||
+ | |||
+ | I run the commands from an X terminal, and at some point start the X based kernel configurator. I run my desktop as " | ||
+ | < | ||
+ | echo $DISPLAY | ||
+ | sudo -i # or "su -" on older Slackwares | ||
+ | xauth merge ~alien/ | ||
+ | export DISPLAY=: | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Downloading and configuring ==== | ||
+ | |||
+ | Now that the build environment is set up, let us continue with obtaining the sources. | ||
+ | |||
+ | Download a new kernel, unpack it into ''/ | ||
+ | < | ||
+ | wget http:// | ||
+ | tar -C /usr/src -jxvf linux-2.6.24.4.tar.bz2 | ||
+ | cd /usr/src | ||
+ | rm linux | ||
+ | ln -s linux-2.6.24.4 linux | ||
+ | </ | ||
+ | |||
+ | You will probably notice more linux-* directories in ''/ | ||
+ | |||
+ | < | ||
+ | |||
+ | Now, get a Slackware kernel config file for a headstart during your own configuring. Pat's config files are pretty generic. By the time you read this, there might be a config for a newer 2.6 release available: | ||
+ | < | ||
+ | wget http:// | ||
+ | cp config-generic-smp-2.6.24.4-smp / | ||
+ | </ | ||
+ | zcat / | ||
+ | </ | ||
+ | Run //make oldconfig// in the kernel source directory so that the defaults are used from the .config file you just installed. Because your kernel sources are probably newer than the .config, there will be new options to choose from. You will only have to answer these (press < | ||
+ | < | ||
+ | cd / | ||
+ | make oldconfig | ||
+ | </ | ||
+ | |||
+ | You now have configured a pretty generic kernel (that is the reason why Pat calls them " | ||
+ | < | ||
+ | make xconfig | ||
+ | </ | ||
+ | |||
+ | Walk through the forest of options. What I usually change are things like: | ||
+ | |||
+ | * build the ext3 (needs the jbd driver as well) and reiser fileystem drivers into the kernel instead of compiling them as modules - I do not need to create an additional " | ||
+ | |||
+ | * enable support for dual procesessors and hypertreading - naturally this only helps if you have a HT Intel CPU, or a dual-CPU board or a dual-core CPU\\ (under " | ||
+ | |||
+ | * enable 4GB of RAM.\\ (under " | ||
+ | |||
+ | * enable the " | ||
+ | |||
+ | * set a 1000Hz timer (under " | ||
+ | |||
+ | * ... and more I can't think of right now. You can decide to disable a lot of the modules that the default config will build, to cut down on time, if you don't have the hardware in your computer. You could also looka at software suspend and CPU frequency scaling (under " | ||
+ | |||
+ | And finally save your configuration if you're satisfied. | ||
+ | |||
+ | ==== Building your kernel ==== | ||
+ | |||
+ | Now, start the build of kernel and modules, and install them to the proper places. | ||
+ | |||
+ | < | ||
+ | make bzImage modules | ||
+ | make modules_install | ||
+ | cp arch/ | ||
+ | cp System.map / | ||
+ | cp .config / | ||
+ | cd /boot | ||
+ | rm System.map | ||
+ | ln -s System.map-custom-2.6.24.4 System.map | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== Modifying lilo.conf ==== | ||
+ | |||
+ | Edit ''/ | ||
+ | image = / | ||
+ | root = /dev/hda1 | ||
+ | label = linux | ||
+ | read-only # Non-UMSDOS filesystems should be mounted read-only for checking | ||
+ | </ | ||
+ | < | ||
+ | image = / | ||
+ | root = /dev/hda1 | ||
+ | label = newkernel | ||
+ | read-only # Non-UMSDOS filesystems should be mounted read-only for checking | ||
+ | </ | ||
+ | After adding a stanza for your new kernel to ''/ | ||
+ | lilo | ||
+ | </ | ||
+ | |||
+ | Now is the time for a reboot, to test the results! In the lilo boot screen, select the " | ||
+ | If the new kernel boots fine, you can add this line to the top of ''/ | ||
+ | default = newkernel | ||
+ | </ | ||
+ | |||
+ | ===== Other packages that contain kernel modules ===== | ||
+ | |||
+ | Most certainly you will have packages installed that contain kernel modules that are not part of the default kernel. Slackware has " | ||
+ | Now, with the installation of your new kernel, you will lose these modules, and you have to recompile the sources so that the binary modules match the new kernel.\\ | ||
+ | You can get an overview of all packages that have installed a kernel module for your current kernel by running this command (i.e. you must run this command while still running your old kernel): < | ||
+ | cd / | ||
+ | grep -l " | ||
+ | </ | ||
+ | All the mentioned packages will need a recompile. | ||
+ | |||
+ | For ALSA you have a choice: either enable the ALSA driver that is part of the kernel you've just downloaded, or leave the kernel configuration like Slackware' | ||
+ | |||
+ | |||
+ | ===== Creating an initrd ===== | ||
+ | |||
+ | In case your kernel does not include the driver for your root filesystem, or a driver for your SATA bus, or other stuff that is only built as modules, your kernel will panic if it boots and can not access the necessary disks, partitions and/or files. Typically, this looks like < | ||
+ | VFS: Cannot open root device " | ||
+ | Please append a correct " | ||
+ | Kernel Panic-not syncing: VFS: unable to mount root fs on unknown block(8,2) | ||
+ | </ | ||
+ | Creating an initrd is quite simple, and I will show two cases here, one in care you have a Reiser filesystem on your root partition, and the second for the case you have an ext3 filesystem. I assume a 2.6.24.4 kernel in these example commands, if your new kernel is different, change the version number as appropriate. | ||
+ | |||
+ | * Change into the /boot directory: < | ||
+ | cd /boot </ | ||
+ | |||
+ | * Run " | ||
+ | mkinitrd -c -k 2.6.24.4 -m reiserfs</ | ||
+ | mkinitrd -c -k 2.6.24.4 -m ext3</ | ||
+ | |||
+ | * Add the line " | ||
+ | image = / | ||
+ | root = /dev/hda1 | ||
+ | initrd = / | ||
+ | label = newkernel | ||
+ | read-only # Non-UMSDOS filesystems should be mounted read-only for checking | ||
+ | </ | ||
+ | |||
+ | <note tip>I have written a shell script ([[http:// | ||
+ | ./ | ||
+ | |||
+ | # | ||
+ | # $Id: mkinitrd_command_generator.sh, | ||
+ | # | ||
+ | |||
+ | # This script will now make a recommendation about the command to use | ||
+ | # in case you require an initrd image to boot a kernel that does not | ||
+ | # have support for your storage or root filesystem built in | ||
+ | # (such as the Slackware ' | ||
+ | # A suitable ' | ||
+ | |||
+ | mkinitrd -c -k 2.6.24.4-smp -m ata_generic: | ||
+ | |||
+ | |||
+ | # An entry in ' | ||
+ | # kernel '/ | ||
+ | # Linux bootable partition config begins | ||
+ | image = / | ||
+ | initrd = / | ||
+ | root = /dev/hda7 | ||
+ | label = 2.6.24.4-smp | ||
+ | read-only | ||
+ | # Linux bootable partition config ends | ||
+ | </ | ||
+ | |||
+ | ===== Loading modules on boot ===== | ||
+ | |||
+ | Prior to Slackware 11.0, modules for your kernel were loaded either by the hotplug subsystem, or by explicit '' | ||
+ | In Slackware 12.0 and newer the 2.6 kernel the only kernel that is available. The loading of kernel modules is handled by udev and by explicit '' | ||
+ | * If ''/ | ||
+ | * Else, if ''/ | ||
+ | * Else, if ''/ | ||
+ | The **$(uname -r)** is the current kernel release. If your kernel version is '' | ||
+ | |||
+ | The Slackware 12.1 package ''/ | ||
+ | |||
+ | < | ||
+ | ''/ | ||
+ | |||
+ | ===== GPG signature ===== | ||
+ | |||
+ | The Linux kernel source archives are signed with the OpenPGP "Linux Kernel Archives Verification Key". This is a means to verify that the source code you downloaded is the original archive and has not been tampered with. The steps for this validation are outlined in this chapter. | ||
+ | |||
+ | * First, import the OpenPGP key into your GnuPG keyring; either by copying the key from the [[http:// | ||
+ | gpg --keyserver wwwkeys.pgp.net --recv-keys 0x517D0F0E | ||
+ | </ | ||
+ | gpg: key 517D0F0E: public key "Linux Kernel Archives Verification Key < | ||
+ | gpg: Total number processed: 1 | ||
+ | gpg: | ||
+ | </ | ||
+ | |||
+ | * Next, get the signature file for the kernel archive you've downloaded: < | ||
+ | wget http:// | ||
+ | |||
+ | * The final step is to run gpg on this signature file, and check what it has to report: < | ||
+ | gpg --verify linux-2.6.24.4.tar.bz2.sign linux-2.6.24.4.tar.bz2 | ||
+ | </ | ||
+ | gpg: Signature made Mon 24 Mar 2008 08:16:45 PM CET using DSA key ID 517D0F0E | ||
+ | gpg: Good signature from "Linux Kernel Archives Verification Key < | ||
+ | gpg: checking the trustdb | ||
+ | gpg: checking at depth 0 signed=1 ot(-/ | ||
+ | gpg: checking at depth 1 signed=0 ot(-/ | ||
+ | gpg: next trustdb check due at 2012-12-21 | ||
+ | gpg: WARNING: This key is not certified with a trusted signature! | ||
+ | gpg: There is no indication that the signature belongs to the owner. | ||
+ | Primary key fingerprint: | ||
+ | </ | ||
+ | Nevertheless, |