您的位置:首页 > 运维架构 > Linux

编译并加载linux-3.13.8的过程

2016-03-31 08:24 471 查看
准备工作:

主机:ubuntu 14.04

说明:在ubuntu系统中可以使用apt代替apt-get使用



downloads linux-3.13.8.tar

sudo cp linux-3.13.8.tar /usr/src

tar xvf linux-3.13.8

cd linux-3.13.8

make mrproper 将残留的.o等文件清空
将原系统/boot/config-*-generic 拷贝到/linux-3.13.8(自己配置则跳过该步)

make menuconfig->load->config-*



/*

 *如果第一次使用make menuconfig出现了上边错误
*Unablle to find the ncurses libraries or the requiresheader files

 *则输入命令:sudo apt install libncurses5-dev

*/

exit->save (重命名为.config)



ls -a 可以看到存在了.config文件(系统版本和编译的版本差异不宜过大,以免产生不兼容)

=========================================================================
开始编译

make > /dev/null(可以使用j参数设置多核加速编译)
/*将编译链接信息定向到/dev/null,仅在终端打印警告或者错误信息*/

编译成功,在arch/x86_64(自己编译的目录)下生成了一个bzImage文件,另外在根目录下生成了一组文件



====================================================================================
安装模块

开始安装模块make modules_install(省去了以上三个步骤)
成功后在/lib/modules/下会产生一个模块



在/boot目录下会产生三个文件



=====================================================================================
使用grub引导系统进入新内核

添加启动项:

/etc/default/grub中的配置决定了grub.cfg
/etc/default/grub参数如下:



修改上述参数
GRUB_DEFAULT=0//该参数决定了启动的时候默认的内核启动项

GRUB_HIDDEN_TIMEOUT=10//修改系统启动过程等待的时间

修改后执行update-grub,若出现warning,则是因为参数修改时的问题
/*******************************************************************************

*Wait this many seconds before displaying the menu. If<ESC> is                *

 *   pressed during that time, displaythe menu and wait for input                  *

 *    according to `GRUB_TIMEOUT'. If ahotkey associated with a menu     *

 *   entry is pressed, boot theassociated menu entry immediately. If             *

 *    the timeout expires before either ofthese happens, display the              *

 *   menu for the number of secondsspecified in `GRUB_TIMEOUT' before*

 *    booting the default entry.                                                                                 *

 *    If you set `GRUB_HIDDEN_TIMEOUT',you should also set                     *

 *   `GRUB_TIMEOUT=0' so that the menu isnot displayed at all unless      *

 *    <ESC> is pressed.                                                                                            *

 *    This option is unset by default, andis deprecated in favour of                 *

 *   the less confusing`GRUB_TIMEOUT_STYLE=countdown' or                  *

 *    `GRUB_TIMEOUT_STYLE=hidden'.                                                             *

********************************************************************************/

根据上边的说明知道,必须先将GRUB_TIMEOUT的默认值改成0,然后才能将

GRUB_HIDDEN_TIMEOUT值修改成10,并且执行update-grup不产生警告.

update-grub



打开grub.cfg,可以看到linux-3.13.8模块已经添加

重新启动 ESC进入启动(虚拟机按shift),第二个ubuntu advance可以选择进入编译好的内核
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: