April 26, 2019

New HOWTO: The Linux Kernel HOWTO - page 6

Table of Contents

  • April 2, 2001
  5.  Compiling the kernel

  5.1.  Cleaning and depending

  When the configure script ends, it also tells you to `make dep' and
  (possibly) `clean'.  So, do the `make dep'. This insures that all of
  the dependencies, such the include files, are in place. It does not
  take long, unless your computer is fairly slow to begin with.  For
  older versions of the kernel, when finished, you should do a `make
  clean'.  This removes all of the object files and some other things
  that an old version leaves behind. In any case, do not forget this
  step before attempting to recompile a kernel.

  5.2.  Compile time

  After depending and cleaning, you may now `make bzImage' or `make
  bzdisk' (this is the part that takes a long time.).  `make bzImage'
  will compile the kernel, and leave a file in arch/i386/boot called
  `bzImage' (among other things). This is the new compressed kernel.
  `make bzdisk' does the same thing, but also places the new bzImage on
  a floppy disk which you hopefully put in drive ``A:''.  `bzdisk' 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
  `bz' in front of the names. A compressed kernel automatically
  decompresses itself when executed.

  In older kernels, you don't have the option to build a bzImage; it was
  simply a zImage. That option is at the moment still available,
  however, given the code size of newer kernels, it is now more or less
  mandatory to build a bzImage because the older methods can't handle a
  kernel that's just too large.

  5.3.  Other ``make''ables

  `make mrproper' will do a more extensive `clean'ing.  It is sometimes
  necessary; you may wish to do it at every patch. `make mrproper' will
  also delete your configuration file, so you might want to make a
  backup of it (.config) if you see it as valuable.

  `make oldconfig' will attempt to configure the kernel from an old
  configuration file; it will run through the `make config' process for
  you. If you haven't ever compiled a kernel before or don't have an old
  config file, then you probably shouldn't do this, as you will most
  likely want to change the default configuration.

  See the section on modules for a description of `make modules'.

  5.4.  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 bzlilo' 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
  bzImage which you just made into place (you would say `cp bzImage
  /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

  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).

Most Popular LinuxPlanet Stories