This page tells how to rebuild the Ubuntu Linux kernel package. This is the most straightforward way of compiling your own Ubuntu kernel, but it's also rather heavyweight. If you plan on doing any kernel developing or debugging, you'd probably be happier following the KernelByHandHowto. It's a bit more involved, but a lot more flexible.
本页谈论如何重建Ubuntu Linux内核包。这是自己编译Ubuntu内核最直接的方法,但它也是相当重量级的方法。如果你打算做一些内核开发或调试的话,你也许会更高兴地按照本指南来做。它更复杂一点但也更灵活。
We will build everything in the "linux" directory (or whatever you want to call it) in your home directory. The steps that must be run as root are prefixed by "sudo".
$ sudo apt-get build-dep linux-source-
$ mkdir ~/linux
$ cd ~/linux
$ apt-get source linux-source-
$ cd linux-source-
Note that this technique can take a lot of disk space, especially if you don't disable any flavours (see below). My tree, with all flavours enabled, takes up 1.6 GB. It might take even more disk space during the compile.
注意:这种方式需要很大的磁盘空间,尤其是在你想要一些特色时(看下面)。My tree在实现全部特色时,需要1.6G。它可能在编译期间甚至需要更多的磁盘空间。
At this point, you may want to change your kernel's configuration. Modify the appropriate file in debian/config/ARCH/ (i.e., if my current kernel is named "linux-p_w_picpath-", I would edit debian/config/i386/686).
You will probably also want to delete the other configurations that you don't care about. Or, at least, move them into another directory. Otherwise, you'll build every flavour from scratch -- a very time consuming process. The following example disables every flavour except for 686.
$ cd debian/config/i386
$ mkdir disabled
$ mv * disabled
$ mv disabled/686 .
Now that the source is installed and configured, build it. If you didn't limit the flavours above, this could take a very long time (about 7 hours on my 1 GHz? laptop).
-B says to only create the architecture-dependent binary files, and -uc and -us say that the files shouldn't be cryptographically signed. -rfakeroot allow you to do everything as a regular (non-root) user.
-B 是说只构建依赖结构的两进制文件,-uc和-us 是指这些文件不能被加密,-rfakerroot 允许你作为一般(非根)用户去做任何事。
$ cd ~/linux/linux-source-
$ dpkg-buildpackage -B -uc -us -rfakeroot
Now install the brand new package.
$ cd ~/linux
$ sudo dpkg -i linux/linux-p_w_picpath-
Build Link
If you are going to build any out-of-tree 2.6 drivers, they will probably require links to the build environment from /lib/modules. You will need to set these up by hand. Of course, replace USER with your user name, or otherwise enure that you specify a full path to the linux directory you used to build the package.
$ sudo ln -s /home/USER/linux/linux-source- /lib/modules/
$ sudo ln -s /home/USER/linux/linux-source- /lib/modules/
You should set up your bootloader as recommended in the Bootloader section of the KernelCompileHowto.
And reboot the computer!
What about revisions numbers? When building with make-kpkg, you can use --revision=custom.xx to create your custom kernel revision.
How revisions are handled using this method?
How to handle ABI changes?
--mukesh agrawal, Sat, 14 May 2005 19:28:29 +0100
I tried building a kernel by following the above instructions. But the kernel had some ABI changes (I disabled the kernel's loop block device support, so that I could build loop-aes). The build system spit out the following error
"ABI has changed! Refusing to continue; please update the ABINAME accordingly. Differences:"
but didn't give any hint on where/how to change the ABINAME. I tried what seemed like the most obvious thing (editing debian/abi/<kernel-version>/abiname), but that edit seems to have been clobbered by the build system.
Editing .config --mukesh agrawal, Sat, 14 May 2005 19:34:19 +0100
编辑.config --mukesh agrawal, Sat, 14 May 2005 19:34:19 +0100
AFAIK, this build process doesn't let you run make config in the build tree. So is the recommended approach to run make config in your own tree, and then copy the .config file over? (Editing .config by hand seems like a bad idea.)
就我所知,该处理过程并非让你在构建树中运行make config。而是建议在你自己的树中作近似处理,然后拷贝并覆盖.config文件?(手动编辑.config看上去并不是好的办法)
Build Process --mukesh agrawal, Sat, 14 May 2005 19:36:40 +0100
构建处理 --mukesh agrawal, Sat, 14 May 2005 19:36:40 +0100
Seems like this build process always cleans out the tree before building. Could someone confirm, and add a note to this effect? Because the build time is so long for the Ubuntu .config, it is useful to know beforehand that you really need to get your source and .config the way you want them before building. The document currently hints at this, by saying the process is "heavyweight", but I think stating this explicitly would be useful.