如何在Linux中编译内核? [英] How to compile the kernel in Linux?

查看:73
本文介绍了如何在Linux中编译内核?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ubunto中编译内核时遇到问题?所以请帮助...

解决方案

首先,从kernel.org或Ubuntu存储库下载您喜欢的内核包。

如果你想要Ubuntu团队打补丁的官方内核,只需输入:

代码:



 sudo apt-get install linux-tree 





在这种情况下,我们将使用最新的稳定香草内核版本。

对于编译过程,你需要在Ubuntu上使用以下软件包:

代码:



 sudo apt-get update 
sudo apt-get install build-essential
sudo apt-get install kernel-package
sudo apt-get install gcc
sudo apt- get install libncurses5
sudo apt-get install libncurses5-dev
sudo apt-get install libqt3-mt-dev





现在解压缩包:

代码:



 cd / usr / src 
sudo tar --bzip2 -xvf linux- 2 6 12 .tar.bz2





创建以下符号链接:

代码:



 sudo ln -s / usr / src / linux-  2  6  12  / usr / src / linux 
cd / usr / src / linux





现在你可以开始自定义你的内核配置了;有两种方式,第一种是图形,第二种是伪图形:

代码:



 sudo make xconfig 





或:

代码:



 sudo make menuconfig 





然后,在完成定制后,我们必须开始编译过程:

代码:



 sudo make-kpkg clean 
sudo make -kpkg --append-to-version = -custom kernel_image modules_image





修订标志是可选的,对编辑内核很有用名字通过uname -r显示。你可以写任何你想要的而不是-custom。



还有另一个有趣且有用的标志,即--initrd。尚未启用vanilla内核才能正确使用initrd,实际上还有一个补丁。 Ubuntu官方内核是一个带有一些补丁的vanilla内核,其中有一个用于initrd。所以,如果你正在编译一个vanilla内核,你应该把--initrd拿出来;否则,如果你正在编译一个Ubuntu内核,你可以使用initrd,你可能就是这样。



注意,现在你将有一个.deb包在/ usr / src中,通过简单的双击即可安装为任何其他软件包。

Grub将自动更新。

所以,只需键入:

代码:



 sudo dpkg -i kernel-image-  2  6  12  -custom_10。 00  .Custom_i386.deb 


I am having problem in the compilation of the kernel in ubunto? so please help...

解决方案

First of all, download the kernel package you like from kernel.org or from the Ubuntu repositories.
If you want the official kernel patched by the Ubuntu Team, just type:
Code:

sudo apt-get install linux-tree



In this case we''ll use the latest stable vanilla kernel version available.
For the compile process you''ll need the following packages on Ubuntu:
Code:

sudo apt-get update
   sudo apt-get install build-essential
   sudo apt-get install kernel-package
   sudo apt-get install gcc
   sudo apt-get install libncurses5
   sudo apt-get install libncurses5-dev
   sudo apt-get install libqt3-mt-dev



Now untar the package:
Code:

cd /usr/src
   sudo tar --bzip2 -xvf linux-2.6.12.tar.bz2



Create the following symlink:
Code:

sudo ln -s /usr/src/linux-2.6.12 /usr/src/linux
   cd /usr/src/linux



Now you can start customizing your kernel configuration; there two way, the first one is graphical, the second one pseudo-graphical:
Code:

sudo make xconfig



Or:
Code:

sudo make menuconfig



Then, after having finished the customization, we have to start the compile process:
Code:

sudo make-kpkg clean
   sudo make-kpkg --append-to-version=-custom kernel_image modules_image



The revision flag is optional and is just useful to edit the kernel name showed through uname -r. You can write whatever you want instead of "-custom".

There''s also another interesting and useful flag, that is --initrd. The vanilla kernel is not enable yet to make use of initrd properly, and in fact there''s a patch for this. The Ubuntu official kernel is a vanilla kernel patched with some patches among which there''s the one for initrd. So, if you are compiling a vanilla kernel, you should take --initrd out; otherwise, if you are compiling a Ubuntu kernel, you can make use of initrd and you probably would that.

Note that now you''ll have a .deb package in /usr/src ready to be installed as any other package through a simple double-click.
Grub will be updated automatically.
So, just type:
Code:

sudo dpkg -i kernel-image-2.6.12-custom_10.00.Custom_i386.deb


这篇关于如何在Linux中编译内核?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆