HOWTO - Compiling the Linux Kernel |
Linux is one of the fastest growing operating systems now with millions of followers around world. Some of it's many features are:Its sources are freely available and bootable distributions can be purchased on CD-ROM's or downloaded from many sites. I got my initial distribution ( slackware at sunsite or the slackware home) from sunsite.unc.edu.
- It's fully POSIX compliant at the system call level
- It looks and acts exactly like UN*X without the pesky USL or UNIVELL or whomever-owns-the-UNIX license fees that add hundreds or thousands of dollars to an otherwise open operating system
- Sources are freely available (in fact it's demanded by the GNU copyright which is generally accepted for most of the software pieces and for the kernel)
- Hundreds of people are upgrading and bug-fixing the code
- Several newsgroups cover various aspects of Linux
- Supports X11 windows
- What I like about it ... it's all FREE!
Requires a 386 machine or better with standard non-proprietary bus (almost anything except IBM MCA). (There are also versions for the DEC alpha and the Sun sparc.)The following is a check-list that I use to install a new kernel version. This information can be gleaned from the Makefile, Configure script, several Linux HOWTO's, trial-&-error. In other words, I had to hunt around alot to compile my first kernel (back with version 1.1.45). I keep a journal of what I do when I modify my computer configuration and have standardize on this simple procedure. In the following xx.xx.xx refers to the version & patch level of the kernel to be installed (e.g. 1.3.71). The commands will be in this style
You should now have a bootable Linux system from the new kernel. Congratulations!
- Print out the old kernel configuration file for future reference
lpr /usr/src/linux/.config (or whatever command you use to print out files)- Remove old /usr/src/linux symbolic link
rm /usr/src/linux- Make a new directory for the new sources
mkdir /usr/src/linux-xx.xx.xx- Make a symbolic link from this new directory to /usr/src/linux
ln -s /usr/src/linux-xx.xx.xx /usr/src/linux- Untar the sources (I assume the gzipped tar file is in /tmp
cd /usr/src
tar -xzf /tmp/linux-xx.xx.xx.tar.gz- Install any kernel patches that may be desired. I have a special directory (/usr/src/kpatches) where I run it all from a single script (KERNEL.PATCH).
cd /usr/src/kpatches
KERNEL.PATCH
- In the new kernel source directory run the `Makefile'
- make mrproper (optional if starting from scratch with this distribution)
- make config (refer to the .config file from the older version).
Can specify menuconfig or xconfig instead for a menu driven configuration.- make dep (establishes the dependencies between header files and sources)
- make zImage (this creates the actual kernel image, this will take some time)
- make modules (creates the loadable modules)
- make modules_install (places the loadable modules at /lib/modules/xx.xx.xx)
- Remove the old /vmlinuz, which should be a hard link to something else. (You don't want to entirely remove your old kernel image ... if for some reason the new one doesn't run at all, you're not stranded without a bootable Linux system.)
rm /vmlinuz- Copy the new kernel into place
cp /usr/src/linux/arch/i386/boot/zImage /vmlinuz- Make a hard link to something else for safe keeping of the kernel image
ln /vmlinuz /vmlinuz.xx.xx.xx- Make the kernel permissions restrictive to non-root
chmod 700 /vmlinuz /vmlinuz.xx.xx.xx- Have the kernel set the boot filesystem to read-only when starting up
rdev -R /vmlinuz 1- Make a bootable floppy
dd if=/vmlinuz of=/dev/fd0 (copies kernel image to the 1st floppy device)
rdev /dev/fd0 /dev/hda2 (tells boot floppy kernel which file system is the root (/) file system. You need to set this for your own configuration).- Be sure the source directories are readable since a lot of software depends on access to the Linux kernel header files
cd /usr/src
chmod -R a+rX linux- Configure lilo to see the new kernel (and keep access to the old one ... just in case). I've got the lilo configuration file under revision control so that I can ``back-out'' any of my screw ups.
cd /etc
co -l lilo.conf
(edit lilo.conf to point to the new kernel image and to the old. See the lilo documentation for further details)
co -l lilo.conf
lilo
ci lilo.conf
Last Modified:
Brought to you by: R.K. Owen,Ph.D.
This page is http://owen.sj.ca.us/rkowen/howto/linux.kernel.html