当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 9 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : KernelHowto
帖子发表于 : 2005-07-22 14:17 
论坛管理员

注册: 2005-03-27 0:06
帖子: 10116
系统: Ubuntu 12.04
送出感谢: 7
接收感谢: 128
How to install a custom Linux kernel

1. How to install a custom Linux kernel
1. Preparation
2. Obtaining the Source
3. Unpacking the Source
4. Configuring the kernel
5. Building your kernel
1. make-kpkg
2. --append-to-version
3. --revision
4. Kernel package names
5. fakeroot
6. Making the kernel image
6. Installing the kernel-image package
7. Wrapping it all up
1. Hold that kernel!
2. Removing the symlink
3. Backing up your kernel
4. Making a new boot diskette
5. Building your next kernel
6. Using an existing configuration
8. Checklist
9. Outside Links

The Linux kernel is the heart of your Ubuntu Operating System. The kernel that comes with Ubuntu should contain all of the drivers you need, but just in case you would like to tweak your kernel or if for some reason you need to recompile for some special reason this guide will help you.

A less detailed document that shows essentially the same steps as this one can be found in the KernelCompileHowto.
Preparation

You will need the build-essential fakeroot and kernel-package packages, to build a kernel.

bash:~$ sudo apt-get install build-essential fakeroot kernel-package

Kernels are built in the /usr/src/ directory. To work there, add yourself to the src group.

bash:~$ sudo adduser my_username src
Adding user my_username to group src...
Done.

Log out and log back in, or use su to log in again:

bash:~$ su my_username
bash:~$ groups
my_username src audio adm dialout cdrom floppy video plugdev lpadmin

Will list all the groups you are in, src should be one of them.
Obtaining the Source

Find the kernel source you want with

bash:~$ apt-cache search source 2.6

Choose the kernel source of your liking.

*

/!\ Question: The kernel source is sometimes called kernel-source-2.6.5 etc and sometimes linux-source-2.6.8.1. Why?

kernel-source comes from Debian, linux-source comes from Ubuntu. Use linux-source if at all possible. All the dependencies haven't been changed over yet, though, so if you get warnings about "uninstalled package kernel-source" even though linux-source is installed, you can safely ignore them. -- Bronson

Download the kernel source using the following command.

bash:~$ sudo apt-get install linux-source

{i} it might suggest installing the packages libncurses-dev and libqt3-dev, the first one is needed for menuconfig, the second for xconfig, install at least one of them (see further below).

It will download and place the source in /usr/src
Unpacking the Source

I will use the 2.6.8.1 kernel as an example since this is the latest kernel Ubuntu ships at the moment of writing.

bash:~$ cd /usr/src
bash:/usr/src$ ls -l
linux-source-2.6.8.1.tar.bz2

If you see a link called linux to an older kernel source remove it.

bash:/usr/src$ rm linux

/!\ do not unpack your kernel if the link is still there. If your new source gets extracted in your old kernel source directory, building will not be successful.

and extract the archive with

bash:/usr/src$ tar xjvf linux-source<version>.tar.bz2

/!\ Do not do this with sudo, it is not necessary.

{i} If the source is a .bz2 use tar jxvf, if it is a .gz use tar zxvf

This should create a directory called linux-source-2.6.8.1 owned by you and the src group.

Create a link called linux to the kernel source

bash:/usr/src$ ln -s linux-source-2.6.8.1 linux

Check if it's all in place. You should see something like:

bash:/usr/src$ ls
linux@ linux-source-2.6.8.1/ linux-source-2.6.8.1.tar.bz2

Configuring the kernel

There are several ways to configure the kernel. You will probably use "xconfig". Once you've changed to the /usr/src/linux directory, start it like this:

bash:/usr/src/linux$ make xconfig

If you are not using X, or don't want to use your mouse:

bash:/usr/src/linux$ make menuconfig

/!\ Warning: you need to ensure that, at a minimum, your bus, disk, and root filesystem drivers are statically compiled into your kernel. Otherwise, your new kernel image won't boot. See the KernelBuildpackageHowto for a technique that doesn't require reconfiguring the kernel.
Building your kernel
make-kpkg

To build the kernel you'll invoke "make-kpkg", a script which automates and replaces the sequence "make dep; make clean; make bzImage; make modules". Take a few minutes and read over the manual page for make-kpkg. The make-kpkg command line can be complex and at first intimidating. Its basic syntax is

bash:/usr/src$ make-kpkg <options> <target>

Your target will be "kernel_image". Let's examine two of the more important and common options, "--append-to-version" and "--revision".
--append-to-version

The first option lets you specify an addition to the kernel version, which then becomes part of the kernel's name. You may use alphanumeric characters, "+" and "." (period or full stop); do not use underscore "_".

Here's the kernel I'm running now:

bash:/usr/src$ /usr/src/$ uname -a
Linux da5id 2.6.8.1-2-k7 #1 Sat Sep 18 11:23:11 BST 2004 i686 GNU/Linux

/!\ You should avoid using --append-to-version values such as "-686", "-K7", and "-sparc". They are commonly used for Debian pre-compiled kernels.

Kernel modules live in subdirectories of /lib/modules; each kernel has its own subdirectory. Every time you install a kernel image with a new name, the package installer creates a new subdirectory of /lib/modules to hold its modules.

This means that by using a new value for --append-to-version each time you build a kernel image, you can ensure that the new kernel will have a new name, and that its modules won't conflict with those of other kernels.

/!\ If you install a kernel with the same name (the same version and --append-to-version) as an already-installed kernel, installing the new kernel package will overwrite the old kernel and its modules. You will be warned and offered the chance to abort. Take it. Use another value for --append-to-version and rebuild.
--revision

Another make-kpkg option is "--revision", which affects the name of the Debian package itself but not the kernel name. As with --append-to-version, you may use only alphanumeric characters, "+" and ".". Do not use underscores "_". If you do not supply a value for --revision, make-kpkg will use "10.00.Custom".

Using different values of --revision will not prevent conflicts between kernels with the same name. They are just for you to see the difference, for example recompiling the same kernel with a very small change.
Kernel package names

Debian kernel-image file names have the form

kernel-image-(kernel-version)(--append-to-version)_(--revision)_(architecture).deb

The package name is everything before the first underscore.

bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb

Now you can see why underscores are not allowed in make-kpkg options — they separate the elements of package names.

I recommend using a different --append-to-version value for each kernel you compile, and letting make-kpkg assign the default revision. Date-based values work for me, but you are free to invent your own scheme.

{i} Please read /usr/share/doc/kernel-package/README.gz if --append-to-version or --revision is unclear, or if you plan on using options different from the ones I suggest. (One way to do this is "zless README.gz".) Ignore the discussions of flavours and epochs until you are more familiar with make-kpkg and with Debian packages generally; they are not likely to be useful to you now.
fakeroot

When you added yourself to the src group you made it possible to do most kernel-package work with normal user privilege. However the files that are part of a kernel package (like the kernel and kernel modules) will be owned by root and run with root privilege; they must be created with root privilege.

Using fakeroot you can start make-kpkg as a normal user, and most of the job will be run with normal permissions. Near the end of the job, fakeroot will simulate a root environment to create the kernel-image package.

The manual page for make-kpkg describes one way to use fakeroot; we will use the simpler method of putting "fakeroot" at the beginning of the make-kpkg command line, like this:

fakeroot make-kpkg <options> <target>

Making the kernel image

Finally! The time has arrived — you're ready to make the kernel image.

bash:/usr/src/linux $ fakeroot make-kpkg clean

Then do:

bash:/usr/src/linux $ fakeroot make-kpkg --append-to-version=.181004 kernel_image --initrd binary

Now all you can do is wait for the computer to finish. Take a few minutes off and enjoy yourself while the computer does its fair share of the work.
Installing the kernel-image package

Once the kernel image is built you will install the kernel-image package, which includes the kernel and its modules. First check to make sure it was built successfully by changing to the /usr/src directory and listing its contents:

bash:/usr/src/linux$ cd ..
bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb
linux@
linux-source-2.6.8.1/
linux-source-2.6.8.1.tar.bz2

There it is! Notice how the --append-to-version value became part of the kernel name.

To install the kernel and all its modules:

bash:/usr/src$ sudo dpkg -i kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb

To install a kernel-image package from disk (as opposed to installing from a Debian archive) use the full file name. You can use tab for command-line-completion.

If everything went well, all you need to do now is reboot. If your new kernel doesn't boot, boot your previous kernel or insert your boot floppy and restart. Go back to Configuring the kernel, tweak your configuration, and try again.
Wrapping it all up
Hold that kernel!

If you used --append-to-version you shouldn't need to worry about apt-get trying to "upgrade" your kernel. If you're paranoid (it is out to get you) you can make sure by doing this:

bash:~$ echo "kernel-image-2.6.8.1.181004 hold" | sudo dpkg --set-selections

Of course substitute the real name of your kernel. To refer to a package that dpkg knows about (an installed package or one in an archive's list) use the package name rather than the full file name. Also, the "|" character is made by typing Shift-\. Check that the package really is on hold; if it is you should see:

bash:~$ dpkg --get-selections | grep kernel-image
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb hold

/!\ Somebody should write about holding packages, what it does etc.
Removing the symlink

Next, you should get rid of the symlink you created in the /usr/src directory. There are several reasons for this:

1.

The next time you download a kernel it might not be from a Debian archive. When you expand the source tarball it could overwrite your old source tree right through the old symlink. Bummer.
2.

The next time you download the kernel source from the Debian archive, you might expand the source into its own tree without problems. But since you already have a symlink called "linux" in the src directory, you might go ahead and compile (forgetting of course that it's linked to your old source tree.)
3.

When you download patches or other source code into a specific source tree, you don't want anything else messing with it. By removing the symlink you might prevent #1 from happening.

To remove the link do this:

bash:~$ rm /usr/src/linux

Backing up your kernel

While not required, it's a good idea to back up your custom kernel .deb. Copy it to a secure undisclosed location.

{!} Once your kernel has been packaged with its modules, you can install it on any machine that has the hardware you specified in your kernel configuration. You could even reinstall it on your current machine after reinstalling your system.
Making a new boot diskette

Create another boot diskette, this one for the kernel you just installed. Grab another floppy — it's not a good idea to overwrite your old boot disk; you haven't been using your new kernel long enough to be sure it works. A boot disk is only necessary if you messed up your system.

bash:/usr/src# cd /boot
bash:/boot# mkboot /boot/vmlinuz-2.4.18.030320

Building your next kernel

If you want to rebuild your kernel because you just bought a new sound card, or you want to enable a new feature you forgot to include the first time, all you need to do is reconfigure, do "fakeroot make-kpkg clean", and rebuild with a different value for --append-to-version. Your session should look something like this:

bash:~$ cd /usr/src
bash:/usr/src$ ln -s linux-source-2.6.8.1 linux
bash:/usr/src$ cd linux
bash:/usr/src/linux$ make xconfig
(reconfigure your kernel)
bash:/usr/src/linux$ fakeroot make-kpkg clean
(lots of cleaning here)
bash:/usr/src/linux$ fakeroot make-kpkg --append-to-version=.181004 kernel_image --initrd binary
(screens and screens of stuff)

Using an existing configuration

When you installed your custom kernel, its configuration was copied to /boot/config-x.y.z. You may want to squirrel it away in another location (or several other locations) for safekeeping or later re-use.

Suppose that just last week you picked your way through the maze of options, and settled on a configuration that supports all the hardware and features you want. Today a new stable kernel is released and of course you want to upgrade right away. Is it necessary to start from scratch configuring the new kernel? Not at all.

Download and expand the new source tarball and make a new symlink. Then change directory to /usr/src/linux, copy your existing configuration there and do "make oldconfig":

bash:/usr/src/linux$ cp /boot/config-2.4.18.030320 .config
bash:/usr/src/linux$ make oldconfig

You'll be asked questions about new kernel options. It's generally safe to answer "no" to all the questions; make notes of the new options that interest you.

{i} After you finish oldconfig you can run xconfig or menuconfig to review your selections, change your answers, or investigate the options you noted.

Build the latest stable kernel with your own configuration.

fakeroot make-kpkg clean

Checklist

1.

Make backup boot diskette.
2.

Install required packages.
1.

build-essential fakeroot kernel-package
3.

Setup source tree.
1.

Add yourself to src. Logout, login. Use groups to confirm.
2.

Remove old symlink.
3.

Expand source tarball.
4.

Make and check new symlink.
4.

Configure kernel.
1.

Use old config file if available. cp /boot/config-x.y.z .config
2.

make oldconfig or make xconfig or make menuconfig.
3.

Save .config file somewhere else for later use.
5.

Build kernel-image package.
1.

fakeroot make-kpkg clean
2.

fakeroot make-kpkg --append-to-version=alpha+numeric.but.no.underscore kernel_image --initrd binary
6.

Install kernel-image package.
1.

dpkg -i kernel-image-x.y.z.yy.mm.dd_10.00.Custom_i386.deb
2.

Reboot.
7.

What next?
8.

Hold your package. echo "kernel-image-x.y.z.yymmdd hold" | dpkg --set-selections
9.

Remove symlink.
10.

Back up kernel image.
11.

Remove old kernel image packages.
12.

Make new boot diskette.

Outside Links

Here are some links to other ways of building the kernel.

*

[WWW] Ben Edwards Article
*

[WWW] Debian Kernel 2.6 How To
*

{OK} [WWW] Creating custom kernels with Debian's kernel-package system


https://wiki.ubuntu.com/KernelHowto


_________________
当净其意如虚空,远离妄想及诸取,令心所向皆无碍


页首
 用户资料  
 
2 楼 
 文章标题 :
帖子发表于 : 2005-07-23 16:47 

注册: 2005-05-07 23:57
帖子: 3025
送出感谢: 0 次
接收感谢: 0 次
How to install a custom Linux kernel
如何安装一个自定义的 Linux 内核

1. How to install a custom Linux kernel
1.如何安装一个自定义的 Linux 内核
  1. Preparation
  1. 预备

  2. Obtaining the Source
  2. 获取源码

  3. Unpacking the Source
  3. 解压源码

  4. Configuring the kernel
  4. 配置内核

  5. Building your kernel
  5. 建立你的内核
    1. make-kpkg

    2. --append-to-version
    3. --revision
    4. Kernel package names
    5. fakeroot
    6. Making the kernel image
    6. 制作内核镜像

  6. Installing the kernel-image package
  6. 安装 kernel-image 包

  7. Wrapping it all up
  7.
    1. Hold that kernel!
    2. Removing the symlink
    2. 移除 symlink
    3. Backing up your kernel
    3. 备份你的内核
    4. Making a new boot diskette
    4. 制作一个新的启动软盘
    5. Building your next kernel
    5. 建立你的下一个内核
    6. Using an existing configuration
    6.使用一个已有的配置

  8. Checklist
  9. Outside Links


_________________
独自看一看大海
总想起身边走在路上的朋友
Lenovo E290-420[Celeron-M420/256M/60G/Intel GMA950]


页首
 用户资料  
 
3 楼 
 文章标题 :
帖子发表于 : 2005-07-23 18:30 

注册: 2005-05-07 23:57
帖子: 3025
送出感谢: 0 次
接收感谢: 0 次
The Linux kernel is the heart of your Ubuntu Operating System. The kernel that comes with Ubuntu should contain all of the drivers you need, but just in case you would like to tweak your kernel or if for some reason you need to recompile for some special reason this guide will help you.
Linux 内核是你的 Ubuntu 操作系统的心脏。与 Ubuntu 一起提供的内核应该包含所有你需要的驱动程序,但万一你想优化你的内核,或者出于某些特殊原因你需要重新编译,这手册将对你有帮助。

A less detailed document that shows essentially the same steps as this one can be found in the KernelCompileHowto.
可以在 KernelCompileHowto 中找到一篇跟这里步骤基本相同,但较为简洁的文档。

Preparation
预备

You will need the build-essential fakeroot and kernel-package packages, to build a kernel.
你将需要 build-essential fakeroot 和 kernel-package 软件包去建立一个内核。


代码:
bash:~$ sudo apt-get install build-essential fakeroot kernel-package


Kernels are built in the /usr/src/ directory. To work there, add yourself to the src group.
内核是被建立在 /usr/src/ 目录。为了在那工作,把你自己添加到 src 用户组中。
代码:
bash:~$ sudo adduser my_username src
Adding user my_username to group src...
Done.


Log out and log back in, or use su to log in again:
注销并重新登陆,或者使用 su 再次登陆:
代码:
bash:~$ su my_username
bash:~$ groups
my_username src audio adm dialout cdrom floppy video plugdev lpadmin


Will list all the groups you are in, src should be one of them.
将列出所有你所在的用户组,src 应该是其中之一。

Obtaining the Source
获取源码

Find the kernel source you want with
查找你所需要的内核源码:
代码:
bash:~$ apt-cache search source 2.6


Choose the kernel source of your liking.
选择你喜欢的内核源码

/!\ Question: The kernel source is sometimes called kernel-source-2.6.5 etc and sometimes linux-source-2.6.8.1. Why?
/!\ 问题:内核源码一时称为 kernel-source-2.6.5 等,一时又称为 linux-source-2.6.8.1,为什么?
kernel-source comes from Debian, linux-source comes from Ubuntu. Use linux-source if at all possible. All the dependencies haven't been changed over yet, though, so if you get warnings about "uninstalled package kernel-source" even though linux-source is installed, you can safely ignore them. -- Bronson
kernel-source 来自 Debian,linux-source 来自 Ubuntu。如果完全可能,请使用 linux-source 。所有的依赖关系都还没有改变,然而,尽管 linux-source 已经安装,如果你得到有关"uninstalled package kernel-source" 的警告,你可以安全地忽略它们。── Bronson

Download the kernel source using the following command.
使用下面命令下载内核源码:
代码:
bash:~$ sudo apt-get install linux-source


{i} it might suggest installing the packages libncurses-dev and libqt3-dev, the first one is needed for menuconfig, the second for xconfig, install at least one of them (see further below).
{i} 建议安装 libncurses-dev 和 libqt3-dev 软件包,第一个 menuconfig 需要,第二个 xconfig 需要,至少安装它们其中一个(更多请看下面)。

It will download and place the source in /usr/src
这将下载并安置内核在 /usr/src 。

Unpacking the Source
解压源码

I will use the 2.6.8.1 kernel as an example since this is the latest kernel Ubuntu ships at the moment of writing.
我将以 2.6.8.1 内核作为例子,因为它在我写这篇文档时是 Ubuntu 里最新的内核。

代码:
bash:~$ cd /usr/src
bash:/usr/src$ ls -l
linux-source-2.6.8.1.tar.bz2


If you see a link called linux to an older kernel source remove it.
如果你看到一个名为 linux 的链接,连接到一个更老的内核源码,请移除它。
代码:
bash:/usr/src$ rm linux


/!\ do not unpack your kernel if the link is still there. If your new source gets extracted in your old kernel source directory, building will not be successful.
/!\ 如果这链接仍在那,请不要解压你的内核。如果你的新源码提取到你老内核源码的目录,建立工作将会失败的。

and extract the archive with
解压缩归档文件:
代码:
bash:/usr/src$ tar xjvf linux-source<version>.tar.bz2


/!\ Do not do this with sudo, it is not necessary.
/!\ 不要使用sudo做这个,这是没必要的。

{i} If the source is a .bz2 use tar jxvf, if it is a .gz use tar zxvf
{i} 如果源码是一个 .bz2 ,使用 tar jxvf ;如果它是一个.gz 使用 tar zxvf

This should create a directory called linux-source-2.6.8.1 owned by you and the src group.
这将建立一个叫做 linux-source-2.6.8.1 的目录,它属于你和 src 用户组。

Create a link called linux to the kernel source
建立一个叫 linux 的链接到内核源码:

代码:
bash:/usr/src$ ln -s linux-source-2.6.8.1 linux


Check if it's all in place. You should see something like:
检查是否全部都在适当位置。你应该看到类似的:
代码:
bash:/usr/src$ ls
linux@  linux-source-2.6.8.1/  linux-source-2.6.8.1.tar.bz2



Configuring the kernel
配置内核

There are several ways to configure the kernel. You will probably use "xconfig". Once you've changed to the /usr/src/linux directory, start it like this:
有几种方法去配置内核。你将可能使用到 "xconfig" 。一旦你已经切换到 /usr/src/linux 目录,像这样开始吧:

代码:
bash:/usr/src/linux$ make xconfig


If you are not using X, or don't want to use your mouse:
如果你不在使用 X ,或者不想使用鼠标:

代码:
bash:/usr/src/linux$ make menuconfig


/!\ Warning: you need to ensure that, at a minimum, your bus, disk, and root filesystem drivers are statically compiled into your kernel. Otherwise, your new kernel image won't boot. See the KernelBuildpackageHowto for a technique that doesn't require reconfiguring the kernel.
/!\ 警告:你需要确保你的 bus 、disk 和 root filesystem 驱动程序已经静态编译进你的内核。否则,你的新内核镜像将不能启动。去 KernelBuildpackageHowto 察看不需要重新配置内核的方法。

Building your kernel
建立你的内核

make-kpkg

To build the kernel you'll invoke "make-kpkg", a script which automates and replaces the sequence "make dep; make clean; make bzImage; make modules". Take a few minutes and read over the manual page for make-kpkg. The make-kpkg command line can be complex and at first intimidating. Its basic syntax is
为了建立内核,你将要调用 "make-kpkg" ,一个自动化取代 "make dep; make clean; make bzImage; make modules" 这一顺序的脚本。花几分钟仔细阅读 make-kpkg 的指南页面。make-kpkg 命令行可以是复杂的和起初有点吓人的。它的基本语法是:
代码:
bash:/usr/src$ make-kpkg <选项> <目标>


Your target will be "kernel_image". Let's examine two of the more important and common options, "--append-to-version" and "--revision".
你的目标将是 "kernel_image" 。让我们探讨两个更重要和常用的选项,"--append-to-version" 和 "--revision" 。


--append-to-version

The first option lets you specify an addition to the kernel version, which then becomes part of the kernel's name. You may use alphanumeric characters, "+" and "." (period or full stop); do not use underscore "_".
第一个选项让你指定一个附加给内核版本,它以后会成为内核名字的一部分。你可以使用字母数字的字符,"+" 和 "."(小数点或句号);不要使用下划线"_" 。

Here's the kernel I'm running now:
这里是我正在运行的内核:
代码:
bash:/usr/src$ /usr/src/$ uname -a
Linux da5id 2.6.8.1-2-k7 #1 Sat Sep 18 11:23:11 BST 2004 i686 GNU/Linux


/!\ You should avoid using --append-to-version values such as "-686", "-K7", and "-sparc". They are commonly used for Debian pre-compiled kernels.
/!\ 你应试避免使用像 "-686", "-K7", 和 "-sparc" 的 --append-to-version 值。它们通常用于 Debian 预编译的内核。

Kernel modules live in subdirectories of /lib/modules; each kernel has its own subdirectory. Every time you install a kernel image with a new name, the package installer creates a new subdirectory of /lib/modules to hold its modules.
内核模块在 /lib/modules 的子目录;各内核有各自的子目录。每次你使用一个新名字安装一个内核镜像,软件包安装程序会建立一个 /lib/modules 的新子目录去放置它的模块。

This means that by using a new value for --append-to-version each time you build a kernel image, you can ensure that the new kernel will have a new name, and that its modules won't conflict with those of other kernels.
这意味着每次使用一个新的 --append-to-version 值去建立内核镜像,你得确保那新内核有一个新名字,那么它的模块就不会因此和其他内核冲突。

/!\ If you install a kernel with the same name (the same version and --append-to-version) as an already-installed kernel, installing the new kernel package will overwrite the old kernel and its modules. You will be warned and offered the chance to abort. Take it. Use another value for --append-to-version and rebuild.
/!\ 如果你使用一个跟已安装内核相同的名字(相同版本和 --append-to-version)去安装一个新内核,新安装的内核软件包将会覆盖旧内核和它的模块。你将会被警告,并提供机会你去中止。抓住机会,使用其他的 --append-to-version 值去重新建立。

--revision

Another make-kpkg option is "--revision", which affects the name of the Debian package itself but not the kernel name. As with --append-to-version, you may use only alphanumeric characters, "+" and ".". Do not use underscores "_". If you do not supply a value for --revision, make-kpkg will use "10.00.Custom".
另一个 make-kpkg 选项是 "--revision",它指派 Debian 软件包自身的名字,而不是内核名字。类似 --append-to-version ,你只可以使用字母数字的字符,"+" 和 "."(小数点或句号);不要使用下划线"_" 。如果你不提供一个值给 --revision ,make-kpkg 会使用 "10.00.Custom" 。


Using different values of --revision will not prevent conflicts between kernels with the same name. They are just for you to see the difference, for example recompiling the same kernel with a very small change.
使用不同的 --revision 值并不能避免相同名字内核之间的冲突。它们仅仅方便你去区别,例如,用一个十分小的改动去重新编译相同的内核。


Kernel package names
内核软件包的名字

Debian kernel-image file names have the form
Debian kernel-image 的文件名具有这格式:

代码:
kernel-image-(kernel-version)(--append-to-version)_(--revision)_(architecture).deb


The package name is everything before the first underscore.
软件包名字是在第一个下划线前的所有东西。

代码:
bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb


Now you can see why underscores are not allowed in make-kpkg options — they separate the elements of package names.
现在你可以看到为什么 make-kpkg 的选项不允许有下划线──它们隔开软件包名字的元素。

I recommend using a different --append-to-version value for each kernel you compile, and letting make-kpkg assign the default revision. Date-based values work for me, but you are free to invent your own scheme.
我再次强调为每一个你编译的内核使用一个不同的 --append-to-version 值,并使 make-kpkg 指派默认的 revision 。我使用 Date-based 这个值,但你可以自由地创造你自己的方案。

{i} Please read /usr/share/doc/kernel-package/README.gz if --append-to-version or --revision is unclear, or if you plan on using options different from the ones I suggest. (One way to do this is "zless README.gz".) Ignore the discussions of flavours and epochs until you are more familiar with make-kpkg and with Debian packages generally; they are not likely to be useful to you now.
{i} 如果 --append-to-version 或 --revision 还不清楚的,或者如果你打算使用不同于我所建议的选项,请阅读 /usr/share/doc/kernel-package/README.gz 。(这里的一个方法是 "zless README.gz" 。)忽略特色和时期的讨论,直到你对 make-kpkg 和 Debian 软件包大体上比较通晓;它们现在好像对你没什么用处。


fakeroot

When you added yourself to the src group you made it possible to do most kernel-package work with normal user privilege. However the files that are part of a kernel package (like the kernel and kernel modules) will be owned by root and run with root privilege; they must be created with root privilege.
当你添加自己进 src 用户组,你令以普通用户的权限去做大多数的 kernel-package 工作成为可能。然而,属于内核软件包一部分的文件(如内核和内核模块)将属于 root ,并用 root 权限运行;它们必须用 root 权限去建立。

Using fakeroot you can start make-kpkg as a normal user, and most of the job will be run with normal permissions. Near the end of the job, fakeroot will simulate a root environment to create the kernel-image package.
使用 fakeroot,你可以以一个普通用户去启动 make-kpkg,并且大部分工作将以普通权限运行。接近工作的尾声,fakeroot 将模拟一个 root 环境去建立 kernel-image 软件包。

The manual page for make-kpkg describes one way to use fakeroot; we will use the simpler method of putting "fakeroot" at the beginning of the make-kpkg command line, like this:
make-kpkg 的指南页面叙述使用 fakeroot 的一种方法;我们将简单地放置 "fakeroot" 在 make-kpkg 命令行的开头,像这样:
代码:
fakeroot make-kpkg <options> <target>



Making the kernel image
制作内核镜像

Finally! The time has arrived — you're ready to make the kernel image.
最后时刻终于到了──你即将制作内核镜像。

代码:
bash:/usr/src/linux $ fakeroot make-kpkg clean


Then do:
然后:

代码:
bash:/usr/src/linux $ fakeroot make-kpkg --append-to-version=.181004 kernel_image --initrd binary


Now all you can do is wait for the computer to finish. Take a few minutes off and enjoy yourself while the computer does its fair share of the work.
现在所有我们能做的就是等计算机完工。过几分钟,当计算机完成它应做的那份工作后,你就可以享受快乐了。


Installing the kernel-image package
安装 kernel-image 软件包

Once the kernel image is built you will install the kernel-image package, which includes the kernel and its modules. First check to make sure it was built successfully by changing to the /usr/src directory and listing its contents:
一旦内核镜像建好,你将安装包含了内核和它的模块的 kernel-image 软件包。首先检查一下,确保它是成功建立了,切换到 /usr/src 目录,然后列出它的内容:
代码:
bash:/usr/src/linux$ cd ..
bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb
linux@
linux-source-2.6.8.1/
linux-source-2.6.8.1.tar.bz2



There it is! Notice how the --append-to-version value became part of the kernel name.
那就是它!注意 --append-to-version 值怎样成为内核名字的一部分。

To install the kernel and all its modules:
安装内核和它的全部模块:

代码:
bash:/usr/src$ sudo dpkg -i kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb


To install a kernel-image package from disk (as opposed to installing from a Debian archive) use the full file name. You can use tab for command-line-completion.
从磁盘安装一个 kernel-image 软件包要使用文件的全名(与从一个Debian 归档文件安装相反)。你可以使用 tab 作为命令行结束。

If everything went well, all you need to do now is reboot. If your new kernel doesn't boot, boot your previous kernel or insert your boot floppy and restart. Go back to Configuring the kernel, tweak your configuration, and try again.
如果一切顺利的话,你现在要做的是重启。如果你的新内核不能启动,请启动你之前的内核或插入你的启动软盘并重启。返回到配置内核,修正你的配置,然后再试一次。


Wrapping it all up

Hold that kernel!

If you used --append-to-version you shouldn't need to worry about apt-get trying to "upgrade" your kernel. If you're paranoid (it is out to get you) you can make sure by doing this:
如果你使用 --append-to-version 你不必担心 apt-get 尝试去“升级”你的内核。如果你担心的,你可以通过以下方法来确保:
代码:
bash:~$ echo "kernel-image-2.6.8.1.181004 hold" | sudo dpkg --set-selections


Of course substitute the real name of your kernel. To refer to a package that dpkg knows about (an installed package or one in an archive's list) use the package name rather than the full file name. Also, the "|" character is made by typing Shift-\. Check that the package really is on hold; if it is you should see:
当然置换你的内核的真名。去查阅一个 dpkg 知道的软件包(一个已安装的软件包或在归档文件列表中的其一)请使用软件包名,而不是文件的全名。同样地,"|" 符号是通过键入 Shift-\ 来实现。检查软件包是真的处于 hold 状态;如果它是,你应该看到:

代码:
bash:~$ dpkg --get-selections | grep kernel-image
 kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb    hold


/!\ Somebody should write about holding packages, what it does etc.
/!\ 一定有人写了关于固定软件包版本,它是做什么的,等等。


Removing the symlink

Next, you should get rid of the symlink you created in the /usr/src directory. There are several reasons for this:


_________________
独自看一看大海
总想起身边走在路上的朋友
Lenovo E290-420[Celeron-M420/256M/60G/Intel GMA950]


页首
 用户资料  
 
4 楼 
 文章标题 :
帖子发表于 : 2005-07-23 23:08 

注册: 2005-07-21 17:48
帖子: 17
送出感谢: 0 次
接收感谢: 0 次
偶不知道楼上的朋友已经作了这项工作,今天下午我翻了一下,第一次做这项工作,肯定有不少错误,请指正。

引用:
KernelHowto

How to install a custom Linux kernel
如何安装定制linux内核

1. How to install a custom Linux kernel
如何安装定制Linux内核

1. Preparation
准备

2. Obtaining the Source
获取源代码

3. Unpacking the Source
源代码解包

4. Configuring the kernel
配置内核

5. Building your kernel
创建内核
1. make-kpkg

2. --append-to-version

3. --revision

4. Kernel package names
内核包名

5. fakeroot

6. Making the kernel image
生成内核映像

6. Installing the kernel-image package
安装内核映像包

7. Wrapping it all up
打包完工

1. Hold that kernel!
保持。。。

2. Removing the symlink
删除symlink

3. Backing up your kernel
备份你的内核

4. Making a new boot diskette
制作新引导盘

5. Building your next kernel
创建你的下一版内核

6. Using an existing configuration
使用原有配置

8. Checklist
检查列表

9. Outside Links
其他链接

The Linux kernel is the heart of your Ubuntu Operating System. The kernel that comes with Ubuntu should contain all of the drivers you need, but just in case you would like to tweak your kernel or if for some reason you need to recompile for some special reason this guide will help you.
Linux内核是Ubuntu操作系统的心脏。Ubuntu自带的内核通常包含你所需要的所有驱动程序,但有时你希望调整你的内核或如果由于某些特别原因你需要重新编译,本手册将帮助你。

A less detailed document that shows essentially the same steps as this one can be found in the KernelCompileHowto.
象这个不太详尽的文档事实上可以在KernelCompileHowto找到。

Preparation
准备


You will need the build-essential fakeroot and kernel-package packages, to build a kernel.
要创建内核,你需要buile-essential、fakeroot和kernel-package。
代码:
bash:~$ sudo apt-get install build-essential fakeroot kernel-package


Kernels are built in the /usr/src/ directory. To work there, add yourself to the src group.
内核创建工作在/usr/src/目录进行,为此,添加src组
代码:
bash:~$ sudo adduser my_username src
正在添加用户 lin 到 src 组...
完成。


Log out and log back in, or use su to log in again:
注销并重新登录,或使用su再登录(切换用户):
代码:
bash:~$ su my_username
bash:~$ groups
my_username src audio adm dialout cdrom floppy video plugdev lpadmin


Will list all the groups you are in, src should be one of them.
会列出所有组名,src是其中之一。


Obtaining the Source
获取源代码


Find the kernel source you want with
你可以用下面的办法搜索内核源代码
代码:
bash:~$ apt-cache search source 2.6


Choose the kernel source of your liking.
选择你想要的内核源代码

*/!\ Question: The kernel source is sometimes called kernel-source-2.6.5 etc and sometimes linux-source-2.6.8.1. Why?
*/!\ 问题:内核原代码有时叫kernel-source-2.6.5等,而有时又叫linux-source-2.6.8.1,为什么?

kernel-source comes from Debian, linux-source comes from Ubuntu. Use linux-source if at all possible. All the dependencies haven't been changed over yet, though, so if you get warnings about "uninstalled package kernel-source" even though linux-source is installed, you can safely ignore them. -- Bronson
kernel-source来自于Debian,linux-source来自Ubuntu。如果可能请尽量使用linux-source。All the dependencies haven't been changed over yet,虽然如此,如果你通过linux-source得到像"uninstalled package kernel-source"(反安装内核源码包)的错误警告,你可以安全地忽略他们--Bronson.


Download the kernel source using the following command.
使用下列命令下载内核源代码:
代码:
bash:~$ sudo apt-get install linux-source


{i} it might suggest installing the packages libncurses-dev and libqt3-dev, the first one is needed for menuconfig, the second for xconfig, install at least one of them (see further below).
建议安装libncurese-dev和libqt3-dev包,第一个是menuconfig所需要的,第二个用于xconfig,安装他们中的一个是很小的(见下面的内容)

It will download and place the source in /usr/src
下载并放源代码至/usr/src

Unpacking the Source
源代码解包


I will use the 2.6.8.1 kernel as an example since this is the latest kernel Ubuntu ships at the moment of writing.
我将使用UBuntu服务器上的最新的2.6.8.1内核为例来写说明
代码:
bash:~$ cd /usr/src
bash:/usr/src$ ls -l
linux-source-2.6.8.1.tar.bz2

If you see a link called linux to an older kernel source remove it.
如果你看到一个指向较老内核源代码的linux链接,请删除它。
代码:
bash:/usr/src$ rm linux


/!\ do not unpack your kernel if the link is still there. If your new source gets extracted in your old kernel source directory, building will not be successful.
如果原来的linux链接仍保存在这里的话不要解包。因为如果你的新源代码直接解包至旧内核原代码目录中,创建工作将不会成功。

and extract the archive with
解开压缩包用:
代码:
bash:/usr/src$ tar xjvf linux-source<version>.tar.bz2


/!\ Do not do this with sudo, it is not necessary.
/!\不要使用sudo,这里并不需要。

{i} If the source is a .bz2 use tar jxvf, if it is a .gz use tar zxvf
{i}如果源代码是.bz2格式,使用tar jxvf,如果是.gz则用tar zxvf

This should create a directory called linux-source-2.6.8.1 owned by you and the src group.
这里应该会以你和src组名义创建一个叫linux-source-2.6.8.1的目录。

Create a link called linux to the kernel source
创建一个叫linux的内核源代码链接
代码:
bash:/usr/src$ ln -s linux-source-2.6.8.1 linux


Check if it's all in place. You should see something like:
在当前位置查看一下,你将看到象这样的情况:
代码:
bash:/usr/src$ ls
linux@ linux-source-2.6.8.1/ linux-source-2.6.8.1.tar.bz2


Configuring the kernel
配置内核


There are several ways to configure the kernel. You will probably use "xconfig". Once you've changed to the /usr/src/linux directory, start it like this:
有几种方法来配置内核。你将可能使用"xconfig"。改变当前目录至/usr/src/linux目录,象这样启动:
代码:
bash:/usr/src/linux$ make xconfig


If you are not using X, or don't want to use your mouse:
如果你未使用X,或你不想使用鼠标:
代码:
bash:/usr/src/linux$ make menuconfig


/!\ Warning: you need to ensure that, at a minimum, your bus, disk, and root filesystem drivers are statically compiled into your kernel. Otherwise, your new kernel image won't boot. See the KernelBuildpackageHowto for a technique that doesn't require reconfiguring the kernel.
警告:至少,你必须确认将你所用的总线(bus)、磁盘(disk)、根分区文件系统(root filesystem)驱动程序直接编译进你的内核。否则,你的新内核映像将无法启动。查看 KernelBuildpackageHowto 来获得无需重新配置内核的方法。

Building your kernel
创建内核


make-kpkg

To build the kernel you'll invoke "make-kpkg", a script which automates and replaces the sequence "make dep; make clean; make bzImage; make modules". Take a few minutes and read over the manual page for make-kpkg. The make-kpkg command line can be complex and at first intimidating. Its basic syntax is
创建内核你要用到"make-kpkg",脚本会自动替换这个命令系列"make dep; make clean; make bzImage; make modules"。花点时间阅读手册中make-kpkg部分。make-kpkg命令行可能有些复杂而首次使用会被吓倒。它的基本语法是:

代码:
bash:/usr/src$ make-kpkg <options> <target>


Your target will be "kernel_image". Let's examine two of the more important and common options, "--append-to-version" and "--revision".
你的目标target将成为"kernel_image"。让我们以较为重要而通用的两个选项(options)进行探讨,"--append-to-version"和"--revision".

--append-to-version

The first option lets you specify an addition to the kernel version, which then becomes part of the kernel's name. You may use alphanumeric characters, "+" and "." (period or full stop); do not use underscore "_".
第一个选项让你添加特别项至内核版本号中,它会成为内核名的一部分。你可以使用字母,"+"和"."(小数点或句号);但不能使用下划线"_"。

Here's the kernel I'm running now:
这个是当前运行的内核:

代码:
bash:/usr/src$ /usr/src/$ uname -a
Linux da5id 2.6.8.1-2-k7 #1 Sat Sep 18 11:23:11 BST 2004 i686 GNU/Linux


/!\ You should avoid using --append-to-version values such as "-686", "-K7", and "-sparc". They are commonly used for Debian pre-compiled kernels.
/!\你使用--append-to-version时要避免使用象"-686","-k7"和"-sparc"的字串,因为它们常常在Debian预编译内核中被使用。

Kernel modules live in subdirectories of /lib/modules; each kernel has its own subdirectory. Every time you install a kernel image with a new name, the package installer creates a new subdirectory of /lib/modules to hold its modules.
内核模块放在/lib/modules子目录中;每个内核都有它自己的子目录。你每次安装新命名的内核映像,包安装器会创建一个象/lib/modules的新子目录来存放它的模块。

This means that by using a new value for --append-to-version each time you build a kernel image, you can ensure that the new kernel will have a new name, and that its modules won't conflict with those of other kernels.
这就意味着你每次用--append-to-version创建内核映像名,你可以使新内核有一个新名字,从而使它的模块不会与其他内核产生冲突。

/!\ If you install a kernel with the same name (the same version and --append-to-version) as an already-installed kernel, installing the new kernel package will overwrite the old kernel and its modules. You will be warned and offered the chance to abort. Take it. Use another value for --append-to-version and rebuild.
/!\如果你用与已安装的内核相同的名称安装内核(相同的版本号和 --append-to-version),安装新内核的包将覆盖旧内核和它的模块。这时你将被警告并被建议退出退出。退出,用另一个append-to-version值来重建内核吧。

--revision

Another make-kpkg option is "--revision", which affects the name of the Debian package itself but not the kernel name. As with --append-to-version, you may use only alphanumeric characters, "+" and ".". Do not use underscores "_". If you do not supply a value for --revision, make-kpkg will use "10.00.Custom".
另一个make-kpkg选项是"--revision",它会指定Debian的名字打包而不是内核名。如用--append-to-version,你只能使用字母,"+"和".",而不能使用线"_"。如果你不提供--revision值,make-kpkg将使用"10.00.Custom"。

Using different values of --revision will not prevent conflicts between kernels with the same name. They are just for you to see the difference, for example recompiling the same kernel with a very small change.
使用不同的--revision值将无法避免用相同内核名产生的冲突。他们只是让你看起来不同,比如重新编译变化很小的相同内核。

Kernel package names
内核包名
Debian kernel-image file names have the form
Debian内核映像文件名如:
kernel-image-(kernel-version)(--append-to-version)_(--revision)_(architecture).deb

The package name is everything before the first underscore.
在第一个下划线之前所有字符就是内核包名

代码:
bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb


Now you can see why underscores are not allowed in make-kpkg options — they separate the elements of package names.
现在你就能明白为什么下划线是不允许在make-kpkg选项中出现了--他们隔开包名的各部分。

I recommend using a different --append-to-version value for each kernel you compile, and letting make-kpkg assign the default revision. Date-based values work for me, but you are free to invent your own scheme.
我建议你为每个编译的内核使用不同的--append-to-version值,并让make-kpkg指定缺省的revision值。Date-based值对我有用,但你可以根据自己的计划自由设定。

{i} Please read /usr/share/doc/kernel-package/README.gz if --append-to-version or --revision is unclear, or if you plan on using options different from the ones I suggest. (One way to do this is "zless README.gz".) Ignore the discussions of flavours and epochs until you are more familiar with make-kpkg and with Debian packages generally; they are not likely to be useful to you now.
如果--append-to-version或--revision值未被清除,或如果你希望使用与我建议的选项不同,请阅读/usr/share/doc/kernel-package/README.gz。(可以这样做到:"zless README.gz")暂时不要去对flavours和epochs进行探讨,直到你用make-kpkg和Debian包更加熟悉;现在它们对你并不十分有用。

fakeroot

When you added yourself to the src group you made it possible to do most kernel-package work with normal user privilege. However the files that are part of a kernel package (like the kernel and kernel modules) will be owned by root and run with root privilege; they must be created with root privilege.
当你已添加你自己到src组,使用正常用户的权限就能做好创建内核包的大多数工作。然而内核包的部分(象内核和内核模块)文件将赋予root并使用root权限运行;它们必须用root权限来创建。

Using fakeroot you can start make-kpkg as a normal user, and most of the job will be run with normal permissions. Near the end of the job, fakeroot will simulate a root environment to create the kernel-image package.
使用fakeroot,你可以用普通用户来启动make-kpkg,并且大多数工作将运行于普通权限。工作接近尾声时,fakeroot将模拟一个root环境来创建内核映像包。

The manual page for make-kpkg describes one way to use fakeroot; we will use the simpler method of putting "fakeroot" at the beginning of the make-kpkg command line, like this:
手册中有关make-kpkg的部分描述了使用fakeroot的一种方法;我们将使用make-kpkg命令行开始处输入"fakeroot"的较简单的方法来做,象这样:

fakeroot make-kpkg <options> <target>

Making the kernel image
制作内核映像

Finally! The time has arrived — you're ready to make the kernel image.
最后!马上就要完工了--你准备制作一内核映像。

代码:
bash:/usr/src/linux $ fakeroot make-kpkg clean


Then do:
然后:

代码:
bash:/usr/src/linux $ fakeroot make-kpkg --append-to-version=.181004 kernel_image --initrd binary


Now all you can do is wait for the computer to finish. Take a few minutes off and enjoy yourself while the computer does its fair share of the work.
现在你所要做的就是等计算机来完成了。在计算机完美的工作中让我们轻松片刻吧。

Installing the kernel-image package
安装内核映像包


Once the kernel image is built you will install the kernel-image package, which includes the kernel and its modules. First check to make sure it was built successfully by changing to the /usr/src directory and listing its contents:
一旦内核映像被创建,你就可以安装内核映像包了,它包含内核和内核模块。首先退回/usr/src目录并列出里面的内容,来检测并确认它被成功创建。
代码:
bash:/usr/src/linux$ cd ..
bash:/usr/src$ ls
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb
linux@
linux-source-2.6.8.1/
linux-source-2.6.8.1.tar.bz2

There it is! Notice how the --append-to-version value became part of the kernel name.
有了!注意--append-to-version值是如何成为内核名的一部分的。

To install the kernel and all its modules:
安装内核和所有的内核模块:
代码:
bash:/usr/src$ sudo dpkg -i kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb


To install a kernel-image package from disk (as opposed to installing from a Debian archive) use the full file name. You can use tab for command-line-completion.
从磁盘安装内核映像包(象对应地从Debian包文件安装)要使用完整的文件名。你可以使用tab键来补齐命令行。

If everything went well, all you need to do now is reboot. If your new kernel doesn't boot, boot your previous kernel or insert your boot floppy and restart. Go back to Configuring the kernel, tweak your configuration, and try again.
如果每一步都做得很好,你现在要做的就是重新启动。如果新内核无法启动,则启动你原来的内核或插入你的引导软盘并重新启动。调整你的内核配置,重试。

Wrapping it all up
结束

Hold that kernel!

If you used --append-to-version you shouldn't need to worry about apt-get trying to "upgrade" your kernel. If you're paranoid (it is out to get you) you can make sure by doing this:
如果你已使用--append-to-version,你不需要为apt-get试图"upgrade"你的内核而担心。如果你试图这样,你只要这样:
代码:
bash:~$ echo "kernel-image-2.6.8.1.181004 hold" | sudo dpkg --set-selections


Of course substitute the real name of your kernel. To refer to a package that dpkg knows about (an installed package or one in an archive's list) use the package name rather than the full file name. Also, the "|" character is made by typing Shift-\. Check that the package really is on hold; if it is you should see:
当然你要用你真实的内核名来代替。查阅dpkg的包以了解有关使用包名比完整的文件名更好。同样,"|"字符输入是\符的上位(Shift)...
代码:
bash:~$ dpkg --get-selections | grep kernel-image
kernel-image-2.6.8.1.181004_10.00.Custom_i386.deb hold

/!\ Somebody should write about holding packages, what it does etc.

Removing the symlink
删除符号链接

Next, you should get rid of the symlink you created in the /usr/src directory. There are several reasons for this:
接下来,你要在/usr/src目录创建符号链接。这样做有几个原因:

1.The next time you download a kernel it might not be from a Debian archive. When you expand the source tarball it could overwrite your old source tree right through the old symlink. Bummer.
1.下次你下载一个不是Debian格式的内核包,当你解开这个源代码包时会通过旧符号链接覆盖你的旧源码目录树。这是令人不快的事。

2.The next time you download the kernel source from the Debian archive, you might expand the source into its own tree without problems. But since you already have a symlink called "linux" in the src directory, you might go ahead and compile (forgetting of course that it's linked to your old source tree.)
2.下次你下载Debian格式的内核源代码,你可能解开源代码到它自己的目录树这个没有问题,但你已有一个叫"linux"的符号链接在src目录里的话,你可能进入并编译旧内核(忘了它之前已经链接到一个旧源代码树)。

3.When you download patches or other source code into a specific source tree, you don't want anything else messing with it. By removing the symlink you might prevent #1 from happening.
当你下载补丁或其他源代码到一个特定的源代码树,你不要想做任何事情,则否弄坏它。通过删除符号链接可以防止#1问题的发生。

To remove the link do this:
删除符号链接这样做:
代码:
bash:~$ rm /usr/src/linux


Backing up your kernel
备份你的内核

While not required, it's a good idea to back up your custom kernel .deb. Copy it to a secure undisclosed location.
这并不是必须的,但备份你的定制内核.deb是个好主意,复制它到一个安全之处。

{!} Once your kernel has been packaged with its modules, you can install it on any machine that has the hardware you specified in your kernel configuration. You could even reinstall it on your current machine after reinstalling your system.
一旦你的内核已经与它的模块一起打包,你可以安装它到有你的硬件的其他机器上,它也可以在你重设系统后重新安装到当前机器上。

Making a new boot diskette
制作新引导盘

Create another boot diskette, this one for the kernel you just installed. Grab another floppy — it's not a good idea to overwrite your old boot disk; you haven't been using your new kernel long enough to be sure it works. A boot disk is only necessary if you messed up your system.
你刚安装好内核,要创建另一个引导磁盘。得到另一个软件--覆盖你的旧引导盘不是个好主意;你还没有足够长的时间使用你的新内核来验证它的工作。如果你弄糟了你的系统,一张引导盘是必须的。
代码:
bash:/usr/src# cd /boot
bash:/boot# mkboot /boot/vmlinuz-2.4.18.030320

Building your next kernel
创建你的下一个内核

If you want to rebuild your kernel because you just bought a new sound card, or you want to enable a new feature you forgot to include the first time, all you need to do is reconfigure, do "fakeroot make-kpkg clean", and rebuild with a different value for --append-to-version. Your session should look something like this:
如果你因为刚刚买了一块新声卡想重新编译你的内核,或你在第一次编译时忘了某个新功能,你需要做的是重新配置,"fakereoot make-kpkg clean",用不同的--append-to-version值重新编译。看起来象这样:
代码:
bash:~$ cd /usr/src
bash:/usr/src$ ln -s linux-source-2.6.8.1 linux
bash:/usr/src$ cd linux
bash:/usr/src/linux$ make xconfig
(reconfigure your kernel)
(重新配置你你的内核)
bash:/usr/src/linux$ fakeroot make-kpkg clean
(lots of cleaning here)
(这里做许多清洁工作)
bash:/usr/src/linux$ fakeroot make-kpkg --append-to-version=.181004 kernel_image --initrd binary
(screens and screens of stuff)

Using an existing configuration
使用已经存在的配置

When you installed your custom kernel, its configuration was copied to /boot/config-x.y.z. You may want to squirrel it away in another location (or several other locations) for safekeeping or later re-use.
当你安装好你制定的内核,它的配置被复制至/boot/config-x.y.z。你可能为了保险起见或以后还要使用而想保存它至其他地方(或几个地方)。

Suppose that just last week you picked your way through the maze of options, and settled on a configuration that supports all the hardware and features you want. Today a new stable kernel is released and of course you want to upgrade right away. Is it necessary to start from scratch configuring the new kernel? Not at all.
假如刚刚在上周你谨慎地通过了内核选项的迷宫,而又决定你希望支持所有硬件和功能配置,今天一个新的稳定内核被释放和导致你希望升级版本。

Download and expand the new source tarball and make a new symlink. Then change directory to /usr/src/linux, copy your existing configuration there and do "make oldconfig":
下载并解开新源代码包并创建一个新符号链接,然后改变目录至/usr/src/linux,复制你已经存在的配置到这里并"make oldconfig":
代码:
bash:/usr/src/linux$ cp /boot/config-2.4.18.030320 .config
bash:/usr/src/linux$ make oldconfig

You'll be asked questions about new kernel options. It's generally safe to answer "no" to all the questions; make notes of the new options that interest you.
你将被问及一些新内核选项的有关问题。所有的问题回答"no"它通常是安全的;新选项你应该引起注意。
{i} After you finish oldconfig you can run xconfig or menuconfig to review your selections, change your answers, or investigate the options you noted.
你完成oldconfig之后,你可以运行xconfig或menuconfig来检查你所选择的项目,改变你的答案,或研究你注意的选项。

Build the latest stable kernel with your own configuration.
用你自己的配置创建最新稳定内核

fakeroot make-kpkg clean

Checklist
检查列表


1.Make backup boot diskette.
制作备份引导盘

2.Install required packages.
安装需要的包
1.build-essential fakeroot kernel-package

3.Setup source tree.
设置源代码目录树

1.Add yourself to src. Logout, login. Use groups to confirm.
添加你自己的源代码,注销,登录,使用使用组确认。

2.Remove old symlink.
删除旧符号链接

3.Expand source tarball.
解包源代码压缩包

4.Make and check new symlink.
制作和检查新符号链接。

4.Configure kernel.
配置内核
1.Use old config file if available. cp /boot/config-x.y.z .config
使用旧的有效配置文件,cp /boot/config-x.y.z .config

2.make oldconfig or make xconfig or make menuconfig.
make oldconfig或make xconfig或make menuconfig.

3.Save .config file somewhere else for later use.
保存稍迟需要用到的.config文件

5.Build kernel-image package.
创建内核映像包

1.fakeroot make-kpkg clean

2.fakeroot make-kpkg --append-to-version=alpha+numeric.but.no.underscore kernel_image --initrd binary

6.Install kernel-image package.
安装内核映像包

1.dpkg -i kernel-image-x.y.z.yy.mm.dd_10.00.Custom_i386.deb

2.Reboot.

7.What next?
下一步是什么?

8.Hold your package. echo "kernel-image-x.y.z.yymmdd hold" | dpkg --set-selections

9.Remove symlink.
删除符号链接。

10.Back up kernel image.
备份内核映像。

11.Remove old kernel image packages.
删除旧的内核映像包。

12.Make new boot diskette.
制作新的引导磁盘。

Outside Links
其他链接


Here are some links to other ways of building the kernel.
这里是其他办法创建内核的一些链接
*[WWW] Ben Edwards Article


*[WWW] Debian Kernel 2.6 How To

*{OK} [WWW] Creating custom kernels with Debian's kernel-package system


_________________
图片


页首
 用户资料  
 
5 楼 
 文章标题 :
帖子发表于 : 2005-07-23 23:17 

注册: 2005-05-07 23:57
帖子: 3025
送出感谢: 0 次
接收感谢: 0 次
呵呵。早知我不用费力了 :wink: 我见这篇这么长,又还没人领就翻啦,谁知。。。

为了避免重复工作,
请帮忙翻译的兄弟最好能在论坛里直接跟贴翻译或说明。

不过,无论如何,兄弟你辛苦了 :P


_________________
独自看一看大海
总想起身边走在路上的朋友
Lenovo E290-420[Celeron-M420/256M/60G/Intel GMA950]


页首
 用户资料  
 
6 楼 
 文章标题 :
帖子发表于 : 2005-07-24 12:18 
论坛管理员

注册: 2005-03-27 0:06
帖子: 10116
系统: Ubuntu 12.04
送出感谢: 7
接收感谢: 128
http://www.ubuntu.org.cn/support/docume ... howto_view


_________________
当净其意如虚空,远离妄想及诸取,令心所向皆无碍


页首
 用户资料  
 
7 楼 
 文章标题 :
帖子发表于 : 2006-01-22 20:19 

注册: 2006-01-19 10:33
帖子: 62
送出感谢: 0 次
接收感谢: 0 次
这个文当过期了一点,有些内容已经改变了


比如已前翻意的不要sudo的操做现在都要了


页首
 用户资料  
 
8 楼 
 文章标题 :
帖子发表于 : 2006-02-03 20:55 

注册: 2005-09-12 7:28
帖子: 106
地址: 大连
送出感谢: 0 次
接收感谢: 0 次
建议一叶兄把翻译的工作放在wiki上。在这里只放链接。


_________________
ubuntu初学者


页首
 用户资料  
 
9 楼 
 文章标题 :
帖子发表于 : 2006-07-29 2:21 
头像

注册: 2005-07-02 14:41
帖子: 4133
系统: Ubuntu 14.04 (Kylin)
送出感谢: 53
接收感谢: 11
这篇文章好像是过期了。
链接也失效了


_________________
https://weakish.github.io


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 9 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 2 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译