日期:2014-05-16  浏览次数:20618 次

Ubuntu10.04编译安装Linux kernel 3.7.10

1. Download linux-3.7.10.bz2.

     You can download in the following website:http://www.kernel.org/


2. Copy the linux-3.7.10.bz2 to the directory /usr/src. The command is:

$ cp ~/linux-3.7.10.bz2 /usr/src

3. Umcompress the linux-3.7.10.bz2 the commands is:

$bzip2 -d linux-3.7.10.tar.bz2
$tar -xvf linux-3.7.10.tar


4. Install the relative packages, the command is:

$apt-get install build-essential libncurses5-dev libncurses5

5. Enter the directory /usr/src/linux-3.7.10, the command is:

$cd /usr/src/linux-3.7.10

6.Configure

Configure the kernel config file. using the following command:

$make menuconfig

Here, I use the default configuration.


7.Compiling

Now compiling the Linux kernel, Commands as follows:

$sudo make -j4

The -jN denoted that if your computer CPU Core is N/2, here you should use N for parallel compiling. this way could save time.


8.Install

There are two parts to install:

The first part is Linux module, using the command:

$sudo make modules_install

The second part is kernel that is compiled, using the command:

$sudo make install

9.Create  initrd.img file


initrd.img 即为初始化的 ramdisk 文件,它是一个镜像文件,将一些最基本的驱动程序和命令工具打包到镜像文件里。该镜像文件的作用是在系统还没有挂载根分区前,系统需要执行一些操作,比如挂载 scsi 驱动,此时将 initrd 文件释放到内存中,作为一个虚拟的根分区,然后执行相关脚本,运行 insmod 命令加载需要的模块。
具体的创建方法如下:

$~/linux-3.0.4$sudo mkinitramfs 3.7.10 -o /boot/initrd.img-3.7.10


10. 更新 grub


最后一步则是更新 grub 启动菜单,使用下面的命令则可以自动更新启动菜单:

$sudo update-grub2

这样会将刚才编译好的内核放在启动菜单的首位,如果需要修改启动菜单中默认系统的启动顺序,则修改/boot/grub/grub.cfg 文件中的 set default=的值即可。


内核编译完毕。