linux kernel编译安装笔记

os: centos-5.2
kernel: linux-2.6.27.7.tar.bz2

需要预先安装module-init-tools 和 ncurses-devel
cp linux-2.6.27.7.tar.bz2 /usr/src/kernels/
cd /usr/src/kernels
tar -jxvf linux-2.6.27.7.tar.bz2
cd linux-2.6.27.7

1. 设置核心内容和模块
make menconfig

主要配置选项有:
1.1 General Setup (常规设置)
[ ] Prompt for development and/or incomplete code/drivers
[*] Support for paging of anonymous memory (swap)
[*] System V IPC

1.2 Enable loadable module support (可加载模块支持)

1.3 Enable the block layer (块设备层支持)
[*]Support for Large Block Devices

1.4 Processor type and features (处理器类型和特征)
Symmetric multi-processing support (多处理器支持)
Subarchitecture Type (处理器架构)
Processor family (处理器类型)
High Memory Support (支持的最大内存)
MTRR (Memory Type Range Register) support (提升PCI/AGP总线上显卡的速度)

1.5 Power management options (电源管理选项)

1.6 Bus options (PCI etc.) (PCI,PCMCIA,EISA,MCA,ISA总线选项)
PCI access mode (PCI访问模式,选'Any')
PCI Express support
ISA support
PCCARD (PCMCIA/CardBus) support (PCMCIA卡支持)
Support for PCI Hotplug (PCI热插拔支持)

1.7 Executable file formats / Emulations (可执行文件格式)
Kernel support for ELF binaries (ELF是开放平台下最常用的二进制文件格式,支持动态连接,支持不同的硬件平台,必选)
Kernel support for MISC binaries (允许插入二进制的封装层到内核中,使用Java,.NET,Python,Lisp等语言编写的程序时需要它)

1.8 Networking support (网络)
TCP/IP networking
IP: policy routing (策略路由)
IP: TCP syncookie support (抵抗SYN flood攻击)
IP: Virtual Server Configuration (IP虚拟服务器,做集群服务器用)
The IPv6 protocol
Network packet filtering framework (Netfilter) (数据包过滤防火墙)
IrDA (infrared) subsystem support (红外线支持)
Bluetooth subsystem support (蓝牙支持)
wireless (无线网络支持)

1.9 Device Drivers (设备驱动程序)
Generic Driver Options (驱动程序通用选项)
Connector - unified userspace <-> kernelspace linker (统一的用户空间和内核空间连接器,可以不选)
Memory Technology Devices (MTD) support (特殊的存储装置,比如数码相机存储卡等)
Parallel port support (并口支持)
Plug and Play support (即插即用支持)
Block devices (块设备,软驱、阵列卡等)
Misc devices (杂项设备)
ATA/ATAPI/MFM/RLL support (通常是IDE硬盘和ATAPI光驱)
SCSI device support (SCSI设备

,包括软RAID、SCSI硬盘,磁带,仿真设备等)
Serial ATA and Parallel ATA drivers (SATA与PATA设备)
Multi-device support (RAID and LVM) (多设备支持(RAID和LVM))
IEEE 1394 (FireWire) support (IEEE 1394(火线))
Network device support -->
Ethernet (10 or 100Mbit)
Ethernet (1000 Mbit)
Ethernet (10000 Mbit)
Wireless LAN
PPP (point-to-point protocol) support (点对点协议,用于ADSL)
Fibre Channel driver support (光纤通道)
ISDN support (综合数字业务网)
Telephony Support (VoIP支持)
Input device support (输入设备,包括鼠标、键盘、游戏杆等)
Character devices (字符设备,包括虚拟终端、串口、并口等设备)
I2C support (用于监控电压/风扇转速/温度等)
SPI support (串行外围接口,MMC和SD卡通常需要)
Hardware Monitoring support (该功能需要I2C的支持)
Multimedia devices (多媒体设备)
Graphics support (图形设备/显卡支持)
Sound card support (声卡)
USB support
MMC/SD Card support (MMC/SD卡支持)
LED support (发光二级管(LED)设备)
InfiniBand support (通用的高性能I/O规范,用于Linux服务器集群系统)
DMA Engine support (从Intel Bensley双核服务器平台开始引入的数据移动加速引擎)

1.10 Fireware Drivers (BIOS,ISCSI等固件驱动)

1.11 File systems (文件系统)
Ext2
Ext3
Reiserfs support
JFS filesystem support (IBM的JFS文件系统)
XFS filesystem support
OCFS2 file system support (一种用于集群的文件系统)
Dnotify support (旧式的基于目录的文件变化的通知机制)
Inotify file change notification support (基于目录的文件变化通知的新机制)
Quota support (磁盘配额支持)
Kernel automounter support (内核自动加载远程文件系统)
Kernel automounter version 4 support (also supports v3)
Filesystem in Userspace support (FUSE允许在用户空间实现一个文件系统)
CD-ROM/DVD Filesystems (包括ISO9660、UDF文件系统)
DOS/FAT/NT Filesystems (包括DOS、VFAT、NTFS文件系统)
Pseudo filesystems (伪文件系统)
Miscellaneous filesystems (非主流的杂项文件系统)
Network File Systems --> (网络文件系统)
NFS
SMB
CIFS
Partition Types (高级磁盘分区类型,不确定可以全不选)
Native Language Support --> (本地语言支持)
(utf8) Default NLS Option (默认本地语言,建议使用UTF8)
<*> Simplified Chinese Charset (CP936,GB2312) (简体中文)
Distributed

Lock Manager (DLM) (通用的分布式锁管理器,不选)

1.12 Kernel hacking (内核hack选项)

1.13 Security options (安全选项)

1.14 Cryptographic API (加密选项)
Cryptographic API (提供核心的加密API支持)

Cryptographic algorithm manager (创建加密模版实例,必选)
Null algorithms (用于IPsec协议的封装安全载荷模块(ESP))
MD5 digest algorithm (主流摘要算法,128位)
SHA1 digest algorithm (主流摘要算法,160位)
Whirlpool digest algorithms (最安全的摘要算法,512位,已被列入ISO标准)
Tiger digest algorithms (号称最快的摘要算法,192位,专门为64位CPU进行了优化)
ECB support (电子密码本,

最简单的加密方法)
CBC support (密码块链,IPSec需要使用它)
CRC32c CRC algorithm (摘要算法,可用于校验iSCSI设备传输的数据)
HMAC support (为IPSec所必须,可为PPPoE提供压缩支持)
Hardware crypto devices (仅有VIA C7系列处理器支持硬件加密)

1.15 Vitualization (虚拟化支持)
Kernel-based Vitual Machine (KVM) support

1.16 Library routines (库子程序)
CRC-CCITT functions (传送8-bit字符,欧洲标准)
CRC16 functions (传送8-bit字符,美国标准)
CRC32 functions (用于点对点的同步数据传输中,传输网络数据包所必须的)
CRC32c (Castagnoli, et al) Cyclic Redundancy-Check (用于点对点的同步数据传输中,比如iSCSI设备)

1.17 Load an Alternate Configuration File (载入一个配置文件)
1.18 Save an Alternate Configuration File (保存配置文件)


参考资料:
金步国《Linux 2.6.19.x 内核编译配置选项简介》
https://www.360docs.net/doc/c35709532.html,/Linux/kernel_options.html

2. 核心的编译与安装

make clean # 清楚旧版的*.o文件
make bzImage # 制作核心文件
make modules # 制作相关模块
make modules_install # 安装模块到/lib/modules/`uname -r` 目录
make install # 安装核心文件到目录/boot

4. 编辑/etc/grub.conf文件
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.27.7)
root (hd0,0)
kernel /boot/vmlinuz-2.6.27.7 ro root=LABEL=/
initrd /boot/initrd-2.6.27.7.img



5. 额外模块的编译安装
以Intel 3945 无线网卡的安装为例
tar -zxvf ipw3945-1.2.2.gz
cd ipw3945-1.2.2
make
将编译出来的模块文件 ipw3945.ko 移到核心目录,并更新模块依赖属性:
cp ipw3945.ko /lib/modules/`uname -r`/kernel/drivers/net
cd /lib/modules/`uname -r`
depmod -a

开机自动加载模块:
cd /etc/sysconfig/modules
echo "modprob

e ipw3945" >>my.modules
chmod 755 my.modules
重启后查看模块是否加载:
lsmod |grep ipw3945

ps: 每次更新kernel后需要重新编译一次额外添加的模块

6. 核心模块管理

lsmod 列出所有模块
modinfo 查看模块信息
modprobe -c 查看配置文件
-l 列出所有模块
-r 移除模块
insmod 插入模块
rmmod 删除模块
-----------------------------------------------------------------

7. 补充内容:为kernel打补丁

本节内容来源于https://www.360docs.net/doc/c35709532.html,/u/26641/showart_221583.html


简单论述了如何在RHEL AS4下为Kernel打补丁。
RHEL AS4下,KERNEL版本是2.6.9-5.EL,升级到2.6.19.1 。
做法是:

7.1.准备好2.6.9-5.EL版本的内核文件linux-2.6.9.tar.bz2先到https://www.360docs.net/doc/c35709532.html,/pub/redhat/linux/enterprise/4/en/os/i386/SRPMS/

处下载kernel-2.6.9-5.EL.src.i386.rpm,因为没有在RHEL光盘上找到.

7.2.将上述RPM安装到/usr/src/redhat/SOURCES/下

[root@server SOURCES]# rpm -ivh kernel-2.6.9-5.EL.src.rpm

7.3.下载2.6.19.1版本的补丁patch-2.6.19.1.bz2与数字签名文件 https://www.360docs.net/doc/c35709532.html,/pub/linux/kernel/v2.6/patch-2.6.19.1.bz2

https://www.360docs.net/doc/c35709532.html,/pub/linux/kernel/v2.6/patch-2.6.19.1.bz2.sign

7.3.打补丁

#tar xvjf linux-2.6.9.tar.bz2 将linux-2.6.9.tar.bz2解压缩

#bzcat patch-2.6.19.1.bz2|patch -p0

#mv linux-2.6.9 linux-2.6.19

7.4.编译内核替换旧内核

#cd linux-2.6.19;make menuconfig

# make dep bzImage modules modules_install install


相关文档
最新文档