SLS

 
Title: buildkernel

Introduction


Simply put, this script will build a new linux kernel for you.
Its strength is that it understands the build process. This means novices
to the build process can build a new kernel without having to understand
all the intricacies of the process. Experienced users can use this to
automate the process of building a number of kernels, allowing you to
experiment with new patches and beta kernels with much less attention.

Features


Most of the following features can be enabled or disabled by user
choices. These choices can be preset in the shell environment, stored in
a configuration file, or specified on the command line. If any options
are unspecified, the script deduces intelligent defaults for them. A
number of them are checked for invalid values.
The script will download and open up the source for a kernel and
the pcmcia utilities. It removes source code that is not useful for this
machine. The necessary symbolic links are created. If the user places
patches in a particular directory, these patches will be applied
automatically (the build halts if rejects are found so that the user can
fix the patch, remove it, or reorder the patches).
While building, it will initiate multiple simultaneous builds to
make better use of the processors in the system. The builds are "nice'd"
to reduce impact on foreground tasks.
The script has a hands-off mode that, barring errors in the build
process, will complete the build without pausing for user input. If
you've already chosen your kernel configuration options, this lets the
build proceed without interruption.
The compiled kernel is configured. The resulting kernel, modules,
pcmcia modules, and System.map are copied to the correct locations.
Throughout the process, the script works hard (goes overboard?) in
checking that files and directories exist and that the build is
progressing correctly. It keeps a log of _everything_ that goes on,
including all output from programs that are run. No more frustrations
that the error messages have already scrolled off the screen.

User changeable parameters


#FIXME Tell user what the files are and which to use.
#FIXME Indicate which ones MUST be set and which ones have intelligent defaults.

If set to YES, the script will get the kernel source if it is not
already on the drive. If the user chooses NEWESTSTABLE, NEWESTBETA, or
NEWESTPCMCIA, this is forced to YES later on.
Only choices (default YES):
BKAUTOGET=NO
BKAUTOGET=YES

If you have a preferred build type, set it here. Otherwise, leave
it at the default. I suggest zImage. The script will automatically try
building "b"+whatever_you_chose if the first build failed. Unless you
_know_ the target machine has problems with bzImage, I'd leave this at
bzImage.
Examples (default bzImage):
BKBUILDTYPE=zImage
BKBUILDTYPE=zdisk

If you would like to have the kernel also copied to a floppy at
the end, set the following to YES and uncomment (for this, you should have
a floppy in the floppy drive during the entire run). The floppy _should_
_not_ be mounted (i.e., when you type "mount", /dev/fd0 should not show up
in the listing).
Only choices (default NO):
BKCOPYTOFLOPPY=NO
BKCOPYTOFLOPPY=YES

Uncomment and set to YES if debugging; generally no need to do so.
Only choices (default NO):
BKDEBUG=NO
BKDEBUG=YES

If you want buildkernel to automatically download the kernel source
tree and have a preference for a server, set it with this parameter. If
you're in a country other than the US, I would strongly suggest setting
this to a mirror site closer to you. Better yet, set up a local kernel
mirror and use that!
The server you use must publish the kernel .tar.gz's or .tar.bz2's
via ftp under the /pub/linux/kernel/vX.Y/ directory - the standard
directory structure for a kernel mirror.
Possibilities (default ftp.bz2.us.kernel.org if bzip2 is on your
system, ftp.gz.us.kernel.org otherwise):
BKFTPSITE=ftp.bz2.us.kernel.org
BKFTPSITE=ftp.gz.mx.kernel.org
BKFTPSITE=ftp.mydomain.net

If your ftp server only has one of the compresed forms of the kernel
tree, set the extension to use in the download with this variable. If
you're using one of the standard kernel mirrors, this will be
automatically detected from the mirror name.
Possibilities:
BKGETEXT=bz2
BKGETEXT=gz

If set to YES, the script will allow you to make changes to the
kernel configuration and pcmcia-cs configuration during the build process.
If set to NO, the build will try to continue without any human
interaction. If set to NO and you do not already have a kernel
configuration (or, if selected to be built, pcmcia-cs configuration), the
build will halt.
Only choices (default YES):
BKINTERACTIVE=NO
BKINTERACTIVE=YES

Which kernel would you like to build? You can technically set
this in one of the configuration files and force which kernel gets built.
It is also set with the first command line parameter (which overrrides any
configuration file entry).
Examples (default is NEWESTSTABLE):
BKKERNELTOBUILD=2.1.66
BKKERNELTOBUILD=2.0.32
BKKERNELTOBUILD=NEWESTBETA
BKKERNELTOBUILD=NEWESTSTABLE

I suggest one of the following three lines. The first actually
raises the priority of the build, speeding it up to some degree, but may
make the system unusable for other tasks. The second lets it run with no
change in priority. The third (recommended) lets the build proceed with
very little effect on other tasks running in the system. BTW, you can't
use the first unless you are root.
Examples (default 'nice -n 10'):
BKLOAD='nice -n -4'
BKLOAD=
BKLOAD='nice -n 10'

The build process keeps a log which includes the output from the
individual programs and the checks made by the script. You can set where
the file is placed after the build is done with this parameter.
A copy of this file is placed in /usr/src/configs/bklog
Examples (default '/usr/src/linux/bklog'):
BKLOGFILE='~/bklog'
BKLOGFILE='/usr/src/linux/bklog'

If set to YES, the script will clean out build files before build.
If set to NO, the script will leave any existing build files. Keep in
mind that if you set BKOPENFRESH to yes, the build files will be erased
anyways as part of removing the old source tree.
This option does _not_ apply to the pcmcia-cs package. "make
clean" will be executed before that build no matter how you have
BKMAKECLEANBEFORE set.
Only choices (default NO):
BKMAKECLEANBEFORE=NO
BKMAKECLEANBEFORE=YES

If set to YES, the script will clean out build files after build.
If set to NO, the script will leave build files in place afterwards.
Only choices (Default NO):
BKMAKECLEANAFTER=NO
BKMAKECLEANAFTER=YES

(Note: The BKINSTALLxx options are a work in progress - they may not work
correctly or at all. As of 12/27/99, The BKINSTALLxx options have no
effect - the kernel installs to the current root filesystem, with the
BKCOPYTOFLOPPY option available.)
You may very well be transporting this kernel and modules to
another system. Buildkernel offers you a few ways to carry the new kernel
to a different machine.
If BKINSTALLTAR=yes, then buildkernel will create at .tar.gz file
that you can transport to another machine. Go to the root directory of
that machine and use "tar -xzvf /path/to/newkernel-version.tar.gz". The
kernel itself will end up in /boot, and the modules in
/lib/modules/version. /etc/lilo.conf.version is a short section that can
be added to /etc/lilo.conf. The following will actually get things going
for you:
cat /etc/lilo.conf.version
/etc/lilo.conf
pico /etc/lilo.conf #replace "pico" with your favourite editor
#and make any changes you'd like. Move
#this new section to be the first once
#you're sure this kernel is the one you
#want to use by default.
lilo

If you'd prefer to install the new kernel via RPM, set
BKINSTALLRPM=yes .
If you _only_ want one of the above package types and don't want
this kernel on this system at all, change BKINSTALLHERE from its default
of yes to no.
The final choice for where this kernel goes, BKCOPYTOFLOPPY, is
documented above. Note that BKCOPYTOFLOPPY _only_ copies the kernel
itself; it does not make a lilo boot floppy and does not copy the modules.
The choices are (BKINSTALLTAR and BKINSTALLRPM default to NO,
BKINSTALLHERE defaults to YES):

BKINSTALLTAR=YES
BKINSTALLTAR=NO
BKINSTALLRPM=YES
BKINSTALLRPM=NO
BKINSTALLHERE=YES
BKINSTALLHERE=NO

The linux kernel has three interfaces to the kernel configuration.
The original choice, "config", is a one-by-one question and answer
program. It tends to be less popular now as one mistake means you have to
stop and start over. It can still be very useful if you have neither
ncurses nor xwindows installed, or use a telnet program that doesn't
handle curses well. The second choice, "menuconfig", uses the ncurses
library to give you a text mode display that lets you move back and forth
through a hierarchical display. This one's recommended if you have
ncurses available. The final choice, "xconfig", is a great graphical
version that runs under X windows with (tcl/tk?) libraries.
Only choices (default is xconfig if DISPLAY set, menuconfig if
ncurses installed, config otherwise):

BKMAKETYPE=config
BKMAKETYPE=menuconfig
BKMAKETYPE=xconfig

Number of concurrent builds to run. I suggest 1 on an
underpowered system or one that needs all the CPU and memory it can get
for foreground tasks. Otherwise I suggest setting it to the number of
CPUs in your system + 1. "1" works on any system, but may take a little
longer to complete. "CPU's+1" is the most efficient way to go. Going
beyond that may actually slow the build down because of possible additional
swapping from too many tasks taking up memory.
If you're not sure, choose "1" if you have less than 16M of
memory, "2" if you have 16M or more.
Examples (legal values are from 1 to 17, default is the number of
CPU's + 1):

BKNUMBUILDS=1
BKNUMBUILDS=2
BKNUMBUILDS=4

If set to YES, the script will open up a completely new source
tree and patch it. If NO, the script will assume that you have a kernel
in place ready to build with any patches already applied.
Only choices (default YES):
BKOPENFRESH=NO
BKOPENFRESH=YES

If you have pcmcia sockets in your system, the script can build
the pcmcia Card Services modules in much the same way as the kernel
itself. If you don't have pcmcia sockets, just leave it at the default of
NO.
Examples (default: NO):
BKPCMCIATOBUILD=2.9.11
BKPCMCIATOBUILD=NO
(future option: BKPCMCIATOBUILD=NEWESTPCMCIA)

Set the appropriate root device here. If you would like to use
whatever the current root device is, just leave it like the first example:
Examples (default: script automatically detects current root
device):
BKROOTDEVICE=
BKROOTDEVICE=/dev/hda3

This is the location (with trailing slash) where the script can
find linux-x.y.zz.tar.gz and (if building pcmcia) pcmcia-cs.a.b.cc.tar.gz
Examples (default /usr/src/source/kernel/):
BKSOURCEDIR=/usr/src/source/kernel/
BKSOURCEDIR=/tmp/

(BKTMPFILEPREFIX is no longer used...)

If set to YES, the script will keep the user updated about its
progress and any errors encountered. If NO, the script will only keep the
user informed about errors.
Examples (default YES):
BKVERBOSE=NO
BKVERBOSE=YES

This option selects which video mode is used when the new kernel
boots. For those that are used to 25 lines by 80 columns, you might want
to try some of the other choices; the characters get smaller, but you can
see more on your screen. If you're not sure which one to try, use '-3'.
When the new kernel boots, you can get a list of available modes and
choose one. '-2' is 50 X 80, '-1' is the standard 25 X 80, and 0 and
above are specific to your video card.
If you accidentally use one that you don't like, simply use the
' vga=ask' command line parameter when booting or edit lilo.conf to
permanently select one.
Examples (default '-2', which is 50 lines by 80 columns):
BKVIDMODE='-3' #ask at boot
BKVIDMODE='-2' #50X80
BKVIDMODE='-1' #25X80
BKVIDMODE='0' #card specific
BKVIDMODE='1' #card specific
BKVIDMODE='2' #card specific
BKVIDMODE='3' #card specific
etc, up to the limit of your video card. Use -3 to find out what that is.

What text editor would you like to use to edit the Makefile and
lilo.conf?
Examples (default: first found of pico, mcedit, vi, jove, nedit or
emacs):
EDITOR=vi
EDITOR=pico

I suspect HOSTNAME, HOSTTYPE, and USER are automatically set by
the kernel or, perhaps, the RedHat distribution. If the set command does
not return the appropriate Architecture, you will have to manually set it
here. I am guessing most people will NOT have to do this. To see if
these need to be set manually, type the following command:
set | grep -E '^HOSTNAME=|^HOSTTYPE=|^USER='<Enter>
If it returns three lines with values similar to the examples
below, you do _not_ have to set these manually.
If not set, HOSTNAME is set to localhost, USER is set to root, and
HOSTTYPE is set from `uname -m`.
Examples:
HOSTNAME=mymachine.mydomain.org
HOSTTYPE=i386
USER=root

Files and directories affected by this package


/boot/... New kernel and System.map copied here
/.bkrc User specific choices for buildkernel
/etc/bkrc System wide defaults for buildkernel
/lib/modules/... Kernel modules copied here
/tmp/ (probably <2M needed)
/tmp/BK* Temporary files that should be deleted at end
/usr/bin/buildkernel Actual buildkernel script
/usr/share/doc/buildkernel-x.yy/ Manuals and docs for this buildkernel (<1M needed)
/usr/include/asm Symbolic link deleted and recreated
/usr/include/linux Symbolic link deleted and recreated
/usr/include/scsi Symbolic link deleted and recreated
/usr/src/buildkernel-x.yy/ Place where buildkernel package opens up (<1M needed)
/usr/src/configs/ Dir for backups of config files and logs (<300K per version needed)
/usr/src/configs/.config.x.y.zz Kernel x.y.zz most recent configuration
/usr/src/configs/.version.x.y.zz Kernel x.y.zz last built version
/usr/src/configs/.config.mk..a.b.cc Pcmcia a.b.cc config
/usr/src/configs/.config.out.a.b.cc Pcmcia a.b.cc config
/usr/src/configs/bklog.x.y.zz Log of kernel build for version x.y.zz
/usr/src/kpatches-x.y.zz/ User created dir for automatically applied patches (probably less than 5M needed)
/usr/src/kpatches-x.y.zz/00 to 20 Up to 21 patches for kernel x.y.zz
/usr/src/linux/ Symbolic link deleted and recreated
/usr/src/linux-x.y.zz/ Dir created and filled w/ kernel source (probably <70M needed for 2.1.x kernels and below)
/usr/src/pcmcia-cs-a.b.cc/ Dir created and filled w/ pcmcia source (probably <10M needed, 0M if your system doesn't need pcmcia)
/usr/src/source/kernel/ holds source for kernel and pcmcia (4-10M per kernel source.tar.bz2, <1M per pcmcia version)

FAQ's


Q
Couldn't this be simpler?
A
Sure, try this script by Jim Bray <jb@as220.org>, submitted to the
linux-kernel mailing list:
I finally automated the patch-and-build after typing all this
a few hundred times or so:

#!/bin/bash
#kmake: patch if given, and make kernel
set -v
cd /usr/src
case $1 in
patch-*.gz) zcat $1 | patch -p0;;
esac
cd linux || exit 1;
find . -name "*.rej" -exec sh -c "echo REJECTS; kill 0" \;
find . -name "*.orig" -exec rm \{\} \;
find . -size 0 -exec rm \{\} \;
make oldconfig && make dep && make clean && make zlilo && make modules &&
make modules_install

If you have your source in place, and any patches applied, I think
you could even use:

#!/bin/bash
cd /usr/src
make oldconfig dep clean zlilo modules modules_install

Haven't tried it, though.

Q
I used buildkernel to install the latest kernel. Everything went fine.
When I tried to boot the kernel, it said "No setup signature". What's
this? I don't believe its a buildkernel problem, but I don't know.
A
You might want to check back over the build log
(usr/src/linux/bklog). Look through for errors or problems during the
build. In particular, search for the error:
"System is too big. Try using bzImage or modules."
One possibility is that you're building a 2.2.x kernel that's too
big to be stored in the zImage format (search for "bzImage" in bklog). If
the kernel build complains that the image is too large, try adding:

--BKBUILDTYPE=bzImage

to the buildkernel command line and rerun (or add:

BKBUILDTYPE=bzImage

to /etc/bkrc to build this larger kernel type by default).

Credits


This document is an edited version of Al Tourlakes' Completely Unauthorized Introduction

There are no comments on this page. [Add comment]


Warning: include(http://forums.suselinuxsupport.de/ssi.php?a=active) [function.include]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /home/customers/webs/slwiki/actions/footer.php on line 51

Warning: include() [function.include]: Failed opening 'http://forums.suselinuxsupport.de/ssi.php?a=active' for inclusion (include_path='.:/home/customers/webs') in /home/customers/webs/slwiki/actions/footer.php on line 51

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.0
Page was generated in 0.0423 seconds