****************************************************************************** Andy Bailey's kernel building guide for Newbies. This is Alpha release 0.1 This document is intended to be a guide for kernel building, for those unfamiliar with the process. Last year, several people looked over this document for accuracy. I've lost all the names and addresses, but consider yourselves thanked :) ******************************************************************************* SECTION 1.1 Compiling a kernel that is optimized for your system is one of the most impo rtant things one can do to make Linux perform well. Unfortunately, it's also a rather daunting task for someone whos never compiled anything, much less the main element of an operating system. Fortunately, the process developed for compiling your own Linux kernel is one that is fairly intuitive, and not part icularly difficult. The kernel is the basic operating system. Its performance and stability set, in effect, the performace and stability of your entire system. The kernel also handles communication with I/O devices and ports. Using MS-DOS, devices aside from the standard ports (COM, LPT) , and drives used a piece of code called a driver. In Linux, support for only the most basic hardware is included by default. Additional support must be included in the ker nel by recompiling. Usually, a distribution of Linux (as in the case of Slackware) include a unn eccesarilly large kernel, that includes drivers for a plethora of hardware. Thi s allows users to get the operating system installed on a variety of configurat ions. Then, the installation procedure will install a kernel, with a relatively small selection of hardware drivers. This kernel will be used when booting from the hard disk, and is often the kernel that is placed on the boot diskette that the installation procedure creates for you. Sometimes hardware that worked when performing the installation is no longer recognized! SECTION 1.2 Several things are necessary in order to build your new kernel. You will need gcc-2.4.5 or higher installed, in order to compile the source. Generally, gcc and make are installed and configured when installing from an package such as Slackware. Another important topic is memory. A kernel can be successfully compile in 4 MB of Ram, but only if a sizeable swap file (of around 12 - 16 megs) is present . Use the "free" command to make sure you have a swap file enabled. SECTION 2.1 The first step is to obtain the source for the new kernel. There are several ways in which you can get the kernel source. One is to use the source for the kernel that is included on the distribution of Linux you are using. You can also find these sources for newer releases of the kernel at several FTP sites around the world. Once you have obtained the kernel source, you'll need to unzip and untar it. Generally the command for this will look somewhat like the following: mv linux-1.x.x.tar.gz /usr/src tar -xvzf linux-1.x.x.tar.gz [ 'x' represents the kernel revision ] This should put the kernel source into the /usr/src/linux directory of your dr ive. There are several other methods by which kernel source is obtained. Sometimes the source can be updated without being completely changed. This is called a pa tch, and is generally the way some small shange interim releases come out. Patches are discussed in an Appendix at the end of this document. SECTION 2.2 At this point, its time to configure and build your personal kernel. The first thing you should do is prepare for emergency. The kernel build isn' t in any way hazardous to your system, but it's possible to accidentally erase important files when you are logged in as root. Backup if you can, and be sure you have a boot floppy, with your old kernel, handy. If you don't have one, you can make it now. Put a blank DOS formatted floppy into drive A: cp /vmlinuz /dev/fd0 rdev -R /dev/fd0 1 This creates a rescue disk with which your Linux system can be booted mcopy /vmlinuz a: This simply put a copy of the kernel on a DOS diskette Now that you're ready to go on, go to directory /usr/src/linux. If your kerne l source is installed properly, you're ready to proceed. "Make" is the prog ram used to manage the compilation. Read the man page for make, for more information. To decide on which options to include in the kernel Type: make config Make will begin to run, and you will be presented with a list of questions abou t devices which you would like to include in the kernel. You wont gain any perf ormance by including lots of extra hardware. In fact, this will make a larger kernel, which takes up more memory. You may want to answer yes to any hardware you plan to purchase soon, if you don't want to recompile again. There is a large amount of hardware support offered, and its important to include everything you'll need. If you should accidentally answer incorrectly, you can stop the make (hit ctrl-c) and start over. The options in the configur ation change as new kernels are released, so examine Appendix A. for a descrip tion and recommendation of which support you should install. Once the config is done, its time to prepare the source to be compiled. Type: make dep ; make clean This will set up dependencies, and clean up any outdated object code that might be in one of the subdirectories. This is especially important if you have compi led a kernel previously, and have installed a newer kernel source package over it. Now you can move on to the build. To start the build, be sure you're in /usr/src/linux Type: make zlilo This will build the kernel based on your desired configuration, and install it into LILO for you. After the build and install are complete type: rdev -R /vmlinuz 1 to set up read-only status. SECTION 2.3 BOOTING FROM A FLOPPY In order to boot the new kernel from a floppy, it needs only to be copied to a formatted disk (DOS format is fine) that can be used in the boot floppy drive (fd0). Type: cp /vmlinuz /dev/fd0 rdev -R /dev/fd0 1 The disk can now be used to boot. APPENDIX A: Descriptions of drivers for config Generally, it is ok to accept defaults for support you aren't familiar with (except device drivers). The configuration script is designed with ease of installation in mind. The following lists some of the available options. Kernel Math Emulation If your machine does not posess a math coprocessor, you will need to include floating point math emulation. If you do have a math comprocessor, this isnt necessary. Normal Hard Disk Support Support for IDE hard drives. Most PC's are configured with such drives. Include this support. XT harddisk support Support for MFM/RLL type Hard Drives. Not neccessary, if your system does not have such a drive. TCP/IP networking If you plan to use TCP/IP network sevices, even via loopback, include this. Limit memory to low 16MB Limits addressing of ram in machines with older DMA controllers. System V IPC Sys V Inter-process-communication Use -m486 flag for 486-specific optimizations Takes advantage of extra features in the 486 cpu. If you have a 486 cpu, include this. Using this option on a 386 wont increase speed, and will make a slightly slower kernel. * SCSI support * If your system uses any SCSI devices (Hard Drive, cd-rom, tape backup) then include this. Leave it out if you do not use any SCSI devices. Under the SCSI configuration, if you choose to include it, you will be prompted for devices, and then controller drivers. Include support for only those devices which your system posesses. It may be necessary to consult the SCSI-Howto if you are unsure about what kind of scsi controller you use. * Network device support * Include this if you will be using TCP/IP other than loopback only. This section will ask you about the type of ethernet card you use. Again, select only those drivers matching equipment in your system. If you wish to have support for SLIP, you can select it after including Network device support. * cd rom drivers * Sony CDU31A CDROM driver support notes have been included, because many of these drives are marked differently outside, but with no manufacturer's name. Include this if you have a Sony cdu-31A or cdu-33A cd rom drive. [note: this drive has a spring pop out caddy-less drawer, and a rectangular green LED just beneath it] Mitsumi CDROM driver support Include if you have this cd-rom drive [note: this is the very common cd reader, in which the whole drive chassis slides out for cd insertion] Matsushita/Panasonic CDROM driver support Include if you have this drive. [note: This is the kind of drive that is usually included with the Creative Audio multimedia kits. It has a caddy-less motorized drawer, which makes it recognizable, but has no external identifying marks] * filesystems * - Standard (minix) fs support Support for the standard file system. Include this. - Extended fs support Support for the obsolete extended file system. Don't include this unless you have a partition that uses the old exfs. - Second extended fs support Include this. This is the de facto Linux Native file system. - xiafs filesystem support Commonly used on Linux floppies - msdos fs support Include this if you plan to access information from a DOS partition of your Hard drive or DOS formatted floppies. Its advisable to include this. - /proc filesystem support Include this - ISO9660 cdrom filesystem support Include this if you use a cd-rom drive - OS/2 HPFS filesystem support (read only) Include this if you would like to read from an OS/2 HPFS partition. - System V and Coherent filesystem support Include this if you need to read or write a Coherent or SYS V file system. * character devices * - Parallel printer support Include this if you use a parallel printer If you have one of the foollowing mice, include it. Serial mice are included my default (Microsoft, Mouse Systems, Logitech serial, etc) Logitech busmouse support (Logitech mice using a interface card) PS/2 mouse (aka "auxiliary device") (mice with a small round connector plug) C&T 82C710 mouse port support (as on TI Travelmate) Microsoft busmouse support (microsoft mouse using an interface card) ATIXL busmouse support (mouse connected to ATI Graphics card) - Selection (cut and paste for virtual consoles) Include this if you'd like to be able to use a pointing device to manipulate text on the terminal screen. - QIC-02 tape support support for QIC 02 and 117 tape drives - QIC-117 tape support * Sound card support * Include this if you use a sound card, or a PC speaker sound driver. * Kernel hacking * It's not neccessary to include this. APPENDIX B Using patches It is sometimes possible to obtain a tarred and gzipped pre-patched kernel, especially with stable releases (like 1.0.9). If you'd like to experiment with Alpha kernel (series 1.1.x), you can upgrade to a new version by obtaining a patch, rather than downloading the entire source tree. Its possible to update the source to a greater revision, without replacing all the source code. This is done with patches. Generally, the patch will be one tar'red and gzipped file. For example, if your current kernel is 1.1.21, and you would like to upgrade to 1.1.22, simply obtain patch22.gz. Unzip it in the /usr/src directory, and: Type: patch -p0 < patch22 If there are several patchfiles, repeat the step for each patch file name. If you would like to patch up to version 1.1.50, obtain patches 23-50, and repeat the process for each one. Then follow the regular build process, making certain to make dep ; make clean, to ensure a proper build. APPENDIX C -Where to get the source Kernel source is available on most Linux ftp sites. sunsite.unc.edu /pub/Linux/kernel/v1.x (x is series) tsx-11.mit.edu /pub/linux/kernel/v1.x ftp.funet.fi /pub/OS/Linux/PEOPLE/Linus/v1.x