首页 / 操作系统 / Linux / Linux内核编译(2.6.18内核升级到V2.6.26.4)
一、当前系统概况: 当前系统为CentOS5.2,内核版本为:2.6.18,欲升级内核到V2.6.26.4二、准备工作: 首先到http://www.eu.kernel.org/pub/linux/kernel/或http://www.kernel.org/pub/linux/kernel/下载最新的内核源代码。下载linux-2.6.26.4.tar.gz完毕后,将其解压至/usr/src/目录下,即:/usr/src/linux-2.6.26.4/。#cd /usr/src/linux-2.6.26.4 进入源代码目录。三、开始编译 依次执行如下命令: #make mrproper 配置内核选项 #make menuconfig [xconfig] #make dep 编译内核: #make bzImage 编译成功后,make会在最后输出 Kernel:arch/x86/boot/bzImage is ready(#1) 内核编译成功后,下面开始编译可加载模块: #make modules 安装可加载模块: #make modules_install 模块安装成功后,会在/lib/modules/目录下生成一个与当前内核版本号同名的目录,其安装的可加载模块就是被安装到该目录下。 安装刚才编译的内核: #make install 在此之前最好先备份一下/boot/grub/grub.conf文件 重新启动系统,在启动时选择刚才编译的内核版本号就可以了。注:如果对内核编译的make选项不太清楚,可以输入: #make help查看详细解释。下面时make help的部分内容截取Cleaning targets: clean - Remove most generated files but keep the config and enough build support to build external modules mrproper - Remove all generated files + config + various backup files distclean - mrproper + remove editor backup and patch filesConfiguration targets: config - Update current config utilising a line-oriented program menuconfig - Update current config utilising a menu based program xconfig - Update current config utilising a QT based front-end gconfig - Update current config utilising a GTK based front-end oldconfig - Update current config utilising a provided .config as base silentoldconfig - Same as oldconfig, but quietly randconfig - New config with random answer to all options defconfig - New config with default answer to all options allmodconfig - New config selecting modules when possible allyesconfig - New config where all options are accepted with yes allnoconfig - New config where all options are answered with noOther generic targets: all - Build all targets marked with [] * vmlinux - Build the bare kernel * modules - Build all modules modules_install - Install all modules to INSTALL_MOD_PATH (default: /) dir/ - Build all files in dir and below dir/file.[ois] - Build specified target only dir/file.ko - Build module including final link rpm - Build a kernel as an RPM package tags/TAGS - Generate tags file for editors cscope - Generate cscope index kernelrelease - Output the release version string kernelversion - Output the version stored in Makefile headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH (default: /src/linux-2.6.21/usr)Static analysers checkstack - Generate a list of stack hogs namespacecheck - Name space analysis on compiled kernel headers_check - Sanity check on exported headersKernel packaging: rpm-pkg - Build the kernel as an RPM package binrpm-pkg - Build an rpm package containing the compiled kernel and modules deb-pkg - Build the kernel as an deb package tar-pkg - Build the kernel as an uncompressed tarball targz-pkg - Build the kernel as a gzip compressed tarball tarbz2-pkg - Build the kernel as a bzip2 compressed tarballDocumentation targets: Linux kernel internal documentation in different formats: htmldocs - HTML installmandocs - install man pages generated by mandocs mandocs - man pages pdfdocs - PDF psdocs - Postscript xmldocs - XML DocBookArchitecture specific targets (i386): * bzImage - Compressed kernel image (arch/i386/boot/bzImage) install - Install kernel using (your) ~/bin/installkernel or (distribution) /sbin/installkernel or install to $(INSTALL_PATH) and run lilo bzdisk - Create a boot floppy in /dev/fd0 fdimage - Create a boot floppy image isoimage - Create a boot CD-ROM imagemake V=0|1 [targets] 0 => quiet build (default), 1 => verbose build make V=2 [targets] 2 => give reason for rebuild of target make O=dir [targets] Locate all output files in "dir", including .config make C=1 [targets] Check all c source with $CHECK (sparse by default) make C=2 [targets] Force check of all c source with $CHECKExecute "make" or "make all" to build all targets marked with [] For further info see the ./README file