####################################################################### # Searchable Keywords: kernel compile zImage vmlinux This is a simpilied kernel howto ------------------- (usually in /usr/src/linux) make menuconfig - menu based config or .. make xconfig - menu based config written for X or .. config - yes no based questions Once you have what you want in your new kernel save it and quit. then.. make dep clean zlilo *See note below* rm -rf /lib/modules/ eg. 2.0.30 make modules modules_install your new kernel is ready to test before you do all that.. make sure you have made a back up kernel cp /vmlinuz /vmlinuz.safe and make a lilo entry to that kernel named backup. So if things go wrong you can type backup at the lilo promt and be back in. The other alternitive is to replace make dep clean zlilo with make dep clean zImage *See note below* (image is in /usr/src/linux/arch/i386/boot) That will make the kernel to a boot disk.. and you boot with that The image file in /usr/src/linux/arch/(arch,i386,i586,etc) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Intel Linux Possibilies: cd /usr/src/linux # make config or make menuconfig or make xconfig(xconfig not as stable( Answer the following questions either to compile code or moduleize it or leave it out. This will build a file called .config # make dep Build dependences. I think this buildthe file .depend # make clean Clean up the objects created with make config This is where alot of the documentation differs in what step comes next and what step does what. READ this whole page. # make zImage *Earlier statments on this page have said zlilo at this point* make zImage' or `make zdisk' (this is the part that takes a long time.). `make zImage' will compile the kernel, and leave a file in arch/i386/boot called `zImage' (among other things). This is the new compressed kernel. `make zdisk' does the same thing, but also places the new zImage on a floppy disk which you hopefully put in drive ``A:''. `zdisk' is fairly handy for testing new kernels; if it bombs (or just doesn't work right), just remove the floppy and boot with your old kernel. It can also be a handy way to boot if you accidentally remove your kernel (or something equally as dreadful). You can also use it to install new systems when you just dump the contents of one disk onto the other (``all this and more! NOW how much would you pay?''). All even halfway reasonably recent kernels are compressed, hence the `z' in front of the names. A compressed kernel automatically decompresses itself when executed. # make modules builds module file # make modules_install <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Installing the kernel After you have a new kernel that seems to work the way you want it to, it's time to install it. Most people use LILO (Linux Loader) for this. `make zlilo' will install the kernel, run LILO on it, and get you all ready to boot, BUT ONLY if lilo is configured in the following way on your system: kernel is /vmlinuz, lilo is in /sbin, and your lilo config (/etc/lilo.conf) agrees with this. Otherwise, you need to use LILO directly. It's a fairly easy package to install and work with, but it has a tendency to confuse people with the configuration file. Look at the config file (either /etc/lilo/config for older versions or /etc/lilo.conf for new versions), and see what the current setup is. The config file looks like this: image = /vmlinuz label = Linux root = /dev/hda1 ... The `image =' is set to the currently installed kernel. Most people use /vmlinuz. `label' is used by lilo to determine which kernel or operating system to boot, and `root' is the / of that particular operating system. Make a backup copy of your old kernel and copy the zImage which you just made into place (you would say `cp zImage /vmlinuz' if you use `/vmlinuz'). Then, rerun lilo -- on newer systems, you can just run `lilo', but on older stuff, you might have to do an /etc/lilo/install or even an /etc/lilo/lilo -C /etc/lilo/config. If you would like to know more about LILO's configuration, or you don't have LILO, get the newest version from your favorite ftp site and follow the instructions. To boot one of your old kernels off the hard disk (another way to save yourself in case you screw up the new kernel), copy the lines below (and including) `image = xxx' in the LILO config file to the bottom of the file, and change the `image = xxx' to `image = yyy', where `yyy' is the full pathname of the file you saved your backup kernel to. Then, change the `label = zzz' to `label = linux-backup' and rerun lilo. You may need to put a line in the config file saying `delay=x', where x is an amount in tenths of a second, which tells LILO to wait that much time before booting, so that you can interrupt it (with the shift key, for example), and type in the label of the backup boot image (in case unpleasant things happen). <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You can never have enough on HOW TO COMPILE a Linux Kernel How to Compile the Linux Kernel James Andrews Introduction RedHat is not Linux, it is a distribution based on the Linux kernel. The Linux kernel is a complex program which provides the underlying services to the rest of a Linux distribution. But it is easy to add new features or improvments to it as, unlike commercial operating systems like Windows 95 or MacOS, the source code is freely available. It is common practice with a Linux based operating system to recompile the kernel from source and much effort has been put in to make this a realitively user-friendly experience. Why Compile a New Kernel? You may be thinking "But why recompile it? It works fine as it is." There are three reasons for a recompile. Firstly, you may have some hardware that is so new that there's no kernel module for it in on your distribution CD. Secondly, you may have come across some kind of bug which is fixed in a revision of the operating system. Lastly, you may have some new software which requires a newer version of the operating system. Getting the Kernel Sources The most recent releases of the kernel sources are available on ftp.kernel.org. This site is mirrored worldwide so there is probably a fast copy of it somewhere near you. Locate the file for the latest version of the operating system and download it to /usr/src. Then issue the tar zxf command to unpack it. If you do not need the very latest version, then installing a kernel source package from your distribution CD may be an easier way to proceed. Configuring For a Build Change directory to /usr/src/Linux and issue the command: make menuconfig This will build a few programs and then quickly pop up a window. The window menu lets you alter many aspects of kernel configuration. After you have made any necessary changes, save the configuration and follow these instructions--do a make dep then make clean The first of these commands builds the tree of interdependencies in the kernel sources. These dependencies may have been affected by the options you have choosen in the configure step. The make clean purges any now-unwanted files left from previous builds of the kernel. Then you are ready to go! Issue this command: make zImage and then, if you are on a machine slower than a Pentium 200, go and make a cup of tea. This takes about 20 minutes on a Pentium 90...the kernel has a lot of source code as you may have noticed when downloading it. When this is complete do a: make modules This will not take as long. Installing a New Kernel Phew, finally! The last step is installing the new kernel. On an Intel-based system the kernel is installed to the right place in /boot with the command cp /usr/Linux/src/arch/i386/boot/zImage /boot/newkernel then make modules_install This will install the modules in /lib/modules. Next, edit /etc/lilo.conf to add a section like this image = /boot/newkernel label = new read-only At the next reboot, select the kernel 'new' in lilo, and it will load the new kernel. If it works fine, move it to the first position in the lilo.conf so it will boot every time by default. Summary Compiling the kernel is a relatively simple operation- if you have done it before! At first it can seem daunting. There are many Web sites dedicated to the kernel; at the left are just a few. See also: