星期一, 二月 23, 2009

编译内核的基本步骤

Linux

# cd /usr/src/linux
# make mrproper # 清除所有东西,包括配置文件
# make oldconfig # 从当前内核配置文件的基础上创建一个新的配置文件
# make menuconfig # 或者 xconfig (Qt) 或者 gconfig (GTK)
# make # 创建一个已压缩的内核映像文件
# make modules # 编译模块
# make modules_install # 安装模块
# make install # 安装内核
# reboot
FreeBSD 要改变和重建内核,需要拷贝源配置文件然后编辑它。当然也可以直接编辑GENERIC 文件。
# cd /usr/src/sys/i386/conf/ # cp GENERIC MYKERNEL # cd /usr/src # make buildkernel KERNCONF=MYKERNEL # make installkernel KERNCONF=MYKERNEL
要重建完全的操作系统:
# make buildworld # 构建完全的系统,但不是内核 # make buildkernel # 使用 KERNCONF 配置文件编译内核 # make installkernel # reboot # mergemaster -p # 建立临时根环境并比对系统配置文件 # make installworld # mergemaster # 升级所有配置和其他文件 # reboot
对于源的一些小改动,有时候简单的命令就足够了:
# make kernel world # 编译并安装内核和系统 # mergemaster # reboot

0 评论: