Linux内核文档翻译之 README

翻译:XK
时间:2011年6月9日4:15:55

Linux kernel release 2.6.xx
These are the release notes for Linux version 2.6. Read them carefully,
as they tell you what this is all about, explain how to install the
kernel, and what to do if something goes wrong.
这是一份linux2.6版本内核的说明文档,能够告诉你这是什么,解释怎样安装内核以及当出现错误的时候应当如何处理,所以你有必要认真读一读。
WHAT IS LINUX?
Linux is a clone of the operating system Unix, written from scratch by
Linus Torvalds with assistance from a loosely-knit team of hackers across
the Net. It aims towards POSIX and Single UNIX Specification compliance.
It has all the features you would expect in a modern fully-fledged Unix,
including true multitasking, virtual memory, shared libraries, demand
loading, shared copy-on-write executables, proper memory management,
and multistack networking including IPv4 and IPv6.
It is distributed under the GNU General Public License - see the
accompanying COPYING file for more details.

什么是LINUX?
linux 是从unix操作系统衍生出来的,由Linus Torvalds带头从unix发展而来,
并且受到了一大群网上认识的组织松散的hackers的帮助,遵从posix标准和unix风格。

linux 包含有你觉得一个完善的unix系统所应该有的功能组件,包含真实的多任务、
虚拟内存管理、共享库、按需加载、写时复制机制、严密的存储管理以及多种网络协议栈如IPV4、IPV6。

linux在GNU通用公共许可证的保护下发布,详情请看附带的COPYING文件。




ON WHAT HARDWARE DOES IT RUN?
Although originally developed first for 32-bit x86-based PCs (386 or higher),
today Linux also runs on (at least) the Compaq Alpha AXP, Sun SPARC and
UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
Xtensa, AVR32 and Renesas M32R architectures.
Linux is easily portable to most general-purpose 32- or 64-bit architectures
as long as they have a paged memory management unit (PMMU) and a port of the
GNU C compiler (gcc) (part of The GNU Compiler Collection, GCC). Linux has
also been ported to a number of architectures without a PMMU, although
functionality is then obviously somewhat limited.
Linux has also been ported to itself. You can now run the kernel as a
userspace application - this is called UserMode Linux (UML).
linux运行于哪些硬件平台?
虽然最早开发运行于32位X86体系结构的PC(386或者更高),
如今,linux至少也能够运行在如下硬件平台:Compaq Alpha AXP, Sun SPARC and
UltraSPARC, Motorola 68000, PowerPC, PowerPC64, ARM, Hitachi SuperH, Cell,
IBM S/390, MIPS, HP PA-RISC, Intel IA-64, DEC VAX, AMD x86-64, AXIS CRIS,
Xtensa, AVR32 ,Renesas M32R

linux在大部风通用32位或

者64位带有分页存储管理(PMMU)以及GCC编译器的体系结构上都能
很容易地部署,他在一些不带分页存储管理的硬件平台上同样能有限地工作。
同时,linux自己也能将自己的内核以用户程序的形式运行起来,这种模式叫做用户模式linux(UML)




DOCUMENTATION:
- There is a lot of documentation available both in electronic form on
the Internet and in books, both Linux-specific and pertaining to
general UNIX questions. I'd recommend looking into the documentation
subdirectories on any Linux FTP site for the LDP (Linux Documentation
Project) books. This README is not meant to be documentation on the
system: there are much better sources available.
- There are various README files in the Documentation/ subdirectory:
these typically contain kernel-specific installation notes for some
drivers for example. See Documentation/00-INDEX for a list of what
is contained in each file. Please read the Changes file, as it
contains information about the problems, which may result by upgrading
your kernel.
- The Documentation/DocBook/ subdirectory contains several guides for
kernel developers and users. These guides can be rendered in a
number of formats: PostScript (.ps), PDF, HTML, & man-pages, among others.
After installation, "make psdocs", "make pdfdocs", "make htmldocs",
or "make mandocs" will render the documentation in the requested format.


文档

对于不管是linux相关或者是常见unix体系的问题,都能找到很多的相关文档,
这些文档能从网络找到电子档或者从书籍查到。这里推荐查看linux的ftp的
documentation子目录里的LDP文档。你正在查看的这个文档并不是关于整个系统
的详细文档,还有更多更好的选择。

在源码树documentation在了目录下有很多的READMEN文档,
它们通常包含相关内核下某些驱动的安装示例。要查看各个文档所包含的内容,
请查看documentation/00-INDEX文件。请记得阅读changes 文件,它包含了
升级内核可能带来的相关问题的信息。

Documentation/DocBook/子目录包含了为内核开发者或者用户提供的指导文档,
这些文档能采用如下命令生成为多种格式:
"make psdocs":——》PostScript (.ps),
"make pdfdocs"——》pdf
"make htmldocs"——》html,
"make mandocs"——》man pages


INSTALLING the kernel source:
- If you install the full sources, put the kernel tarball in a
directory where you have permissions (eg. your home directory) and
unpack it:
gzip -cd linux-2.6.XX.tar.gz | tar xvf -
or
bzip2 -dc linux-2.6.XX.tar.bz2 | tar xvf -
Replace "XX" with the version number of the latest kernel.
Do NOT use the /usr/src/linux area! This area has a (usually
incomplete) set of kernel headers that are used by the library header
files. They should match the library

, and not get messed up by
whatever the kernel-du-jour happens to be.
- You can also upgrade between 2.6.xx releases by patching. Patches are
distributed in the traditional gzip and the newer bzip2 format. To
install by patching, get all the newer patch files, enter the
top level directory of the kernel source (linux-2.6.xx) and execute:
gzip -cd ../patch-2.6.xx.gz | patch -p1
or
bzip2 -dc ../patch-2.6.xx.bz2 | patch -p1
(repeat xx for all versions bigger than the version of your current
source tree, _in_order_) and you should be ok. You may want to remove
the backup files (xxx~ or xxx.orig), and make sure that there are no
failed patches (xxx# or xxx.rej). If there are, either you or me has
made a mistake.
Unlike patches for the 2.6.x kernels, patches for the 2.6.x.y kernels
(also known as the -stable kernels) are not incremental but instead apply
directly to the base 2.6.x kernel. Please read
Documentation/applying-patches.txt for more information.
Alternatively, the script patch-kernel can be used to automate this
process. It determines the current kernel version and applies any
patches found.
linux/scripts/patch-kernel linux
The first argument in the command above is the location of the
kernel source. Patches are applied from the current directory, but
an alternative directory can be specified as the second argument.
- If you are upgrading between releases using the stable series patches
(for example, patch-2.6.xx.y), note that these "dot-releases" are
not incremental and must be applied to the 2.6.xx base tree. For
example, if your base kernel is 2.6.12 and you want to apply the
2.6.12.3 patch, you do not and indeed must not first apply the
2.6.12.1 and 2.6.12.2 patches. Similarly, if you are running kernel
version 2.6.12.2 and want to jump to 2.6.12.3, you must first
reverse the 2.6.12.2 patch (that is, patch -R) _before_ applying
the 2.6.12.3 patch.
You can read more on this in Documentation/applying-patches.txt
- Make sure you have no stale .o files and dependencies lying around:
cd linux
make mrproper
You should now have the sources correctly installed.


安装内核源码
如果你是从全新的完整的内核源码包安装,那么请将源码压缩包放置于你拥有
权限的路径下(如:你的用户主路径)并解压,解压命令如下:

gzip -cd ../patch-2.6.xx.gz | patch -p1
或者
bzip2 -dc ../patch-2.6.xx.bz2 | patch -p1
xx是你所要安装的内核版本号。
安装源码的时候,不要使用/usr/src/linux路径,这通常是当前运行内核的头文件所在路径,
需要与所安装的各个内核对应,无论如何要不能将其弄乱。

除了完整安装最新源码,你也可以选择在2.6的各个内核源码间通过升级获取最新源码,
升级补丁通常以bzip或者bzip2格式打包,用如下命令解压并应用各升级补丁:
首先

,进入源码书顶层路径,运行:
gzip -cd ../patch-2.6.xx.gz | patch -p1
or
bzip2 -dc ../patch-2.6.xx.bz2 | patch -p1
xx是补丁的版本(好歹也要高于现有版本吧……)

打完补丁之后,你可以删除掉备份文件(xxx~ or xxx.orig)
并且确保没有失败的补丁(xxx# or xxx.rej),如果有没有成功打上的补丁,
要么是你,要么是我犯错误了……

形如2.6.x.y的补丁和形如2.6.x的补丁是不一样的,前者并不是增量形式,
而是在源码路径上直接修改(么得看懂啊T_T)
详情请看文档Documentation/applying-patches.txt

或者,你也可以使用自动化的打补丁脚本,它会根据现有内核使用找到所有能用的补丁。
linux/scripts/patch-kernel linux
上述代码的第一个参数是当前内核源码树路径,该命令会在当前路径下查找补丁,当然,
你可以利用第二个参数指定补丁所在路径。

如果你是在稳定子版本之间升级内核,那你打补丁的时候不能直接在子版本之间打,
而必须从该稳定版本的基础版本的基础上打补丁,也就是说,你不能在2.6.12.2的基础上
打2.6.12.3补丁,而是需要在2.6.12的基础上打该补丁,或者你可以将2.6.12.2利用2.6.12.2补丁
回滚至2.6.12然后再打2.6.12.3补丁……
详情请看Documentation/applying-patches.txt

最后,你需要确保你的源码树是干净的,不含有任何老的编译输出文件或者依赖文件,
可以采用以下命令:

cd linux
make mrproper

现在,新内核的源码就准备好了。


SOFTWARE REQUIREMENTS
Compiling and running the 2.6.xx kernels requires up-to-date
versions of various software packages. Consult
Documentation/Changes for the minimum version numbers required
and how to get updates for these packages. Beware that using
excessively old versions of these packages can cause indirect
errors that are very difficult to track down, so don't assume that
you can just update packages when obvious problems arise during
build or operation.
软件依赖
编译运行2.6版本内核需要升级某些软件包,详情参考Documentation/Changes
可以看到对相关软件的最低版本要求。请当心,使用太老版本的软件会导致一些诡异的错误,
这些错误会很难跟踪,所以,不要抱着侥幸心理不去升级软件包。


BUILD directory for the kernel:
When compiling the kernel all output files will per default be
stored together with the kernel source code.
Using the option "make O=output/dir" allow you to specify an alternate
place for the output files (including .config).
Example:
kernel source code: /usr/src/linux-2.6.N
build directory: /home/name/build/kernel
To configure and build the kernel use:
cd /usr/src/linux-2.6.N
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make

O=/home/name/build/kernel modules_install install
Please note: If the 'O=output/dir' option is used then it must be
used for all invocations of make.

设置内核构建路径

当编译内核的时候,编译产生的所有输出文件会被存放在对应源码所在的路径,
你也可以使用"make O=output/dir"编译选项指定输出文件(包括.config文件)存放的路径。
例如:
源码: /usr/src/linux-2.6.N
构建路径: /home/name/build/kernel
采用如下配置、安装命令:
cd /usr/src/linux-2.6.N
make O=/home/name/build/kernel menuconfig
make O=/home/name/build/kernel
sudo make O=/home/name/build/kernel modules_install install
注意:如果使用了"make O=output/dir"指定输出路径,那么其他的make相关命令也需要加上这个参数指定路径。

CONFIGURING the kernel:
Do not skip this step even if you are only upgrading one minor
version. New configuration options are added in each release, and
odd problems will turn up if the configuration files are not set up
as expected. If you want to carry your existing configuration to a
new version with minimal work, use "make oldconfig", which will
only ask you for the answers to new questions.
- Alternate configuration commands are:
"make config" Plain text interface.
"make menuconfig" Text based color menus, radiolists & dialogs.
"make nconfig" Enhanced text based color menus.
"make xconfig" X windows (Qt) based configuration tool.
"make gconfig" X windows (Gtk) based configuration tool.
"make oldconfig" Default all questions based on the contents of
your existing ./.config file and asking about
new config symbols.
"make silentoldconfig"
Like above, but avoids cluttering the screen
with questions already answered.
Additionally updates the dependencies.
"make defconfig" Create a ./.config file by using the default
symbol values from either arch/$ARCH/defconfig
or arch/$ARCH/configs/${PLATFORM}_defconfig,
depending on the architecture.
"make ${PLATFORM}_defconfig"
Create a ./.config file by using the default
symbol values from
arch/$ARCH/configs/${PLATFORM}_defconfig.
Use "make help" to get a list of all available
platforms of your architecture.
"make allyesconfig"
Create a ./.config file by setting symbol
values to 'y' as much as possible.
"make allmodconfig"
Create a ./.config file by setting symbol
values to 'm' as much as possible.
"make allnoconfig" Create a ./.config file by setting symbol
values to 'n' as much as possible.
"make randconfig" Create a ./.config file by setting symbol
values to random values.
You can find more information on using the Linux kernel config tools
in Documentation/kbuild/kconfig.txt.
NOTES on "make config":
- having unnecessary drivers will make the kernel bigger, and can
under some circumstances lead to problems:

probing for a
nonexistent controller card may confuse your other controllers
- compiling the kernel with "Processor type" set higher than 386
will result in a kernel that does NOT work on a 386. The
kernel will detect this on bootup, and give up.
- A kernel with math-emulation compiled in will still use the
coprocessor if one is present: the math emulation will just
never get used in that case. The kernel will be slightly larger,
but will work on different machines regardless of whether they
have a math coprocessor or not.
- the "kernel hacking" configuration details usually result in a
bigger or slower kernel (or both), and can even make the kernel
less stable by configuring some routines to actively try to
break bad code to find kernel problems (kmalloc()). Thus you
should probably answer 'n' to the questions for
"development", "experimental", or "debugging" features.

配置内核
无论如何,你都需要配置你的内核,即便你只是从旧版本升级到新版本
省略N字么得技术含量又不想翻译的,自己看吧
"make config" 纯文本模式,你保证伤不起
"make menuconfig" 颜色文本,有对话框,很简陋的……
"make nconfig" 上者的加强版,木有用过
"make xconfig" 基于QT图形库的图形窗口模式
"make gconfig" 基于GTK图形库的图形窗口模式
"make oldconfig" 采用 ./.config 的参数作为默认参数,只有新属性需要手动设置,但是,你还是会按回车按到手抽筋的
"make silentoldconfig"
在上者的基础上,不再问你老问题了,只问新属性怎么整。
"make defconfig" 根据你所选的体系结构,选择默认的自带的配置文件作为.config
"make ${PLATFORM}_defconfig"
同上,指定PLATFORM为你所需的体系结构,当然不能胡编乱造
"make allyesconfig"
将所有的选项设置为yes,也就是所有的东西都编译进内核,你会得到一个硕大无朋的内核的
"make allmodconfig"
尽量将所有的东西都编译为模块,
"make allnoconfig"
能省就省了,这样的内核最小了,就是不知道能干嘛。
"make randconfig"
随机,我勒个去,这个……


COMPILING the kernel:
- Make sure you have at least gcc 3.2 available.
For more information, refer to Documentation/Changes.
Please note that you can still run a.out user programs with this kernel.
- Do a "make" to create a compressed kernel image. It is also
possible to do "make install" if you have lilo installed to suit the
kernel makefiles, but you may want to check your particular lilo setup first.
To do the actual install you have to be root, but none of the normal
build should require that. Don't take the name of root in vain.
- If you configured any of the parts of the kernel as `modules', you
will also have to do "make modules_install".
- Verbose kernel compile/build output

:
Normally the kernel build system runs in a fairly quiet mode (but not
totally silent). However, sometimes you or other kernel developers need
to see compile, link, or other commands exactly as they are executed.
For this, use "verbose" build mode. This is done by inserting
"V=1" in the "make" command. E.g.:
make V=1 all
To have the build system also tell the reason for the rebuild of each
target, use "V=2". The default is "V=0".
- Keep a backup kernel handy in case something goes wrong. This is
especially true for the development releases, since each new release
contains new code which has not been debugged. Make sure you keep a
backup of the modules corresponding to that kernel, as well. If you
are installing a new kernel with the same version number as your
working kernel, make a backup of your modules directory before you
do a "make modules_install".
Alternatively, before compiling, use the kernel config option
"LOCALVERSION" to append a unique suffix to the regular kernel version.
LOCALVERSION can be set in the "General Setup" menu.
- In order to boot your new kernel, you'll need to copy the kernel
image (e.g. .../linux/arch/i386/boot/bzImage after compilation)
to the place where your regular bootable kernel is found.
- Booting a kernel directly from a floppy without the assistance of a
bootloader such as LILO, is no longer supported.
If you boot Linux from the hard drive, chances are you use LILO which
uses the kernel image as specified in the file /etc/lilo.conf. The
kernel image file is usually /vmlinuz, /boot/vmlinuz, /bzImage or
/boot/bzImage. To use the new kernel, save a copy of the old image
and copy the new image over the old one. Then, you MUST RERUN LILO
to update the loading map!! If you don't, you won't be able to boot
the new kernel image.
Reinstalling LILO is usually a matter of running /sbin/lilo.
You may wish to edit /etc/lilo.conf to specify an entry for your
old kernel image (say, /vmlinux.old) in case the new one does not
work. See the LILO docs for more information.
After reinstalling LILO, you should be all set. Shutdown the system,
reboot, and enjoy!
If you ever need to change the default root device, video mode,
ramdisk size, etc. in the kernel image, use the 'rdev' program (or
alternatively the LILO boot options when appropriate). No need to
recompile the kernel to change these parameters.
- Reboot with the new kernel and enjoy.

编译
首先,你的GCC版本得在3.2以上,并且你得确保你当前内核还能运行可执行文件。

运行 make将得到一个压缩了的内核镜像文件,如果再运行make install,你的lilo就会
得到更新以便用新内核启动。安装需要管理员权限,而编译并不需要。

如果你在配置内核的时候有选择为M的,也就是模块化的,那你还需要make modules_install以
安装相应模

块。

make的时候,可以通过参数设置是否显示编译相关信息,如:
使用make V=1 all可以看到对各个源文件的详细的编译选项
make V=2可以看到更多的信息,包括为什么要编译…………??
默认为V=0。

注意,请备份当前能运行的内核,在升级至开发版本的内核的时候更是如此。
由于新内核包含有未经测试的代码,所以有可能导致新内核无法启动,所以在
升级至同一版本号的内核之前,备份你的模块安装路径是很有必要的(在执行make modules_install之前)

当然,也可以在配置内核的时候加上"LOCALVERSION"参数,这样就能为新内核追加版本号以防止覆盖旧内核相关文件。




现在的内核已经不能够从没有loader的软盘启动了。

如果从硬盘启动,拷贝内核镜像至相关路径(路径见/etc/lilo.conf),然后重新运行lilo更新装载表,不然是启动不了滴。
额,鉴于现在很少用lilo了,下边的就不翻译了……其实么得这么麻烦,make install玩了就全都自动更新好了。

对于内核的显示模式神马的参数,只需要修改内核启动参数即可,不需要重新编译。
IF SOMETHING GOES WRONG:
- If you have problems that seem to be due to kernel bugs, please check
the file MAINTAINERS to see if there is a particular person associated
with the part of the kernel that you are having trouble with. If there
isn't anyone listed there, then the second best thing is to mail
them to me (torvalds@https://www.360docs.net/doc/b814882726.html,), and possibly to any other
relevant mailing-list or to the newsgroup.
- In all bug-reports, *please* tell what kernel you are talking about,
how to duplicate the problem, and what your setup is (use your common
sense). If the problem is new, tell me so, and if the problem is
old, please try to tell me when you first noticed it.
- If the bug results in a message like
unable to handle kernel paging request at address C0000010
Oops: 0002
EIP: 0010:XXXXXXXX
eax: xxxxxxxx ebx: xxxxxxxx ecx: xxxxxxxx edx: xxxxxxxx
esi: xxxxxxxx edi: xxxxxxxx ebp: xxxxxxxx
ds: xxxx es: xxxx fs: xxxx gs: xxxx
Pid: xx, process nr: xx
xx xx xx xx xx xx xx xx xx xx
or similar kernel debugging information on your screen or in your
system log, please duplicate it *exactly*. The dump may look
incomprehensible to you, but it does contain information that may
help debugging the problem. The text above the dump is also
important: it tells something about why the kernel dumped code (in
the above example it's due to a bad kernel pointer). More information
on making sense of the dump is in Documentation/oops-tracing.txt
- If you compiled the kernel with CONFIG_KALLSYMS you can send the dump
as is, otherwise you will have to use the "ksymoops" program to make
sense of the dump (but compiling with CONFIG_KALLSYMS is usually pref

erred).
This utility can be downloaded from
ftp://ftp.https://www.360docs.net/doc/b814882726.html,/pub/linux/utils/kernel/ksymoops/ .
Alternately you can do the dump lookup by hand:
- In debugging dumps like the above, it helps enormously if you can
look up what the EIP value means. The hex value as such doesn't help
me or anybody else very much: it will depend on your particular
kernel setup. What you should do is take the hex value from the EIP
line (ignore the "0010:"), and look it up in the kernel namelist to
see which kernel function contains the offending address.
To find out the kernel function name, you'll need to find the system
binary associated with the kernel that exhibited the symptom. This is
the file 'linux/vmlinux'. To extract the namelist and match it against
the EIP from the kernel crash, do:
nm vmlinux | sort | less
This will give you a list of kernel addresses sorted in ascending
order, from which it is simple to find the function that contains the
offending address. Note that the address given by the kernel
debugging messages will not necessarily match exactly with the
function addresses (in fact, that is very unlikely), so you can't
just 'grep' the list: the list will, however, give you the starting
point of each kernel function, so by looking for the function that
has a starting address lower than the one you are searching for but
is followed by a function with a higher address you will find the one
you want. In fact, it may be a good idea to include a bit of
"context" in your problem report, giving a few lines around the
interesting one.
If you for some reason cannot do the above (you have a pre-compiled
kernel image or similar), telling me as much about your setup as
possible will help. Please read the REPORTING-BUGS document for details.
- Alternately, you can use gdb on a running kernel. (read-only; i.e. you
cannot change values or set break points.) To do this, first compile the
kernel with -g; edit arch/i386/Makefile appropriately, then do a "make
clean". You'll also need to enable CONFIG_PROC_FS (via "make config").
After you've rebooted with the new kernel, do "gdb vmlinux /proc/kcore".
You can now use all the usual gdb commands. The command to look up the
point where your system crashed is "l *0xXXXXXXXX". (Replace the XXXes
with the EIP value.)
gdb'ing a non-running kernel currently fails because gdb (wrongly)
disregards the starting offset for which the kernel is compiled.
关于错误处理
如果你的内核不幸报错甚至崩溃了,请发送邮件至………………,当然,记得说明
你说的是什么版本的内核,并尽量把报错显示的信息发送过来。
然后就是什么地址啊,动态加载啊,什么的了,还有开启什么调试选项神马的,不想翻译了。

相关文档
最新文档