home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / HOWTO / KERNEL-H < prev    next >
Encoding:
Text File  |  1995-04-20  |  31.9 KB  |  949 lines

  1.   The Linux Kernel HOWTO
  2.   by Brian Ward, ward@blah.tu-graz.ac.at
  3.   version 0.2, 3 Jan 1995
  4.  
  5.   This is a detailed guide to kernel configuration, compilation, and
  6.   upgrades.
  7.  
  8.   1.  Introduction
  9.  
  10.  
  11.   This is release 0.2 of the Kernel-HOWTO. Is this document for you?
  12.   Well, if you've got any of the following symptoms:
  13.  
  14.  
  15.  
  16.   o  ``Arg! This wizzo-46.5.6 package says it needs kernel 1.1.193 and
  17.      I've still only got release 1.0!''
  18.  
  19.   o  There's a device driver in one of the newer kernels that you just
  20.      gotta have
  21.  
  22.   o  You really have no idea at all how to compile a kernel
  23.  
  24.   o  ``Is this stuff in the README really the whole story?''
  25.  
  26.   o  You came, you tried, it didn't work
  27.  
  28.   o  You know how to compile and install a kernel, and people seem to
  29.      know this. Therefore, they keep whining to you to help them install
  30.      their kernels.
  31.  
  32.  
  33.   1.1.  Assumptions
  34.  
  35.   Some of the examples in this document assume that you have GNU tar,
  36.   find, and xargs. These are standard with distributions. It is also
  37.   assumed that you know your system's filesystem structure; if you
  38.   don't, it is critical that you keep a written copy of the mount
  39.   command's output during normal system operation (or a listing of
  40.   /etc/fstab, if you can read it). This information is important, and
  41.   doesn't change unless you repartition your disk, add a new one,
  42.   reinstall your system, or something similar.
  43.  
  44.  
  45.  
  46.   2.  Some questions that usually come up before anything else
  47.  
  48.  
  49.  
  50.   2.1.  What does the kernel do, anyway?
  51.  
  52.  
  53.   In Unix, the kernel does a lot of things. First, it does all of that
  54.   memory management for all of the running programs (processes), and
  55.   makes sure that they all get a fair (or unfair, as the case may be)
  56.   share of the processor's cycles. In addition, it provides a nice
  57.   interface for the aforementioned programs to talk to your hardware.
  58.  
  59.  
  60.   Is that it? Well, it is a little more complicated, but it won't be
  61.   discussed in detail here.
  62.  
  63.  
  64.  
  65.  
  66.  
  67.   2.2.  Why would I want to upgrade my kernel?
  68.  
  69.  
  70.   Newer kernels generally offer more the ability to talk to more kinds
  71.   of weird hardware (ie, they have more device drivers), they can have
  72.   better process management, they can run faster than the older
  73.   versions, they could be more stable than the older versions, and they
  74.   fix silly bugs in the older versions. Most people upgrade kernels
  75.   because they want the device drivers and the bug-fixes.
  76.  
  77.  
  78.  
  79.   2.3.  What kind of hardware do the newer kernels support?
  80.  
  81.  
  82.   See the Hardware-HOWTO. Alternatively, you can look at the
  83.   ``config.in'' file in the linux source, or just find out when you try
  84.   ``make config.''  ``make config'' will allow you to see all hardware
  85.   supported by the standard kernel source code, but not everything that
  86.   linux supports; many common device drivers (like PCMCIA drivers and
  87.   some tape drivers) are loadable modules maintained and distributed
  88.   seperately.
  89.  
  90.  
  91.  
  92.   2.4.  What version of gcc or libc do I need?
  93.  
  94.  
  95.   Linus recommends this in the README in the linux source. If you don't
  96.   have at least that version, the new distribution of gcc should tell
  97.   you if you need to upgrade your libc. Both of these aren't really
  98.   scary operations, but do follow the instructions.
  99.  
  100.  
  101.  
  102.   2.5.  What's a loadable module?
  103.  
  104.  
  105.   These are parts of the kernel (device drivers, usually) which aren't
  106.   compiled into the kernel. One compiles them separately, and can insert
  107.   and remove them into the running kernel just about any time. This has
  108.   become a preferred way of adding things onto the kernel, since it's
  109.   obviously more modular. Many popular device drivers, such as the
  110.   PCMCIA drivers and the QIC-80/40 tape driver, are loadable modules.
  111.  
  112.  
  113.  
  114.   2.6.  How much disk space do I need?
  115.  
  116.  
  117.   It depends on a few things. First off, the compressed linux source was
  118.   1.66 megs at version 1.1.45. You'll usually want to keep this around.
  119.   Uncompressed, that was about 8 megs. But that's not the end -- you'll
  120.   need more to actually compile the thing. This depends on how much junk
  121.   you've got configured into your kernel. For example, on my 386, I've
  122.   networking, the 3Com 3C503 driver, and five filesystems configured,
  123.   and it takes 16.2 megs. Adding the compressed linux source, you have
  124.   about 18 megs for this particular configuration. On another system,
  125.   without network device support (but still with networking support),
  126.   and sound card support, it takes 12 megs. So, in general, if you've
  127.   got a lot of hardware, make sure that you have a big enough hard disk
  128.   in that mess..
  129.  
  130.  
  131.  
  132.  
  133.   2.7.  How long does it take?
  134.  
  135.  
  136.   For most people, the answer is, ``kind of long.'' The speed of your
  137.   processor is and the amount of memory you have ultimately determines
  138.   the time, but there's a small bit to do with the amount of stuff
  139.   you've got configured into the kernel. On a 486DX4/100 notebook with
  140.   16 megs of RAM, on a kernel with five filesystems, networking support,
  141.   and sound card drivers, it takes under 20 minutes. On a 386DX/40 (8MB
  142.   RAM) with a similar configuration, it's about 1.5 hours. (meaningless
  143.   aside: I know someone with a 386SX/16 w/4MB RAM who compiles his
  144.   kernels overnight (it usually takes longer (yes, I have told him to
  145.   get a real computer)))
  146.  
  147.  
  148.  
  149.   3.  How to actually configure the kernel
  150.  
  151.  
  152.  
  153.   3.1.  Getting the source
  154.  
  155.  
  156.   You can attain the source via ftp from ftp.funet.fi or mirror in
  157.   /pub/OS/Linux/PEOPLE/Linus, a mirror of this site, or other sites.  It
  158.   is typically labelled linux-x.x.x.tar.gz, where x.x.x is the version
  159.   number. Newer (better?) versions and the patches are typically in
  160.   subdirectories like ``v1.1'' and ``v1.2.''
  161.  
  162.  
  163.   It is strongly suggested that you use a mirror ftp site instead of
  164.   ftp.funet.fi! A short listing of mirrors and other sites follows.
  165.  
  166.  
  167.   (mirrors of ftp.funet.fi:)
  168.   Germany:        ftp.Germany.EU.net
  169.   UK:             doc.ic.ac.uk
  170.   Australia:      kirk.bu.oz.au
  171.   (sites that also carry the kernel files:)
  172.   USA:            tsx-11.mit.edu
  173.   USA:            sunsite.unc.edu
  174.   Germany:        ftp.dfv.rwth-aachen.de
  175.  
  176.  
  177.  
  178.   If you don't have ftp access, there is a list of BBS systems carrying
  179.   linux which is posted periodically to comp.os.linux.announce; try to
  180.   get your hands on this.
  181.  
  182.  
  183.  
  184.   3.2.  Unpacking the source
  185.  
  186.  
  187.   Make sure you're ``root,'' and cd to /usr/src. If you got your linux
  188.   from anywhere reasonable, there will already be a directory there
  189.   called ``linux.'' That's the old linux source code.  If you have the
  190.   disk space and you want to play it safe, you'll want to preserve that
  191.   directory. A good idea is to figure out what version you're running
  192.   and rename the directory accordingly. The command ``uname -r'' will
  193.   tell you the new version.  Therefore, if ``uname -r'' said ``1.1.47,''
  194.   you would rename ``linux'' to ``linux-1.1.47.''  If you're the
  195.   reckless kind of person, just wipe out the directory. In any case,
  196.   just make sure there is no ``linux'' directory in /usr/src before
  197.   unpacking the full source code.
  198.  
  199.   In /usr/src, unpack the source with ``zcat linux.x.x.x.tar.gz | tar
  200.   xvf -'' (You could also use ``tar zxvf linux.x.x.x.tar.gz'' for
  201.   simplicity; if you've just got a .tar  file (no .gz  at the end),
  202.   ``tar xvf linux.x.x.x.tar'' will work fine.).  You'll see the contents
  203.   of the source fly by. When finished, there will be a new ``linux''
  204.   directory. ``cd'' to linux and look over the README  file.  There will
  205.   be a section labelled ``INSTALLING the kernel'' or something like
  206.   that. Carry out the instructions when appropriate -- symlinks that
  207.   should be in place, removal of stale .o files, etc.
  208.  
  209.  
  210.  
  211.   3.3.  Configuring the kernel
  212.  
  213.  
  214.   Note: Some of this is a reiteration/clarification of the corresponding
  215.   section in Linus' README file.
  216.  
  217.  
  218.   The command ``make config'' while in /usr/src/linux will start up a
  219.   script that asks you all sorts of questions. It needs bash, so make
  220.   sure bash is /bin/bash, /bin/sh, or $BASH.
  221.  
  222.  
  223.   You're ready to answer the questions, usually with ``y'' or ``n.''
  224.   Some of the more obvious and non-critical options are not described.
  225.  
  226.  
  227.  
  228.   3.3.1.  Kernel math emulation
  229.  
  230.  
  231.   If you don't have a math coprocessor (ie, you've got a bare 386 or
  232.   486SX), you need to say ``y'' to this. If you do have a coprocessor
  233.   and you still say ``y,'' don't worry too much -- the coprocessor will
  234.   be used and the emulation ignored. The only consequence is that the
  235.   kernel will be larger.
  236.  
  237.  
  238.  
  239.   3.3.2.  Normal harddisk support
  240.  
  241.  
  242.   You'll almost always need to say yes to this. This means that the
  243.   kernel will support standard PC disks like IDE stuff, which most
  244.   people have. This does not include SCSI drives.
  245.  
  246.  
  247.  
  248.   3.3.3.  Networking support
  249.  
  250.  
  251.   If you're on a network, say, if you are on the internet, or you're
  252.   going to use SLIP, PPP, term, or something to dial up to places for
  253.   internet access, say ``y.''
  254.  
  255.  
  256.  
  257.   3.3.4.  Limit memory to low 16MB
  258.  
  259.  
  260.   If you've got less than 16MB of RAM, you almost always want to say
  261.   ``y'' to this; you save a little bit of RAM when the new kernel is in
  262.   use.  But, of course, if you've got more than 16, if you don't say
  263.   ``n,'' the new kernel will only use 16 of your 34 billion megs of RAM.
  264.   There are supposedly bad 386 DMA controllers (or something hardware-
  265.   related) out there which don't address anything above 16 megs
  266.   correctly, either; you would want to say ``y'' in the (rare) case that
  267.   you have one.
  268.  
  269.  
  270.  
  271.   3.3.5.  Use -m486 flag for 486-specific optimizations
  272.  
  273.  
  274.   This optimizes the kernel for the 486. The new kernel will be slightly
  275.   bigger, but it will still work fine on a 386, if you're worried about
  276.   that. It might be a ``little'' slower on the 386, but you won't notice
  277.   it.
  278.  
  279.  
  280.  
  281.   3.3.6.  SCSI support
  282.  
  283.  
  284.   If you've got a SCSI device, say ``y.'' You'll be prompted for further
  285.   information, like if you want to support CD-ROM, disks, and what kind
  286.   of SCSI adapter you've got. See the SCSI-HOWTO for more detail.
  287.  
  288.  
  289.  
  290.   3.3.7.  Network device support
  291.  
  292.  
  293.   If you've got an ethernet card, or you want to use SLIP, PPP, or a
  294.   parallel port adapter, say ``y.'' You'll be prompted for which kind of
  295.   card you have, or which serial protocol to use.
  296.  
  297.  
  298.  
  299.   3.3.8.  Filesystems
  300.  
  301.  
  302.   You'll be prompted for support of a number of filesystems. They are:
  303.  
  304.  
  305.   Standard (minix) - Newer distributions don't create minix filesystems,
  306.   and many people don't use it, but it may still be a good idea to
  307.   configure this one. Some ``rescue-disk'' programs use it, and still
  308.   more floppies may have a minix filesystem, since the minix filesystem
  309.   is optimal for floppy disks.
  310.  
  311.  
  312.   Extended fs - This was the first version of the extended filesystem,
  313.   which isn't used much anymore. Chances are, you'll know it if you need
  314.   it.
  315.  
  316.  
  317.   Second extended - This is widely used in new distributions. You
  318.   probably have one of these.
  319.  
  320.  
  321.   xiafs filesystem - At one time, this was pretty common, but at the
  322.   time of this writing, I didn't know anyone running it.
  323.  
  324.  
  325.   msdos - Well, you guessed it; if you want to use your MS-DOS hard disk
  326.   partitions, or mount MS-DOS formatted floppy disks, say ``y.''
  327.  
  328.  
  329.   umsdos - This is a fairly slick filesystem which can make an MS-DOS
  330.   filesystem have more features, like long filenames, etc. It's not
  331.   really useful for people (like me) who don't run MS-DOS.
  332.  
  333.  
  334.   /proc - One of the most slick filesystems (idea shamelessly stolen
  335.   from Bell Labs, I guess). It's not anything you partition disks with;
  336.   but a filesystem interface to the kernel and processes. Many process-
  337.   listers (like ``ps'') use it. If you've got it installed, try ``cat
  338.   /proc/meminfo'' or ``cat /proc/devices'' sometime.  Some shells, like
  339.   rc, use /proc/self/fd  (known as /dev/fd on other systems) for i/o.
  340.   You should almost certainly say ``y'' to this; many important standard
  341.   Linux tools depend on it!
  342.  
  343.  
  344.   NFS - If you're on a network and you want to share files, say ``y.''
  345.  
  346.  
  347.   ISO9660 - Found on most CD-ROMs.
  348.  
  349.  
  350.   OS/2 HPFS - At the time of this writing, a read-only fs for OS/2 HPFS.
  351.  
  352.  
  353.   System V and Coherent - for partitions of System V and Coherent
  354.   systems.
  355.  
  356.  
  357.  
  358.   3.3.8.1.  But I don't know which filesystems I need!
  359.  
  360.  
  361.   Ok, type ``mount.'' It will look something like this:
  362.  
  363.  
  364.  
  365.  
  366.                blah% mount
  367.                /dev/hda1 on / type ext2 (defaults)
  368.                /dev/hda3 on /usr type ext2 (defaults)
  369.                none on /proc type proc (defaults)
  370.                /dev/fd0 on /mnt type msdos (defaults)
  371.  
  372.  
  373.  
  374.  
  375.   Look at each line; the word next to ``type'' is the filesystem type.
  376.   On this example, my /  and /usr  partitions are the second extended
  377.   type, I'm using /proc, and there's a floppy disk mounted using the
  378.   msdos (bleah) filesystem.
  379.  
  380.  
  381.   You can try ``cat /proc/filesystems'' if you've got /proc. It will
  382.   give you a list of what's in your current kernel.
  383.  
  384.  
  385.  
  386.   3.3.9.  Character devices
  387.  
  388.  
  389.   Here, you'll find the devices for your printer, busmouse, PS/2 mouse
  390.   (most notebooks use builtin PS/2 mice), some tape drives, selection.
  391.   Say ``y'' when appropriate.
  392.  
  393.  
  394.   Note: ``Selection'' allows one to run a program that lets you use the
  395.   mouse outside of X-Windows to cut and paste between virtual consoles.
  396.   It's fairly nice if you've got a serial mouse, because it interacts
  397.   well with X Windows, but at the time of this writing, it didn't play
  398.   nice with PS/2 type mice (it locks up the mouse port, making it
  399.   impossible to run X Windows until you kill the selection process.).
  400.  
  401.  
  402.  
  403.   3.3.10.  Sound card
  404.  
  405.  
  406.   If you're interested in keeping the people next door awake, say ``y,''
  407.   and later on, a config program will compile and ask you all about your
  408.   sound board.
  409.  
  410.  
  411.  
  412.   3.3.11.  Kernel hacking
  413.  
  414.  
  415.   >From Linus' README:
  416.  
  417.   the ``kernel hacking'' configuration details usually result in a
  418.   bigger or slower kernel (or both), and can even make the kernel less
  419.   stable by configuring some routines to actively try to break bad code
  420.   to find kernel problems (kmalloc()).  Thus you should probably answer
  421.   `n' to the questions for a ``production'' kernel.
  422.  
  423.  
  424.  
  425.   3.4.  Now what? (The Makefile)
  426.  
  427.  
  428.   You'll get a message telling you that your kernel has been configured,
  429.   and to ``check the top-level Makefile for additional configuration,''
  430.   etc.
  431.  
  432.  
  433.   So, look at the Makefile. You probably won't have to change it, but it
  434.   doesn't hurt to look. You may also change the options in there with
  435.   the ``rdev'' command once the new kernel is in place, too.
  436.  
  437.  
  438.  
  439.   4.  Compiling the kernel
  440.  
  441.  
  442.  
  443.   4.1.  Cleaning and depending
  444.  
  445.  
  446.   When the configure script ends, it will tell you to ``dep'' and
  447.   ``clean.''  So, do the ``make dep.'' It doesn't take that long unless
  448.   you've got a really slow computer. Making depend makes sure you've got
  449.   all of the dependencies in place, like the include files and that kind
  450.   of thing.  When finished (you can also do it before the ``make dep''),
  451.   do a ``make clean.''  This wipes out all of the object files and some
  452.   other things that the kernel compiles. Don't forget this step.
  453.  
  454.  
  455.  
  456.   4.2.  Compile time
  457.  
  458.  
  459.   After depending and cleaning, you can now do ``make'' or ``make
  460.   zdisk.'' ``make'' will compile the kernel, and leave you with a file
  461.   called ``zImage'' (among other things). That's the new kernel. ``make
  462.   zdisk'' does the same thing, but sticks it on a floppy disk that you
  463.   have hopefully put in drive A:.  ``zdisk'' is fairly handy for testing
  464.   new kernels; if it totally bombs out, just remove the floppy and boot
  465.   with your old kernel. It's also a handy way to boot if you
  466.   accidentally remove or kernel or something. You can also use it in
  467.   installing new systems when you just dump the contents of one disk
  468.   onto the other (all of this and more! NOW how much would you pay?).
  469.  
  470.  
  471.   All reasonably recent kernels are compressed, hence the ``z'' in front
  472.   of the names. The kernel is compressed, and when run, automatically
  473.   decompresses itself (a nice way to save disk space).
  474.  
  475.  
  476.  
  477.   4.3.  Other ``make''ables
  478.  
  479.  
  480.   ``make mrproper'' will do a more extensive ``clean''ing.  It's
  481.   sometimes necessary, so you may wish to do it at every patch.  ``make
  482.   zlilo'' will install the kernel, run LILO on it, and get you all ready
  483.   to boot, BUT ONLY if lilo is configured in the following way on your
  484.   system: kernel is /vmlinuz , lilo is in /sbin, and your lilo config
  485.   agrees.
  486.  
  487.  
  488.  
  489.   4.4.  Installing the kernel
  490.  
  491.  
  492.   After you've got a new kernel that seems to work the way you want it
  493.   to, it's time to install it. Most people use LILO (Linux Loader) for
  494.   this. It's a fairly easy package to install which, however, can
  495.   confuse people with the config file. If you don't have the latest
  496.   version, look at the config file (either /etc/lilo/config  for older
  497.   versions or /etc/lilo.conf  for new versions), and see what you've
  498.   got. It will say something like this:
  499.  
  500.  
  501.  
  502.       image = /vmlinux
  503.           label = Linux
  504.           root = /dev/hda1
  505.           ...
  506.  
  507.  
  508.  
  509.   First off, that ``image = '' is set to what the installed kernel is.
  510.   Most people seem to use /vmlinuz, but I use /vmlinux. ``label'' is
  511.   used by lilo to tell which kernel or operating system you're booting,
  512.   and ``root'' is the / of that particular OS. Make a backup copy of
  513.   your old kernel (whatever it's called), and copy the zImage you made
  514.   into place (like, you would say ``cp zImage /vmlinuz'' if you use
  515.   ``/vmlinuz'').  Then, rerun lilo -- on newer systems, you can just run
  516.   ``lilo,'' but on older stuff, you might have to do an
  517.   /etc/lilo/install  or even an /etc/lilo/lilo -C /etc/lilo/config.
  518.  
  519.  
  520.   If you want to know more about LILO's configuration, or you don't have
  521.   LILO but you want to, get the newest version from your favorite ftp
  522.   site and follow the instructions.
  523.  
  524.  
  525.   To be able to boot one of your old kernels off the hard disk (another
  526.   way to save yourself in case you floozie up the new kernel), copy the
  527.   lines (including the line) ``image = xxx'' in the lilo config file to
  528.   the bottom of the file, and change the ``image = xxx'' to ``image =
  529.   yyy,'' where ``yyy'' is the name of the thing you saved your backup
  530.   kernel to. Then, change the ``label = xXx'' to something like ``label
  531.   = linux-backup.'' Then, rerun lilo. You may have to put a line in the
  532.   config file saying ``delay=x,'' where x is an amount in tenths of a
  533.   second. That's to make lilo wait before booting, so you can interrupt
  534.   it (with the shift key, for example), and type in the label of the
  535.   backup boot image (in case unpleasant things happen).
  536.  
  537.  
  538.  
  539.   5.  Patching the kernel
  540.  
  541.  
  542.  
  543.   5.1.  Applying a patch
  544.  
  545.  
  546.   Incremental upgrades of the kernel are distributed as patches. For
  547.   example, if you have version 1.1.45, and you notice that there's a
  548.   ``patch46.gz'' out there for it, it means you can upgrade to version
  549.   1.1.46 by applying the patch. You might want to make a backup of the
  550.   source tree first (``make clean'' and then ``cd /usr/src; tar cvf -
  551.   linux | gzip -c > old-tree.tar.gz'' will make a compressed tar archive
  552.   for you.).
  553.  
  554.  
  555.   So, continuing with the example in the above, let's suppose that
  556.   you've got ``patch46.gz'' in /usr/src. cd to /usr/src  and do a ``zcat
  557.   patch46.gz | patch -p0'' (or ``patch -p0 < patch46'' if the patch
  558.   isn't compressed). You'll see things whizz by (or flutter by, if your
  559.   computer is kind of slow) telling you that it's trying to apply hunks,
  560.   and if it succeeds or not. Usually, it goes by too fast for you to
  561.   read, so you're not too sure whether it worked or not. So, to look for
  562.   things that might not have gone smoothly, cd to /usr/src/linux  and
  563.   look for files with a .rej extension. Some versions of patch (older
  564.   versions which may have been compiled with on an inferior filesystem)
  565.   leave the rejects with a # extension. You can use ``find'' to look for
  566.   you; ``find .  -name '*.rej' -print'' will do the trick.
  567.  
  568.  
  569.   If everything has gone right, do a ``make clean,'' ``config,'' and
  570.   ``dep'' as described in sections 2 and 3.
  571.  
  572.  
  573.   There are quite a few options to the patch command. patch -s will
  574.   suppress all messages except the errors. If you keep your kernel
  575.   source in some other place than /usr/src/linux, a patch -p1 in that
  576.   directory will patch things cleanly. Other patch options are well-
  577.   documented in the manual page.
  578.  
  579.  
  580.  
  581.   5.2.  If something goes wrong
  582.  
  583.  
  584.   The most frequent problem that arises used to be when a patch modified
  585.   a file called ``config.in'' and it didn't look quite right, because
  586.   you changed the options to suit your machine. This has been taken care
  587.   of, but one still might encounter it with an older release.  To fix
  588.   it, look at the config.in.rej  file, and see what's left.  The changes
  589.   will typically be marked with ``+'' and ``-'' at the beginning of the
  590.   line. Look at the lines surrounding it, and remember if they were set
  591.   to ``y'' or ``n.'' Now, edit config.in, and change ``y'' to ``n'' and
  592.   ``n'' to ``y'' when appropriate. Do a ``patch -p0 < config.in.rej,''
  593.   and if it says it succeeded (no fails), then you're okay. The
  594.   config.in.rej  file will remain, but you can get rid of it.
  595.   If you've got further problems, you might have installed a patch out
  596.   of order. If patch says ``previously applied patch detected: Assume
  597.   -R?,'' you are probably applying some patch that is below your current
  598.   version number (This is not one of those recommended things to do.).
  599.  
  600.  
  601.   To back out (unapply) a patch, use ``patch -R'' on the original patch.
  602.  
  603.  
  604.   The best thing to do when patches really bomb out is to start over
  605.   again with a clean, out-of-the-box source tree (for example, from one
  606.   of the linux-x.x.x.tar.gz  files), and start again.
  607.  
  608.  
  609.  
  610.   5.3.  Getting rid of the .orig files
  611.  
  612.  
  613.   After just a few patches, the .orig  files will start to pile up. For
  614.   example, one 1.1.51 tree I had was last cleaned out at 1.1.48 (I
  615.   think). Removing the .orig files saved over a half a meg.  ``find .
  616.   -name '*.orig' -exec rm -f {} ';' '' will take care of it for you.
  617.   Some versions of patch use a tilde instead of .orig.
  618.  
  619.   There are other (better?) ways to get rid of the .orig files.  Most
  620.   use ``xargs'' instead of ``-exec:'' ``find .  -name '*.orig' | xargs
  621.   rm'' or ``find . -name '*.orig' -print0 | xargs --null rm --'' (the
  622.   latter is more secure.).
  623.  
  624.  
  625.  
  626.   5.4.  Other patches
  627.  
  628.  
  629.   There's always other patches (I'll call them ``nonstandard'') than the
  630.   ones Linus distributes. If you apply these, Linus' patches may not
  631.   work correctly and you'll have to either back them out, or fix the
  632.   source or the patch accordingly.  That's generally an ugly thing to do
  633.   for novices, so if you're not into screwing around with the source,
  634.   back out the nonstandard patches before applying Linus'. Then, you can
  635.   see if the nonstandard patches still work. If they don't, you're
  636.   either stuck with running at the old patchlevel, playing with the
  637.   patch to get it to work, or waiting for someone to come out with a
  638.   version of the nonstandard patch for your new patchlevel.
  639.  
  640.  
  641.   How common are the ones not in the standard distribution? You will
  642.   probably hear of them. I use Bill Paul's noblink patch to make the
  643.   cursor on my virtual consoles because I hate blinking cursors. As far
  644.   as I know, this particular patch was last updated for kernel version
  645.   1.0, but I still used it at 1.1.51 -- I have modified it quite a few
  646.   times, because it often messes up Linus' patches to
  647.   drivers/char/console.c.
  648.  
  649.  
  650.  
  651.   6.  Additional packages
  652.  
  653.   Your Linux kernel has a lot of features which are not explained in the
  654.   kernel source itself; these features are typically utilized through
  655.   external packages. Some of the most common are listed here.
  656.  
  657.  
  658.  
  659.  
  660.  
  661.   6.1.  kbd
  662.  
  663.   The Linux console has more features than you can shake a stick at.
  664.   This includes the ability to switch fonts, remap your keyboard, switch
  665.   videomodes (in newer kernels), etc. The kbd package has programs which
  666.   allow the user to do all of this, plus a ton of fonts and keyboard
  667.   maps for almost any keyboard.
  668.  
  669.  
  670.  
  671.   6.2.  hdparm
  672.  
  673.   As with many packages, this was once a kernel patch and support
  674.   programs.  The patches made it into the official kernel, and the
  675.   programs to optimize and play with your hard disk are distributed
  676.   seperately, as usual.
  677.  
  678.  
  679.  
  680.   7.  Some pitfalls
  681.  
  682.  
  683.  
  684.   7.1.  make clean
  685.  
  686.  
  687.   If your new kernel does really weird things (it's happened to me),
  688.   chances are you forgot to make clean. Symptoms can be anything from
  689.   your kernel outright crashing, to strange I/O problems, to crummy
  690.   performance. Make sure you do a make dep, too.
  691.  
  692.  
  693.  
  694.   7.2.  Huge or slow kernels
  695.  
  696.  
  697.   If your kernel is sucking up a lot of memory, or is getting really
  698.   big, or really takes forever to compile even when you've got your new
  699.   486DX6/440 working on it, you've probably got lots of unneeded stuff
  700.   (device drivers, filesystems, etc) configured. If you don't use it,
  701.   don't configure it, because it does take up memory. If you've got less
  702.   than 16 megs, make sure that you say yes to ``limit memory to low
  703.   16MB;'' it makes a lot of difference (especially on a 4MB system).
  704.   The most obvious symptom of bloat is extreme swapping in and out of
  705.   memory to disk. If your disk is making a lot of noise, look over your
  706.   kernel configuration.
  707.  
  708.  
  709.   You can find out how much memory the kernel is using by taking the
  710.   total amount of memory in your machine and subtracting it from the
  711.   amount of ``total mem'' in /proc/meminfo  or the output of the command
  712.   ``free.'' You can also find out by doing a ``dmesg'' (or by looking at
  713.   the kernel log file, wherever it is on your system).  There will be a
  714.   line that looks like this:
  715.  
  716.  
  717.   Memory: 15124k/16384k available (552k kernel code, 384k reserved, 324k
  718.   data)
  719.  
  720.  
  721.   My 386 (which has slightly less junk configured) says this:
  722.  
  723.  
  724.   Memory: 7000k/8192k available (496k kernel code, 384k reserved, 312k
  725.   data)
  726.  
  727.   7.3.  Kernel doesn't compile
  728.  
  729.  
  730.   If it doesn't compile, then a patch has probably failed, or you got
  731.   corrupted sources from somewhere. Your version of gcc also might not
  732.   be correct, or could be messed up. Make sure that the symlinks which
  733.   Linus describes in the README are right. In general, if a kernel
  734.   doesn't compile, something is seriously wrong.
  735.  
  736.  
  737.  
  738.   7.4.  New version of the kernel doesn't seem to boot
  739.  
  740.  
  741.   LILO either wasn't run, or isn't configured correctly. One thing that
  742.   ``got'' me once was a problem in the config file. I had ``boot =
  743.   /dev/hda1'' instead of ``boot = /dev/hda'' (This can be really
  744.   annoying at first, but once you've got a working config file, you
  745.   shouldn't need to change it.).
  746.  
  747.  
  748.  
  749.   7.5.  You forgot to run LILO, or system doesn't boot at all
  750.  
  751.  
  752.   Ooops! The best thing you can do here is to boot off of a floppy disk
  753.   and prepare another bootable floppy (like ``make zdisk'' would do).
  754.   You need to know where your root (/) partition is and what type it is
  755.   (second extended, minix, etc). In the example below, you also need to
  756.   know what partition your /usr/src/linux source tree is on, its type,
  757.   and where it is normally mounted.
  758.  
  759.  
  760.   In the example, the / is /dev/hda1, and the partition which holds
  761.   /usr/src/linux is /dev/hda3, normally mounted at /usr. They are both
  762.   second extended filesystems. The working kernel image in
  763.   /usr/src/linux is called zImage.
  764.  
  765.  
  766.   The idea is that if there was a working kernel image in /usr/src/linux
  767.   called zImage, it is possible to use that for the new floppy. Another
  768.   alternative, which may or may not work better (it depends on the
  769.   particular method in which you messed up your system) is discussed
  770.   after the example.
  771.  
  772.  
  773.   First, boot from a boot/root disk or rescue disk, and then mount the
  774.   partition that there was a working kernel image on:
  775.  
  776.  
  777.  
  778.   mkdir /mnt
  779.   mount -t ext2 /dev/hda3 /mnt
  780.  
  781.  
  782.  
  783.   If mkdir tells you that the directory already exists, just ignore it.
  784.   Now, cd to the place where the working kernel image was (Note: /mnt +
  785.   /usr/src/linux - /usr = /mnt/src/linux). Put a formatted disk in drive
  786.   a: (make sure it's not your boot or root disk!), dump the image to the
  787.   disk, and configure for your root partition:
  788.  
  789.  
  790.  
  791.  
  792.  
  793.   cd /mnt/src/linux
  794.   dd if=zImage of=/dev/fd0
  795.   rdev /dev/fd0 /dev/hda1
  796.  
  797.  
  798.  
  799.   cd to / and unmount the normal /usr partition:
  800.  
  801.  
  802.   cd /
  803.   umount /mnt
  804.  
  805.  
  806.  
  807.   You should now be able to reboot your system as normal from this
  808.   floppy.  Don't forget to run lilo (or whatever it was that you did
  809.   wrong) after the reboot!
  810.  
  811.  
  812.   As mentioned above, there is another very common alternative. If you
  813.   happened to have a working kernel image in / (/vmlinuz for example),
  814.   you can use that as well. Supposing all of the above conditions, and
  815.   that my kernel image is /vmlinuz, just make these alterations to the
  816.   example above: change /dev/hda3 to /dev/hda1 (the / partition),
  817.   /mnt/src/linux to /mnt, and if=zImage to if=vmlinuz. The little note
  818.   explaining how to derive /mnt/src/linux may be ignored.
  819.  
  820.  
  821.  
  822.   7.6.  It says ``warning: bdflush not running''
  823.  
  824.  
  825.   This can be a pretty severe problem. Starting with a kernel release
  826.   after 1.0 (I can't remember which, exactly, but it was around 20 Apr
  827.   1994), a program called ``update'' which periodically flushes out the
  828.   filesystem buffers was upgraded/replaced. Get the sources to
  829.   ``bdflush'' (you should find it where you got your kernel), and
  830.   compile it (You will probably want to run under the old kernel while
  831.   compiling and installing). It will install itself as ``update'' and
  832.   you should be fine with the new kernel after that.
  833.  
  834.  
  835.  
  836.   7.7.  It says weird things about obsolete routing requests
  837.  
  838.  
  839.   Get new versions of the route program and/or recompile the old stuff.
  840.   /usr/include/linux/route.h  (which is actually a file in
  841.   /usr/src/linux) has changed.
  842.  
  843.  
  844.  
  845.   8.  Tips and tricks
  846.  
  847.  
  848.  
  849.   8.1.  Redirecting output of the make or patch commands
  850.  
  851.  
  852.   If you'd like logs of what those ``make'' or ``patch'' commands did,
  853.   you can redirect output to a file. First, find out what shell you're
  854.   running: ``grep root /etc/passwd'' and look for something like
  855.   ``/bin/csh.''
  856.  
  857.  
  858.  
  859.   If you're running sh or bash, ``(command) 2>&1 | tee (output file)''
  860.   will place a copy of the make in the file ``(output file).''
  861.  
  862.  
  863.   For csh or tcsh, the syntax ``(command) |& tee (output file)'' is for
  864.   you.
  865.  
  866.  
  867.   For rc (Note: you probably aren't running rc) it's ``(command) >[2=1]
  868.   | tee (output file).''
  869.  
  870.  
  871.  
  872.   9.  Misc
  873.  
  874.  
  875.  
  876.   9.1.  Author
  877.  
  878.  
  879.   The original revision was -0.1 on 3 October 1994 by Brian Ward
  880.   (ward@blah.tu-graz.ac.at).  Please send me any comments, additions,
  881.   corrections, or computers.  Corrections are, in particular, the most
  882.   important to me!
  883.  
  884.  
  885.   Even though I try to be attentive as possible with mail, please
  886.   remember that I get a lot of mail per day, so it may take a little
  887.   time to get back to you. Especially when emailing me with a question,
  888.   please try extra hard to be clear and detailed in your message. I'd
  889.   like to thank everyone who's given me feedback.
  890.  
  891.  
  892.  
  893.   9.2.  History and other forms of this document
  894.  
  895.   I originally wrote this in ASCII, then I put some TeX around it, and
  896.   then horrified the TeX so that I could convert the TeX into SGML with
  897.   a perl script. Because of the original in TeX, the first version of
  898.   this document that appeared on sunsite had two section numbers with
  899.   each section (It wouldn't have looked that bad if they weren't
  900.   different.).  I also realize that it's kind of nonstandard to make
  901.   revision numbers negative, but oh well. And if any of the above sounds
  902.   kind of stupid, I don't blame you.
  903.  
  904.  
  905.  
  906.   9.3.  To do
  907.  
  908.   The ``Tricks and tips'' section is a little small. I hope to expand on
  909.   it with suggestions from others.
  910.  
  911.   So is ``Additional packages.''
  912.  
  913.   More debugging/crash recovery info needed.
  914.  
  915.  
  916.  
  917.   9.4.  Contributions
  918.  
  919.   A small part of Linus' README (Re: kernel hacking options) is
  920.   inclusive.  (Thanks, Linus!)
  921.  
  922.   uc@brian.lunetix.de (Ulrich Callmeier): patch -s and xargs.
  923.  
  924.  
  925.   quinlan@yggdrasil.com (Daniel Quinlan): corrections and additions in
  926.   many sections.
  927.  
  928.   nat@nataa.frmug.fr.net (Nat MAKAREVITCH): mrproper
  929.  
  930.   The people who have sent me mail with questions and problems have been
  931.   helpful, too!
  932.  
  933.  
  934.   9.5.  Copyright notice and copying
  935.  
  936.   Copyright (c) Brian Ward, 1994, 1995.
  937.  
  938.   This document may be distributed in any medium as long as it and this
  939.   notice remain unaltered. Permission is granted for translation into
  940.   any language, so long as the translator's name is added to the
  941.   document. There is no warranty on this document and its contents; no
  942.   one may be held liable for any unfortunate outcome of its content.
  943.  
  944.  
  945.   Commercial redistribution is allowed and encouraged; however, it is
  946.   strongly recommended that the redistributor contact the author before
  947.   the redistribution, in the interest of keeping things up-to-date. The
  948.   same is true for translations.
  949.