Kernel: 编译、安装内核详细过程
本文已过期!请查看更新版本:Kernel:编译、安装内核详解教程
清理
$ make distclean CLEAN scripts/basic CLEAN scripts/kconfig CLEAN include/config include/generated
复制配置文件(自己配置可以省略此步骤)
$ cp /boot/config-$current_version-general ./.config
生成配置文件
$ make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/docproc HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o *** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: *** [menuconfig] Error 2
Aho! 遇到错误,我们缺少 ncurses-dev这个包:
$ sudo apt-get update $ sudo apt-get install ncurses-dev
再来一次:
$ make menuconfig HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o HOSTCC scripts/kconfig/lxdialog/checklist.o HOSTCC scripts/kconfig/lxdialog/inputbox.o HOSTCC scripts/kconfig/lxdialog/menubox.o HOSTCC scripts/kconfig/lxdialog/textbox.o HOSTCC scripts/kconfig/lxdialog/util.o HOSTCC scripts/kconfig/lxdialog/yesno.o HOSTCC scripts/kconfig/mconf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/lex.zconf.c SHIPPED scripts/kconfig/zconf.hash.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/mconf scripts/kconfig/mconf Kconfig # # using defaults found in /boot/config-2.6.32-28-generic # /boot/config-2.6.32-28-generic:557:warning: symbol value 'm' invalid for PCCARD_NONSTATIC /boot/config-2.6.32-28-generic:3033:warning: symbol value 'm' invalid for MFD_WM831X /boot/config-2.6.32-28-generic:3034:warning: symbol value 'm' invalid for MFD_WM8350 /boot/config-2.6.32-28-generic:3035:warning: symbol value 'm' invalid for MFD_WM8350_I2C /boot/config-2.6.32-28-generic:3040:warning: symbol value 'm' invalid for AB3100_CORE /boot/config-2.6.32-28-generic:3510:warning: symbol value 'm' invalid for FB_VESA /boot/config-2.6.32-28-generic:4179:warning: symbol value 'm' invalid for MMC_RICOH_MMC /boot/config-2.6.32-28-generic:4203:warning: symbol value 'm' invalid for LEDS_CLASS /boot/config-2.6.32-28-generic:4480:warning: symbol value 'm' invalid for RAR_REGISTER
$ make bzImage [V=1] ... # 这里要很长时间,中间编译的过程略去了 Root device is (8, 8) Setup is 14620 bytes (padded to 14848 bytes). System is 4090 kB CRC 2705ad73 Kernel: arch/x86/boot/bzImage is ready (#1) #告诉你编译后的内核镜像在哪里
编译、安装模块
$ make modules ... # 这里要很长时间,中间编译的过程略去了 $ sudo make modules_install # 将模块相关的文件复制到/lib/modules/目录下的$version目录
生成ramdisk
$ mkinitrd initrd-$version $version
注释:$version 一定要是/lib/modules/下存在的目录名
如果机器上没有mkinitrd
这条命令,你试试mkinitramfs
:
$ mkinitramfs -o initrd-2.6.37.2
安装内核
$ sudo cp arch/x86/boot/bzImage /boot/vmlinuz-2.6.37.2 $ sudo cp initrd-2.6.37.2 /boot/ $ sudo update-grub Generating grub.cfg ... Found linux image: /boot/vmlinuz-2.6.37.2 Found initrd image: /boot/initrd-2.6.37.2 done
好啦,安装完毕,重启试试看新内核吧!!
原创文章,转载请遵守许可条款
版权声明
本文出自 Lesca 技术宅,转载时请注明出处及相应链接。
本文永久链接: https://www.lesca.cn/archives/kernel-complie-and-install-process.html
郁闷
2011-02-28 at 23:59
我的编译为什么会出错呢? 找不到模块说?
lesca
2011-03-01 at 14:52
你是执行哪一步的时候出错的?编译安装、模块那里嘛?
安装模块前必须先编译
make modules
,否则就会找不到模块了。