1.寻找相关内核
apt-cache search linux-source
linux-source - Linux kernel source with Ubuntu patches
linux-source-2.6.32 - Linux kernel source for version 2.6.32 with Ubuntu patches
2.下载内核
sudo apt-get install linux-source-2.6.32
3.下载完成,可以看到内核源码:/usr/src/linux-source-2.6.32.tar.bz2
4.解压源码:
cd /usr/src/
sudo tar -xjvf linux-source-2.6.32.tar.bz2
5.进入内核目录,配置,编译:
sudo make oldconfig //从目录运行的系统中生成一份.config
sudo make bzImage
sudo make modules
sudo make modules_install
sudo make install
6.这时,在/boot/目录中:
$ ls /boot/ -l
total 21216
-rw-r--r-- 1 root root 646334 2011-07-08 09:00 abi-2.6.32-33-generic
-rw-r--r-- 1 root root 110252 2015-03-02 21:57 config-2.6.32.11+drm33.2
-rw-r--r-- 1 root root 110578 2011-07-08 09:00 config-2.6.32-33-generic
drwxr-xr-x 3 root root 4096 2015-02-02 12:50 grub
-rw-r--r-- 1 root root 8369062 2015-01-28 23:32 initrd.img-2.6.32-33-generic
-rw-r--r-- 1 root root 160280 2010-03-23 17:40 memtest86+.bin
-rw-r--r-- 1 root root 2099740 2015-03-02 21:57 System.map-2.6.32.11+drm33.2
-rw-r--r-- 1 root root 2156784 2011-07-08 09:00 System.map-2.6.32-33-generic
-rw-r--r-- 1 root root 1336 2011-07-08 09:03 vmcoreinfo-2.6.32-33-generic
-rw-r--r-- 1 root root 4000160 2015-03-02 21:57 vmlinuz-2.6.32.11+drm33.2
-rw-r--r-- 1 root root 4050464 2011-07-08 17:00 vmlinuz-2.6.32-33-generic<span style="font-family:Arial, Helvetica, sans-serif;"><span style="white-space: normal;">
</span></span>
在/lib/modules/目录中:
$ ls /lib/modules/
2.6.32.11+drm33.2 2.6.32-33-generic
7.制作initrd.img:
sudo mkinitramfs 2.6.32.11+drm33.2 -o /boot/initrd.img-2.6.32.11+drm33.2
8.更新grub:
sudo update-grub
重启,在选择操作系统时便多了一项:
2.6.32.11+drm33.2
选中它便可从你编译的内核启动,不知为何,我的电脑启动的过程特别慢,需要2,3分钟。
编译过程如出现;(ld: /ubuntu/omnibook/sections.lds: No such file: No such file or directory )
解决方法:
在/usr/src/linux-source-2.6.32/ubuntu/omnibook/Makefile 中
ifeq ($(KERNELRELEASE),)
# Support for direct Makefile invocation
的前面增加:
PWD=$(shell pwd)