Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1909136
  • 博文数量: 383
  • 博客积分: 10011
  • 博客等级: 上将
  • 技术积分: 4061
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-24 18:53
文章分类

全部博文(383)

文章存档

2011年(1)

2010年(9)

2009年(276)

2008年(97)

我的朋友

分类: LINUX

2009-01-14 14:38:43

编译之前
  注意看套件解压缩之后的 INSTALL 或 README 档案!
  由于害怕不小心前面有人已经先编译过了核心,则由于编译过程当中会产生目的档案(档名为 .o ),为了避免此一问题,请先执行 make mrproper 这个指令:
设定编译模式:
  目前的 Kernel 可以允许多种编译的模式,包括了:
   make config :这种模式需要逐行输入所需要设定的项目,无法往前修改设定,所以目前很少使用这种方式来设定 Kernel 的项目了;
   make xconfig :这种模式则是使用 X-Window 为主要环境的设定模式!除非你有 X-Window 在执行,否则没有办法使用这种模式;
   make menuconfig :这种模式有点像是文字界面的选单模式,较为简便,而且可以在纯文字界面下面执行编辑动作!是目前最常使用的模式。
开始设定:
 [root @test linux]# make mrproper   <==去除 .o 的编译过的档案
 [root @test linux]# make menuconfig  <==以文字选单的模式进行编译!
 Code maturity level options  --->                  <==关于核心测试功能的 code 开启项目;
         [ ] Prompt for development and/or incomplete code/drivers  <==因为我们没有要研发核心,所以不选
 Loadable module support  --->                    <==这个就是我们之前说的『模块』啦!
     [*] Enable loadable module support              <==让核心可以加载模块项目(必选)
         [ ]   Set version information on all module symbols      <==这个除非你要使用旧版本的数据,通常不选!
     [*]   Kernel module loader                 <==也是必选啦!
 Processor type and features  --->                  <==选择 CPU 的型号项目
         (Pentium-MMX) Processor family               <==请依照您的实际情况选择您的 CPU 型号
         < > Toshiba Laptop support                  <==底下这两个有使用到(笔记型计算机)才选择!
         < > Dell laptop support
         /dev/cpu/microcode - Intel IA32 CPU microcode support  <==如果是使用 Intel 的,可以编译成模块
         /dev/cpu/*/msr - Model-specific register support    <==如果是使用 Intel 的,可以编译成模块
         /dev/cpu/*/cpuid - CPU information support       <==如果是使用 Intel 的,可以编译成模块
         (off) High Memory Support                  <==这个东西跟你的 RAM 有关系,RAM小于 1 GB 则使用 off 即可
         [ ] Math emulation                      <==是否需要数值模拟?当然不需要!我们的 CPU 都够强了!
         [ ] MTRR (Memory Type Range Register) support         <==P6 (PII等级以上) 并且要跑 X-Window 才加上吧,与 AGP 有关
     [ ] Symmetric multi-processing support            <==如果是双 CPU 的主机板才选择!否则就不要选了!
         [*] Local APIC support on uniprocessors (NEW)         <==如果你的 CPU 有支持 APIC 则选择!通常可以选择起来啦!
         [*] IO-APIC support on uniprocessors             <==跟上面的理由一致!选择起来吧!
 General setup  --->                         <==一般设定部分
     [*] Networking support                 <==底下四个一定要选,跟基本的硬件装置有关!
     [*] PCI support
         (Any)   PCI access mode
     [*] PCI device name database
         [ ] EISA support                   <==底下这两个则与主机板上面的插槽有关!除非笔记型,否则不选
         [ ] MCA support
         [*] Support for hot-pluggable devices         <==有点类似随插即用吧!可以选择呦!
         PCMCIA/CardBus support  --->
                 < > PCMCIA/CardBus support          <==因为我没有笔记型,所以不选,若为笔记型计算机,请选择!
         PCI Hotplug Support  --->
         [*] System V IPC                   <==底下这三个东西对于效能都不错!可以选择呦!
         [*] BSD Process Accounting
         [*] Sysctl support
         (ELF) Kernel core (/proc/kcore) format        <==底下这几个东西可以编译成模块啦!但是我直接编到核心啰!
         <*> Kernel support for a.out binaries
         <*> Kernel support for ELF binaries
         <*> Kernel support for MISC binari
         [*] Power Management support
         < >   Advanced Power Management BIOS support     <==如果你想要你的 BIOS 接管电源管理,可以选择!我是不选的啦!
 Memory Technology Devices (MTD)  --->
         < > Memory Technology Device (MTD) support      <==没必要就不要选吧!
 Parallel port support  --->
     < > Parallel port support        <==由于我的主机上面并没有接打印机,所以没选!如果你有打印机的话,一定要选择
 Plug and Play configuration  --->
         <*> Plug and Play support        <==底下两个随插即用! 马上勾选!
         <*>   ISA Plug and Play support    
 Block devices  --->               <==一些比较冷门的储存机器!如果不确定的话,直接编译成模块吧!没关系的!
         <*> Normal PC floppy disk support
         < > XT hard disk support
         < > Compaq SMART2 support
         < > Compaq Smart Array 5xxx support
         < > Mylex DAC960/DAC1100 PCI RAID Controller support
         < > Loopback device support
         < > Network block device support
         < > RAM disk support
 Multi-device support (RAID and LVM)  --->
         [ ] Multiple devices driver support (RAID and LVM)   <==除非要完 RAID (磁盘阵列)与 LVM ,否则不用选!
 Networking options  --->                  <==这一部份是最重要的除非特别强调,否则能编成模块就编成模块!
     <*> Packet socket
         [*]   Packet socket: mmapped IO
         Netlink device emulation (NEW)
         [*] Network packet filtering (replaces ipchains)
         [ ]   Network packet filtering debugging (NEW)
         [*] Socket Filtering
         <*> Unix domain sockets
         [*] TCP/IP networking
         [*]   IP: multicasting
         [*]   IP: advanced router
         [*]     IP: policy routing (NEW)
         [*]       IP: use netfilter MARK value as routing key (NEW)
         [*]       IP: fast network address translation (NEW)
         [*]     IP: equal cost multipath (NEW)
         [*]     IP: use TOS value as routing key (NEW)
         [*]     IP: verbose route monitoring (NEW)
         [ ]     IP: large routing tables (NEW)
         [*]   IP: kernel level autoconfiguration
         [*]     IP: DHCP support (NEW)
         [*]     IP: BOOTP support (NEW)
         [*]     IP: RARP support (NEW)
            IP: tunneling
            IP: GRE tunnels over IP
         [*]     IP: broadcast GRE over IP (NEW)
         [*]   IP: multicast routing
         [*]     IP: PIM-SM version 1 support (NEW)
         [*]     IP: PIM-SM version 2 support (NEW)
         [*]   IP: TCP Explicit Congestion Notification support
         [*]   IP: TCP syncookie support (disabled per default)
           IP: Netfilter Configuration  --->            <==这就是防火墙机制里头的 iptables 啦!都编成模块!
                 Connection tracking (required for masq/NAT) (NEW)
                    FTP protocol support (NEW)
                    IRC protocol support (NEW)
                 IP tables support (required for filtering/masq/NAT) (NEW)
                    limit match support (NEW)
                    MAC address match support (NEW)
                    netfilter MARK match support (NEW)
                    Multiple port match support (NEW)
                    TOS match support (NEW)
                    AH/ESP match support (NEW)
                    LENGTH match support (NEW)
                    TTL match support (NEW)
                    tcpmss match support (NEW)
                    Connection state match support (NEW)
                    Packet filtering (NEW)
                      REJECT target support (NEW)
                    Full NAT (NEW)
                      MASQUERADE target support (NEW)
                      REDIRECT target support (NEW)
                    Packet mangling (NEW)
                      TOS target support (NEW)
                      MARK target support (NEW)
                    LOG target support (NEW)
                    TCPMSS target support (NEW)
                 ipchains (2.2-style) support (NEW)
                 ipfwadm (2.0-style) support (NEW)
         The IPX protocol
         [ ]   IPX: Full internal IPX network (NEW)
         < > Appletalk protocol support
         < > DECnet Support
         < > 802.1d Ethernet Bridging
         QoS and/or fair queueing  --->
                 [ ] QoS and/or fair queueing
 Telephony Support  --->            <==这东西我也不知道怎么玩~~
         < > Linux telephony support
 ATA/IDE/MFM/RLL support  --->      <==储存界面的选择!当然 IDE 一定要选的啦!! 里面如果有看到属于您的芯片组,请记得将他选择起来!例如如果使用 VIA 的芯片组,那么最后一项VIA82CXXX chipset support就一定要选择起来呢!如果你是跟 VBird 一样,使用较老旧的主机板,那么就用系统默认值也就可以了!
         <*> ATA/IDE/MFM/RLL support
         IDE, ATA and ATAPI Block devices  --->
                 <*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support
                 <*>   Include IDE/ATA-2 DISK support
                 [*]     Use multi-mode by default
                 <*>   Include IDE/ATAPI CDROM support
                 ---- IDE chipset support/bugfixes
                 [*]   CMD640 chipset bugfix/support
                 [*]   RZ1000 chipset bugfix/support
                 [*]   Generic PCI IDE chipset support
                 [*]     Sharing PCI IDE interrupts support
                 [*]     Generic PCI bus-master DMA support
                 [*]       Use PCI DMA by default when available
                 [*]     Intel PIIXn chipsets supportt
                 [*]       PIIXn Tuning supportt
 SCSI support  --->        <==我的旧机器上并没有安装 SCSI 卡!我确定我不会使用到 SCSI ,但是如果你可能会安装的话,请编译!
         < > SCSI support
 Fusion MPT device support  --->
 I2O device support  --->
         < > I2O support
 Network device support  --->  <==仔细的将你的网络设备编译进来吧!这个也很重要的!
         [*] Network device support
         <*> Dummy net driver support  <==这个一定要装!但是请注意!如果你之前已经使用了 MRTG 了!这个装完之后 MRTG 要重跑一次!
         Bonding driver support
         EQL (serial line load balancing) support
         Universal TUN/TAP device driver support
         General Instruments Surfboard 1000
         Ethernet (10 or 100Mbit)  ---> <==这里面有相当多的卡,我只列出我要的卡而已!请选择你自己的网络卡呦!
                 [*] Ethernet (10 or 100Mbit)
                 [*]   EISA, VLB, PCI and on board controllers
                 <*>     EtherExpressPro/100 support
                      RealTek RTL-8139 PCI Fast Ethernet Adapter support
                 [*]       Use PIO instead of MMIO
                 [*]       Support for older RTL-8129/8130 boards
                      VIA Rhine support  <==这就是传说中的 D-Link 530 那块卡的驱动程序啦!
         <*> PPP (point-to-point protocol) support   <==这个一定要编进核心!不然就无法使用 ADSL 的 rp-pppoe 拨接啰!
         [*]   PPP filtering (NEW)
            PPP support for async serial ports (NEW)
            PPP support for sync tty ports (NEW)
            PPP Deflate compression (NEW)
            PPP BSD-Compress compression (NEW)
            PPP over ATM (EXPERIMENTAL) (NEW)
 Amateur Radio support  --->   <==底下这四个应该不需要安装吧!?
 IrDA (infrared) support  --->
 ISDN subsystem  --->
 Old CD-ROM drivers (not SCSI, not IDE)  --->
 Input core support  --->  <==这个也编成模块就好啰!
         Input core support
            Keyboard support
            Mouse support
         (1024)    Horizontal screen resolution (NEW)
         (768)    Vertical screen resolution (NEW)
            Joystick support
            Event interface support
 Character devices  --->   <==接口设备的选项!最重要的地方在 AGP 的设定项目!因为我没有 AGP 所以没有设定!
         [*] Virtual terminal
         [*]   Support for console on virtual terminal
         <*> Standard/generic (8250/16550 and compatible UARTs) serial support
         [*] Unix98 PTY support
         Mouse Support (not serial and bus mice)
         [*]   PS/2 mouse (aka "auxiliary device") support
         < > /dev/agpgart (AGP Support)  <==这个相当的重要!就是 AGP 显示卡的支持核心!请选择(若你有 AGP 的话!)
         [ ]   Intel 440LX/BX/GX and I815/I830M/I840/I850 support  <==下面的选项要上面的打勾之后才会出现!
         [ ]   Intel I810/I815/I830M (on-board) support               请特别留意选择你的适合的主机板芯片组呢!
         [ ]   VIA chipset support
         [ ]   AMD Irongate, 761, and 762 support
         [ ]   Generic SiS support
         [ ]   ALI chipset support
         [ ]   Serverworks LE/HE support
         [ ] Direct Rendering Manager (XFree86 DRI support)
         [ ]   Build drivers for old (XFree 4.0) DRM (NEW)
         --- DRM 4.1 drivers
         < >   3dfx Banshee/Voodoo3+
         < >   ATI Rage 128
         < >   ATI Radeon
         < >   Intel I810
         < >   Matrox g200/g400
         < >   SiS (NEW)
         [ ] Direct Rendering Manager (XFree86 DRI support)
 Multimedia devices  --->
 File systems  --->      <==底下的选项主要在提供核心支持的档案格式!相当的重要!如果忘记编入的话,系统可是会读不到东西!
         [*] Quota support    <==没有他! Quota 就无法起来!请选择呦!
         Kernel automounter support
         <*> Kernel automounter version 4 support (also supports v3)
         Ext3 journalling file system support (EXPERIMENTAL)
         DOS FAT fs supportt
            MSDOS fs supportt
              UMSDOS: Unix-like file system on top of standard MSDOS fss
            VFAT (Windows-95) fs supportt
         Compressed ROM file system support
         [*] Virtual memory file system support (former shm fs)
         <*> ISO 9660 CDROM file system support   <==在 Red Hat 7.2 这里就是被编成模块了!才需要每次加载!
         [*]   Microsoft Joliet CDROM extensionss
         Minix fs support
         NTFS file system support (read only)
         [*] /proc file system support
         [*] /dev/pts file system for Unix98 PTYs
         <*> Second extended fs support
         System V/Xenix/V7/Coherent file system support
         Network File Systems  --->
                 Coda file system support (advanced network fs)
                 <*> NFS file system support  <==NFS 也是需要的呦!
                 SMB file system support (to mount Windows shares etc.)  <==网芳总是需要的吧!
                 [*]   Use a default NLS (NEW)
                         Default Remote NLS Option: "cp950" (NEW)   <==支持中文的语系!
         Partition Types  --->
         Native Language Support  ---> <==除了底下说的几个 * 的之外,其它的全部都编译成为模块!(以备不时之需!)
                      Default NLS Option: "iso8859-1" (NEW)
                 <*> Traditional Chinese charset (Big5) (NEW)
                 <*> NLS ISO 8859-1  (Latin 1; Western European Languages) (NEW)
                 for others
 Console drivers  --->
         [*] VGA text console
 Sound  --->
         < > Sound card support  <==你有声卡吗?那就编译他吧!
 USB support  --->
         Support for USB
 Kernel hacking  --->
 好了!编译完成之后选择『Save Configuration to an Alternate File』然后写成一个你喜欢的档名,这个档案内容就是你刚刚编译完成的数据啦!然后选择 之后,再储存一次到系统当中!接着下来就准备要编译.

开始编译之前:
 需要将原本的模块移动到其它地方去.
开始编译:
 开始编译的动作主要如下所示:
 
 # make dep        <==模块进行相依属性的建立;
 # make clean       <==将您前一次编译的目标文件 ( *.o 的档案 ) 给他去除
 # make bzImage      <==开始编译核心.这个核心是经过压缩的,此外,这个步骤也很长.
                           <==编译出来的核心档案放置的地点在底下的目录当中:
                           <== /usr/src/linux/arch/i386/boot/bzImage
                           <==此外,其实还有个未经压缩的核心在 /usr/src/linux 底下,
                           <==那就是 /usr/src/linux/vmlinux
 # make modules      <==开始编译模块.这个动作视您刚刚编译的模块数量.
 # make modules_install  <==好了.将数据给他安装在 /lib/modules/`uname -r` 里面.
 # make install      <==就将刚刚 bzImage 建立完成的核心给他安装上来.
安装核心与 grub多重开机设定
 将核心放置在开机核心预设放置的目录 /boot.
 # cp /usr/src/linux/arch/i386/boot/bzImage /boot/vmlinuz-2.4.18
 修改grub
 [root @test linux]# vi /boot/grub/menu.lst
 timeout 10
 color black/cyan yellow/cyan
 default 0

 title linux-2.4.18
   kernel (hd0,0)/boot/vmlinuz-2.4.19 root=/dev/hda1 devfs=mount

 title linux-2.4.19-16mdk
   kernel (hd0,0)/boot/vmlinuz-2.4.19-16mdk root=/dev/hda1 devfs=mount
   initrd (hd0,0)/boot/initrd.img
核心模块管理:
  /etc/modules.conf
  如:alias eth0 via-rhine
  核心的模块放置目录:   /lib/modules/`uname –r`/kernel/
  核心的档案格式模块:   /lib/modules/`uname –r`/kernel/fs
  核心的网络卡驱动程序模块: /lib/modules/`uname –r`/kernel/drivers/net
  depmod
   [root @test /root]# depmod [-aens]
   参数说明:
   -a :将 /etc/modules.conf 可以查询到的模块的相关性都写入 /lib/modules/`uname -r`/当中
   -e :显示出目前已加载的不可执行的模块名称
   -n :将各模块的相依性直接输出屏幕上,而不是输出到 /lib/modules/`uname -r` 当中
   -s :将一些讯息结果输出到 syslog 的登录档中!
 lsmod
 modinfo
 [root @test /root]# modinfo [-adnp] module_name
 参数说明:
 -a :秀出作者
 -d :秀出这个模块的基本说明
 -n :秀出这个模块的档案放置路径与名称  
 如果不加任何参数的时候,就是将这个模块的所有讯息都写出来
 modprobe
 [root @test /root]# modprobe [-l|-c]
 [root @test /root]# modprobe modules_name<==直接加载该模块与其相依属性的模块
 参数说明:
 -l :列出目前系统所有的模块 ( 在 /lib/modules/`uname -r`/kernel 底下 )
 -c :列出目前系统所有的模块。(更详细的代号对应表)  
 insmod
 [root @test /root]# insmod [-fkps] module_name
 参数说明:
 -f :强制将模块加载,要加载不相同版本的模块时候可能会用到的参数
 -k :自动在核心没有使用到该模块的时候,先清除干净!
 -p :测试模块是否可以被加载,不会直接加载系统中!
 -s :将一些执行讯息写到 syslog 这种登录档,而不是写到 terminal 当中!
 rmmod
 [root @test /root]# rmmod modules_name  
 移除模块

##感谢鸟哥。。
阅读(1197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~