一、下载解压并打上内核补丁
内核源代码:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.38.tar.bz2
最新内核补丁:http://www.kernel.org/pub/linux/kernel/v2.6/snapshots/patch-2.6.38.bz2
cd /usr/src
rm -rf linux
tar jxf /download/linux-2.6.10.tar.bz2
ln -s linux-2.6.10 linux
cd linux
bunzip2 -dv /download/patch-2.6.10-bk4.bz2 |patch -p1
如果在/usr/src目录下就用patch -p0
二、修改内核源代码 (升级2.6就是为了优化,干脆连源代码也改了吧)
1.修改/usr/src/linux/include/linux/posix_types.h
设置fd_set支持的最大数量
#define __FD_SETSIZE 1024 --->; 65536
2.修改/usr/src/linux/include/linux/fs.h
设置最大打开文件数量(TCP连接数量)
#define INR_OPEN 1024 --->; 65536
#define NR_FILE 8192 --->; 65536
#define NR_RESERVED_FILES 10 --->; 128
3.修改/usr/src/linux/include/net/tcp.h
设置TIMEOUT的时间为1秒
#define TCP_TIMEWAIT_LEN (60*HZ) 60 --->; 1*HZ
设置在backlog队列里的半连接的重试次数,每次都会花相应的时间,本质上 也是减少重试时间
#define TCP_SYNACK_RETRIES 5 --->; 3
三、安装必要的工具
1.下载module-init-tools-3.1.tar.bz2
http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.1.tar.bz2
./configure --prefix=/
make moveold
make all install
./generate-modprobe.conf /etc/modprobe.conf
2.下载新的mkinitrd
ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/mkinitrd-4.1.18-2.i386.rpm
它需要lvm2 device-mapper
ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/device-mapper-1.00.19-2.i386.rpm
ftp://195.220.108.108/linux/6/fedora/core/3/i386/os/Fedora/RPMS/lvm2-2.00.25-1.01.i386.rpm 安装lvm2-2.00.25-1.01.i386.rpm时请用rpm -ivh --nodeps package name
四、make menuconfig
01.Code maturity level options --->;
[*] Prompt for development and/or incomplete code/drivers
[*] Select only drivers expected to compile cleanly
02.General setup --->;
[*] Support for paging of anonymous memory (swap)
[*] System V IPC
[*] POSIX Message Queues
[ ] BSD Process Accounting
[*] Sysctl support
[ ] Auditing support
[ ] Support for hot-pluggable devices
[*] Kernel Userspace Events
[ ] Kernel .config support
[*] Configure standard kernel features (for small systems) --->;
[*] Load all symbols for debugging/kksymoops
[ ] Do an extra kallsyms pass
[*] Enable futex support
[*] Enable eventpoll support
[ ] Optimize for size
[*] Use full shmem filesystem
03.Loadable module support --->;
[*] Enable loadable module support
[*] Module unloading
[ ] Forced module unloading
[ ] Module versioning support (EXPERIMENTAL)
[ ] Source checksum for all modules
[*] Automatic kernel module loading
04.Processor type and features --->;
Subarchitecture Type (PC-compatible) --->;
Processor family (Pentium-4/Celeron(P4-based)/Pentium-4 M/Xeon) --->;
[*] Generic x86 support
[ ] HPET Timer Support
[*] Symmetric multi-processing support 多CPU
(8) Maximum number of CPUs (2-255)
[*] SMT (Hyperthreading) scheduler support
[*] Preemptible Kernel 抢占式内核,请选上它
[ ] Machine Check Exception
< >; Toshiba Laptop support
< >; Dell laptop support
< >; /dev/cpu/microcode - Intel IA32 CPU microcode support
< >; /dev/cpu/*/msr - Model-specific register support
< >; /dev/cpu/*/cpuid - CPU information support
Firmware Drivers --->;
High Memory Support (4GB) --->; 高内存
[ ] Allocate 3rd-level pagetables from highmem
[ ] Math emulation
[*] MTRR (Memory Type Range Register) support
[*] Enable kernel irq balancing
[ ] Use register arguments (EXPERIMENTAL)
05.Power management options (ACPI, APM) --->; 电源管理 自定 (偶没选)
06.Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->; 板卡支持 自定
[*] PCI support
PCI access mode (Any) --->;
[ ] Message Signaled Interrupts (MSI and MSI-X)
[*] Legacy /proc/pci interface
[*] PCI device name database
[ ] ISA support
[ ] MCA support
< >; NatSemi SCx200 support
07.Executable file formats --->;
[*] Kernel support for ELF binaries
; Kernel support for a.out and ECOFF binaries
; Kernel support for MISC binaries
08.Device Drivers --->; 设备驱动及网络支持
Generic Driver Options --->; 默认
[*] Select only drivers that don't need compile-time external firmware
[*] Prevent firmware from being built
Memory Technology Devices (MTD) --->; 不选
Parallel port support --->; 并行端口 自定(偶没选)
Plug and Play support --->; 支持热插拔 自定(偶没选)
Block devices --->;
<*>; Normal floppy disk support
< >; Compaq SMART2 support
< >; Compaq Smart Array 5xxx support
< >; Mylex DAC960/DAC1100 PCI RAID Controller support
< >; Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)
; Loopback device support
< >; Cryptoloop Support
; Network block device support
< >; Promise SATA SX8 support
; RAM disk support
(16) Default number of RAM disks
(4096) Default RAM disk size (kbytes)
() Source directory of cpio_list
[ ] Support for Large Block Devices
< >; Packet writing on CD/DVD media
IO Schedulers --->; IO调度器,都选上吧 可以在grub.conf指定用IO调度哪种方式,后面会讲的
<*>; Anticipatory I/O scheduler
<*>; Deadline I/O scheduler
<*>; CFQ I/O scheduler
ATA/ATAPI/MFM/RLL support --->; ATA设备 自定 (偶没选)
SCSI device support --->; SCSI设备 自定我有scsi的设备所以有以下选项
<*>; SCSI device support
[*] legacy /proc/scsi/ support
--- SCSI support type (disk, tape, CD-ROM)
<*>; SCSI disk support
因为偶式MPT的SCSI,所以以下都没选,省略之
Multi-device support (RAID and LVM) --->; 支持RAID和LVM(逻辑卷) 自定
[*] Multiple devices driver support (RAID and LVM)
<*>; RAID support
< >; Linear (append) mode
<*>; RAID-0 (striping) mode
< >; RAID-1 (mirroring) mode
< >; RAID-10 (mirrored striping) mode (EXPERIMENTAL)
<*>; RAID-4/RAID-5 mode
< >; RAID-6 mode (EXPERIMENTAL)
<*>; Multipath I/O support
< >; Faulty test module for MD
<*>; Device mapper support
< >; Crypt target support
< >; Snapshot target (EXPERIMENTAL)
< >; Mirror target (EXPERIMENTAL)
< >; Zero target (EXPERIMENTAL)
Fusion MPT device support --->; 偶的SCSI是这个,所以选了 还是自定
<*>; Fusion MPT (base + ScsiHost) drivers
(40) Maximum number of scatter gather entries
<*>; Fusion MPT misc device (ioctl) driver
IEEE 1394 (FireWire) support --->; 自定 (偶没选)
I2O device support --->; 自定 (偶没选)
Networking support --->; 网络选项
[*] Networking support
Networking options --->;
<*>; Packet socket
[ ] Packet socket: mmapped IO
< >; Netlink device emulation
<*>; Unix domain sockets 如果你有网络就选
< >; PF_KEY sockets
[*] TCP/IP networking
[ ] IP: multicasting
[ ] IP: advanced router
[ ] IP: kernel level autoconfiguration
< >; IP: tunneling
< >; IP: GRE tunnels over IP
[ ] IP: ARP daemon support (EXPERIMENTAL)
[*] IP: TCP syncookie support (disabled per default) 能防DOS***,但会降低一点性能,总的说性价比不错
< >; IP: AH transformation
< >; IP: ESP transformation
< >; IP: IPComp transformation
< >; IP: tunnel transformation
<*>; IP: TCP socket monitoring interface
IP: Virtual Server Configuration --->; lvs 支持
< >; The IPv6 protocol (EXPERIMENTAL)
[*] Network packet filtering (replaces ipchains) --->; 包过滤省略(知道的自己选,不熟悉的都选上)
以下都没选,省略
[ ] Amateur Radio support --->;
< >; IrDA (infrared) subsystem support --->;
< >; Bluetooth subsystem support --->;
[*] Network device support
< >; Dummy net driver support 这个是nis服务器的吧,不大清楚,没用过
<*>; Bonding driver support 双网卡绑定的
< >; EQL (serial line load balancing) support
< >; Universal TUN/TAP device driver support
ARCnet devices --->;
Ethernet (10 or 100Mbit) --->;
Ethernet (1000 Mbit) --->;
< >; Alteon AceNIC/3Com 3C985/NetGear GA620 Gigabit support
< >; D-Link DL2000-based Gigabit Ethernet support
< >; Intel(R) PRO/1000 Gigabit Ethernet support
< >; National Semiconduct DP83820 support
< >; Packet Engines Hamachi GNIC-II support
< >; Packet Engines Yellowfin Gigabit-NIC support (EXPERIMENTAL)
< >; Realtek 8169 gigabit ethernet support
< >; Marvell Yukon Chipset / SysKonnect SK-98xx Support
<*>; Broadcom Tigon3 support
以下都没选,省略
ISDN subsystem --->;
Telephony Support --->;
Input device support --->;
Character devices --->;
I2C support --->;
Dallas's 1-wire bus --->;
Misc devices --->;
Multimedia devices --->;
Graphics support --->;
Sound --->;
USB support --->;
MMC/SD Card support --->; 以上都没选,需要的自己选
09.File systems --->; 文件系统
< >; Second extended fs support
<*>; Ext3 journalling file system support
[ ] Ext3 extended attributes
[*] JBD (ext3) debugging support
< >; Reiserfs support
< >; JFS filesystem support
< >; XFS filesystem support
< >; Minix fs support
< >; ROM file system support
[ ] Quota support
< >; Kernel automounter support
<*>; Kernel automounter version 4 support (also supports v3)
CD-ROM/DVD Filesystems --->;
<*>; ISO 9660 CDROM file system support
[ ] Microsoft Joliet CDROM extensions
[ ] Transparent decompression extension
< >; UDF file system support
DOS/FAT/NT Filesystems --->; floppy要用到的文件格式
<*>; MSDOS fs support
<*>; VFAT (Windows-95) fs support
(437) Default codepage for FAT (NEW)
(iso8859-1) Default iocharset for FAT (NEW)
< >; NTFS file system support
Pseudo filesystems --->;
[*] /proc file system support proc文件系统支持
[ ] /proc/kcore support
[ ] /dev file system support (OBSOLETE)
[ ] /dev/pts Extended Attributes
[*] Virtual memory file system support (former shm fs) 虚拟内存支持
[ ] tmpfs Extended Attributes
[ ] HugeTLB file system support
Miscellaneous filesystems --->;
Network File Systems --->;
<*>; NFS file system support nfs客户端支持
[*] Provide NFSv3 client support
[ ] Provide NFSv4 client support (EXPERIMENTAL)
[ ] Allow direct I/O on NFS files (EXPERIMENTAL)
< >; NFS server support nfs服务端支持
< >; Secure RPC: Kerberos V mechanism (EXPERIMENTAL)
< >; Secure RPC: SPKM3 mechanism (EXPERIMENTAL)
< >; SMB file system support (to mount Windows shares etc.) samba支持
< >; CIFS support (advanced network filesystem for Samba, Window and other CIFS compliant servers)
< >; NCP file system support (to mount NetWare volumes)
< >; Coda file system support (advanced network fs)
< >; Andrew File System support (AFS) (Experimental)
Partition Types --->;
Native Language Support --->; 自己选
10.Profiling support --->; 没选
11.Kernel hacking --->; 没选
12.Security options --->; 没选
13.Cryptographic options --->; 没选
14.Library routines --->;
< >; CRC-CCITT functions
<*>; CRC32 functions
; CRC32c (Castagnoli, et al) Cyclic Redundancy-Check
五、编译安装
步骤:make -jn(n代表同时编译的进程,可以加快编译速度,n由你的配置决定,我的配置用15-25)
make modules_install
make install
六、grub的设置
下面说说怎么设置:参数的格式为elevator=调度器名
修改/boot/grub/grub.conf,在kernel那行后门加入elevator=deadline
例如:kernel /boot/vmlinuz-2.6.10-bk4 ro root=/dev/你的根分区 elevator=deadline
七、reboot