步骤:在www.kernal.org的官网上下载自己需要的内核,解压的步骤就省了吧,这个相信使用linux的人都会
1.我下载的是2.6.24的核,解压后的目录为linux-2.6.24。
cd linux-2.6.24若之前编译过内核,需要用命令
sudo make mrproper 清理一下
2.Now you can start kernel configuration by typing any one of the command:
$ make menuconfig - Text based color menus, radiolists & dialogs. This option also useful on remote server if you wanna compile kernel remotely.
$ make xconfig - X windows (Qt) based configuration tool, works best under KDE desktop
$ make gconfig - X windows (Gtk) based configuration tool, works best under Gnome Dekstop.
For example make menuconfig command launches following screen:
$ make menuconfig
You have to select different options as per your need. Each configuration option has HELP button associated with it so select help button to get help.
3.Compile kernel
Start compiling to create a compressed kernel image, enter:
$ make
Start compiling to kernel modules:
$ make modules
Install kernel modules (become a root user, use su command):
$ su -
# make modules_install
4.Install kernel
So far we have compiled kernel and installed kernel modules. It is time to install kernel itself.
# make install
It will install three files into /boot directory as well as modification to your kernel grub configuration file:
System.map-2.6.24
config-2.6.24
vmlinuz-2.6.24
5.Create an initrd image
Type the following command at a shell prompt:
# cd /boot
# mkinitramfs -o initrd.img-2.6.24 2.6.24
initrd.img-2.6.24 表示initrd images,后一个2.6.24是的位置是在/lib/modules目录下
initrd images contains device driver which needed to load rest of the operating system later on. Not all computer requires initrd, but it is safe to create one.
6. Modify Grub configuration file - /boot/grub/menu.lst
Open file using vi:
# vi /boot/grub/menu.lst
title kernel 2.6.24 Default
root (hd0,2)
kernel /boot/vmlinuz root=/dev/hdb3 ro
initrd /boot/initrd.img-2.6.24
savedefault
bootRemember to setup correct root=/dev/hdXX device. Save the file. If you think editing and writing all lines by hand is too much for you then try out update-grub command to update the lines for each kernel in /boot/grub/menu.lst file. Just type command:
# update-grub
若仅仅用命令update-grub在menu.lst不会出现initrd /boot/initrd.img-2.6.24的,若无initrd的映像文件,该内核是不会启动,会出现错误,无法启动新内核。
7.computer and boot into your new kernel
Just issue reboot command:
# reboot
[分享]内核编译完整步骤(可用,已试过)
其他Linux/Unix/BSD/OSX等发行版讨论
前往
- 公告/注意事项
- ↳ 新闻和通知
- ↳ 软件推荐
- 系统安装
- ↳ 教学和常见问答
- ↳ 系统安装和升级
- ↳ 启动和引导
- ↳ 网卡无线拨号
- ↳ 硬件与内核
- ↳ 笔记本及便携设备
- ↳ Ubuntu衍生版
- ↳ 其他类Unix OS发行版
- ↳ Debian发行版
- 配置美化
- ↳ 中文显示和输入法
- ↳ 个人配置文件存放点
- ↳ 软件文档翻译
- ↳ 窗口管理器及美化
- ↳ 桌面展示
- 软件使用
- ↳ 办公、图像、机械电子设计等
- ↳ Vim和Emacs
- ↳ 开源模板库
- ↳ 互联网相关软件
- ↳ 影音多媒体
- ↳ 游戏和模拟器
- ↳ 虚拟机和虚拟化
- ↳ Wine及其分支
- ↳ 其它类软件
- 服务器管理
- ↳ 服务器运维
- ↳ 云计算和容器(K8S/KVM/Docker/WSL等)
- ↳ Ubuntu VPS
- 程序设计与开发
- ↳ Shell脚本
- ↳ 软件/网站开发
- ↳ 内核及嵌入式开发
- ↳ Ubuntu编译和打包
- ↳ 开源小工具
- ↳ 挑战任务
- 感想与交流
- ↳ 深度PK版
- ↳ Ubuntu故事和感慨
- ↳ 同城交流
- ↳ 校园社团
- ↳ 港澳台校区
- ↳ 国外校区
- 站务区
- ↳ 论坛管理
- ↳ Ubuntu中文网上商店