📄 00000063.htm
字号:
<BR>Now issue the command:
<BR>
<BR>tar xzvf linux-kernel-source.tar.gz
<BR>
<BR>I have a habit of always including w (wait for confirmation) in the tar <BR>option string, then when I see that the .tar.gz or .tgz file is
<BR>going to unpack into its own subdirectory, I ctrl-C out and reissue the <BR>command without the w. This way I can prevent
<BR>corrupted archives from unpacking into the current directory.
<BR>
<BR>Once you have the kernel unpacked, if you have any patches you wish to apply, <BR>now is a good time. Let's say you don't wish to
<BR>run kernel 2.0.30, but you do want the tcp-syn-cookies. Copy the patch <BR>(called tcp-syn-cookies-patch-1) into the /usr/src directory
<BR>and issue the command:
<BR>
<BR>patch < tcp-syn-cookies-patch-1
<BR>
<BR>This command applies the patch to the kernel. Look for files with an .rej <BR>extension in in the /usr/src directory. These files didn't
<BR>patch properly. They may be unimportant, but peruse them anyway. If you <BR>installed a Red Hat system with some but not all of the
<BR>kernel source (SPARC, PowerPC, etc.), you'll see some of these files. As long <BR>as they're not for your architecture, you're okay.
<BR>
<BR>
<BR>
<BR>Preparation
<BR>
<BR>As a final note, before we change (cd) into the kernel source directory and <BR>start building our new kernel, let's check some links
<BR>that are needed. In your /usr/include directory, make sure you have the <BR>following soft links:
<BR>
<BR>asm - /usr/src/linux/include/asm
<BR>linux - /usr/src/linux/include/linux
<BR>scsi - /usr/src/linux/include/scsi
<BR>
<BR>Now, you see another reason to standardize the location of the kernel. If you <BR>don't put the latest kernel you wish to install in
<BR>/usr/src/linux (via a link), the above links will not reach their intended <BR>target (dangling links), and the kernel may fail to compile.
<BR>
<BR>
<BR>
<BR>How to proceed
<BR>
<BR>Once everything else is set up, change directories into /usr/src/linux. <BR>Although you may want to stop off and peruse some of the
<BR>documentation in the Documentation directory, particularly if you have any <BR>special hardware needs. Also, several of the CD-ROM
<BR>drivers need to be built with customized settings. While they usually work as <BR>is, these drivers may give warning messages when
<BR>loaded. If this doesn't bother you and they work as they should, don't worry. <BR>Otherwise, read the appropriate .txt, .h (header) files
<BR>and .c (c code) files. For the most part, I have found them to be well <BR>commented and easy to configure. If you don't feel brave,
<BR>you don't have to do it. Just remember you can always restore the original <BR>file by unpacking the gzipped tar file (or reinstalling the
<BR>.rpm files) again.
<BR>
<BR>
<BR>
<BR>Beginning to Compile
<BR>
<BR>The first command I recommend you issue is:
<BR>
<BR>make mrproper
<BR>
<BR>While this command is not necessary when the kernel source is in pristine <BR>condition, it is a good habit to cultivate. This command
<BR>ensures that old object files are not littering the source tree and are not <BR>used or in the way.
<BR>
<BR>
<BR>
<BR>Configuring the Kernel
<BR>
<BR>Now, you're ready to configure the kernel. Before starting, you'll need to <BR>understand a little about modules. Think of a module as
<BR>something you can plug into the kernel for a special purpose. If you have a <BR>small network at home and sometimes want to use it
<BR>(but not always), maybe you'll want to compile your Ethernet card as a <BR>module. To use the module, the machine must be running
<BR>and have access to the /lib/modules This means that the drive (IDE, SCSI, <BR>etc., but could be an ethernet card in the case of nfs),
<BR>the file system (normally ext2 but could be nfs) and the kernel type <BR>(hopefully elf) must be compiled in and cannot be modules.
<BR>Modules aren't available until the kernel is loaded, the drive (or network) <BR>accessed, and the file system mounted. These files must
<BR>be compiled into the kernel or it will not be able to mount the root <BR>partition. If you're mounting the root partition over the network,
<BR>you'll need the network file system module, and your Ethernet card compiled. <BR>
<BR>
<BR>Why use modules? Modules make the kernel smaller. This reduces the amount of <BR>protected space never given up by the kernel.
<BR>Modules load and unload and that memory can be reallocated. If you use a <BR>module more than about 90% of the time the machine
<BR>is up, compile it. Using a module in this case can be wasteful of memory, <BR>because while the module takes up the same amount of
<BR>memory as if it were compiled, the kernel needs a little more code to have a <BR>hook for the module. Remember, the kernel runs in
<BR>protected space, but the modules don't. That said, I don't often follow my <BR>own advice. I compile in: ext2, IDE and elf support only.
<BR>While I use an Ethernet card almost all the time, I compile everything else <BR>as modules: a.out, java, floppy, iso9660, msdos, minix,
<BR>vfat, smb, nfs, smc-ultra (Ethernet card), serial, printer, sound, ppp, etc. <BR>Many of these only run for a few minutes at a time here
<BR>and there.
<BR>
<BR>The next step is to configure the kernel. Here we have three choices--while <BR>all do the same thing, I recommend using one of the
<BR>graphical methods. The old way was to simply type: make config. This begins a <BR>long series of questions. However, if you
<BR>make a mistake, your only option is to press ctrl-C and begin again. You also <BR>can't go back in the sequence, and some
<BR>questions depend on previous answers. If for some reason you absolutely can't <BR>use either of the graphical methods, be my guest.
<BR>
<BR>I recommend using either make menuconfig or make xconfig. In order to use <BR>menuconfig, you must have installed the
<BR>ncurses-dev and the tk4-dev libraries. If you didn't install them and you <BR>don't want to use the next method, I highly recommend
<BR>that you install them now. You can always uninstall them later.
<BR>
<BR>To run make xconfig, you must install and configure X. Since X is such a <BR>memory hog, I install, configure and startx only for
<BR>this portion of the process, going back to a console while the kernel <BR>compiles so it can have all the memory it needs. The xconfig
<BR>menu is, in my opinion, the best and easiest way to configure the kernel. <BR>Under menuconfig, if you disable an option, any
<BR>subordinate options are not shown. Under xconfig, if you disable an option, <BR>subordinate options still show, they are just greyed out.
<BR>I like this because I can see what's been added since the last kernel. I may <BR>want to enable an option to get one of the new
<BR>sub-options in order to to experiment with it.
<BR>
<BR>I'm going to take some space here to describe the sections in the kernel <BR>configuration and tell you some of the things I've
<BR>discovered--mostly the hard way.
<BR>
<BR>The first section is the code-maturity-level option. The only question is <BR>whether you want to use developmental drivers and code.
<BR>You may not have a choice if you have some bleeding edge hardware. If you <BR>choose ``no'', the experimental code is greyed out or
<BR>not shown. If you use this kernel for commercial production purposes, you'll <BR>probably want to choose ``no''.
<BR>
<BR>The second section concerns modules. If you want modules, choose ``yes'' for <BR>questions 1 and 3. If you want to use proprietary
<BR>modules that come with certain distributions, such as Caldera's OpenLinux for <BR>their Netware support, also answer ``yes'' to the
<BR>second question since you won't be able to recompile the module.
<BR>
<BR>The third section is general setup. Do compile the kernel as ELF and compile <BR>support for ELF binaries. Not compiling the proper
<BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -