清除临时文件、中间文件和配置文件命令:
make clean //remove most generated files but keep the config
make mrproper //remove all generated files + config files
make distclean //mrproper + remove editor backup and patch files
配置内核命令:
make config:基于文本模式的交互式配置。
make menuconfig ARCH=i386:基于文本模式的菜单型配置。//“*”编译成内核(按y)(生成镜像),“m”编译成模块(按m)(生成点o文件),“ ”为不编译(按n)
配置完成之后会在当前文件夹下生成.config文件。
Linux内核提供了一系列可供参考的内核配置文件,位于./arch/$cpu/configs。
编译内核:
make zImage//获取详细信息make zImage V=1
make bzImage//获取详细信息make bzImage V=1
区别:在X86平台,zImage只能用于小于512K的内核
编译好的内核文件位于./arch/$cpu/boot/(文件名为bzImage)。
编译内核模块:
make modules
安装内核模块:
make modules_install
将编译好的内核模块从内核源代码目录copy至/lib/modules下,文件夹名为该内核版本号如2.6.29。
制作init ramdisk:
即将/lib/modules下的内核文件夹生成init ramdisk文件。
mkinitrd initrd-$version $version //例mkinitrd initrd-2.6.29 2.6.29
内核安装:
将bzImage文件和init ramdisk文件都复制到/boot/ 下。
如上文中的initrd-2.6.29,以及编译好的内核文件bzImage如重命名为vmlinuz-2.6.29。
并且修改/etc/grub.conf 或者 /etc/lilo.conf。
如:
default=1
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-53.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-53.el5 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.18-53.el5.img
title newlinux
root (hd0,0)
kernel /vmlinuz-2.6.29 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.29
关于make distclean会删除哪些文件:
# make distclean
CLEAN arch/x86/boot/compressed
CLEAN arch/x86/boot
CLEAN /home/zbf/kernel/linux-2.6.30
CLEAN arch/x86/kernel/acpi/realmode
CLEAN arch/x86/kernel/cpu
CLEAN arch/x86/kernel
CLEAN arch/x86/vdso
CLEAN drivers/char
CLEAN drivers/md
CLEAN drivers/scsi/aic7xxx
CLEAN drivers/video/logo
CLEAN firmware
CLEAN init
CLEAN kernel
CLEAN lib
CLEAN usr
CLEAN .tmp_versions
CLEAN vmlinux System.map .tmp_kallsyms1.o .tmp_kallsyms1.S .tmp_kallsyms2.o .tmp_kallsyms2.S .tmp_kallsyms3.o .tmp_kallsyms3.S .tmp_vmlinux1 .tmp_vmlinu[root@localhost linux-2.6.30]# make distclean
CLEAN arch/x86/boot/compressed
CLEAN arch/x86/boot
CLEAN /home/zbf/kernel/linux-2.6.30
CLEAN arch/x86/kernel/acpi/realmode
CLEAN arch/x86/kernel/cpu
CLEAN arch/x86/kernel
CLEAN arch/x86/vdso
CLEAN drivers/char
CLEAN drivers/md
CLEAN drivers/scsi/aic7xxx
CLEAN drivers/video/logo
CLEAN firmware
CLEAN init
CLEAN kernel
CLEAN lib
CLEAN usr
CLEAN .tmp_versions
CLEAN vmlinux System.map .tmp_kallsyms1.o .tmp_kallsyms1.S .tmp_kallsyms2.o .tmp_kallsyms2.S .tmp_kallsyms3.o .tmp_kallsyms3.S .tmp_vmlinux1 .tmp_vmlinux2 .tmp_vmlinux3 .tmp_System.map
CLEAN scripts/basic
CLEAN scripts/genksyms
CLEAN scripts/kconfig
CLEAN scripts/mod
CLEAN scripts/selinux/mdp
CLEAN scripts
CLEAN include/config
CLEAN .config include/asm .version include/linux/autoconf.h include/linux/version.h include/linux/utsrelease.h include/linux/bounds.h include/asm/asm-offsets.h include/asm-x86/asm-offsets.h Module.symvers
x2 .tmp_vmlinux3 .tmp_System.map
CLEAN scripts/basic
CLEAN scripts/genksyms
CLEAN scripts/kconfig
CLEAN scripts/mod
CLEAN scripts/selinux/mdp
CLEAN scripts
CLEAN include/config
CLEAN .config include/asm .version include/linux/autoconf.h include/linux/version.h include/linux/utsrelease.h include/linux/bounds.h include/asm/asm-offsets.h include/asm-x86/asm-offsets.h Module.symvers