gentoo环境下裁剪、安装内核

来源:互联网 发布:海拉尔二中分尸案 知乎 编辑:程序博客网 时间:2024/06/03 15:30

硬件平台:TOSHIBA M600-02S

软件平台 :主机 Fedora 16 x86_64 虚拟机 VMware WorkStation 8.0.3     

主机Lspci结果:

00:00.0 Host bridge: Intel Corporation Core Processor DRAM Controller (rev 02)00:01.0 PCI bridge: Intel Corporation Core Processor PCI Express x16 Root Port (rev 02)00:02.0 VGA compatible controller: Intel Corporation Core Processor Integrated Graphics Controller (rev 02)00:16.0 Communication controller: Intel Corporation 5 Series/3400 Series Chipset HECI Controller (rev 06)00:1a.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)00:1c.0 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 1 (rev 05)00:1c.1 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 2 (rev 05)00:1c.2 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 3 (rev 05)00:1c.3 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 4 (rev 05)00:1c.4 PCI bridge: Intel Corporation 5 Series/3400 Series Chipset PCI Express Root Port 5 (rev 05)00:1d.0 USB Controller: Intel Corporation 5 Series/3400 Series Chipset USB2 Enhanced Host Controller (rev 05)00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev a5)00:1f.0 ISA bridge: Intel Corporation Mobile 5 Series Chipset LPC Interface Controller (rev 05)00:1f.2 SATA controller: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA AHCI Controller (rev 05)00:1f.3 SMBus: Intel Corporation 5 Series/3400 Series Chipset SMBus Controller (rev 05)00:1f.6 Signal processing controller: Intel Corporation 5 Series/3400 Series Chipset Thermal Subsystem (rev 05)01:00.0 VGA compatible controller: nVidia Corporation GT216 [GeForce GT 330M] (rev a2)02:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)07:00.0 Network controller: Broadcom Corporation BCM4313 802.11b/g/n Wireless LAN Controller (rev 01)16:00.0 System peripheral: JMicron Technology Corp. SD/MMC Host Controller (rev 20)16:00.2 SD Host controller: JMicron Technology Corp. Standard SD Host Controller (rev 20)16:00.3 System peripheral: JMicron Technology Corp. MS Host Controller (rev 20)16:00.4 System peripheral: JMicron Technology Corp. xD Host Controller (rev 20)ff:00.0 Host bridge: Intel Corporation Core Processor QuickPath Architecture Generic Non-core Registers (rev 02)ff:00.1 Host bridge: Intel Corporation Core Processor QuickPath Architecture System Address Decoder (rev 02)ff:02.0 Host bridge: Intel Corporation Core Processor QPI Link 0 (rev 02)ff:02.1 Host bridge: Intel Corporation Core Processor QPI Physical 0 (rev 02)ff:02.2 Host bridge: Intel Corporation Core Processor Reserved (rev 02)ff:02.3 Host bridge: Intel Corporation Core Processor Reserved (rev 02)

VMware下lspic结果:

00:00.0 Host bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (rev 01)00:01.0 PCI bridge: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX AGP bridge (rev 01)00:07.0 ISA bridge: Intel Corporation 82371AB/EB/MB PIIX4 ISA (rev 08)00:07.1 IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)00:07.3 Bridge: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)00:07.7 System peripheral: VMware Virtual Machine Communication Interface (rev 10)00:0f.0 VGA compatible controller: VMware SVGA II Adapter00:10.0 SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)00:11.0 PCI bridge: VMware PCI bridge (rev 02)00:15.0 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.1 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.2 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.3 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.4 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.5 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.6 PCI bridge: VMware PCI Express Root Port (rev 01)00:15.7 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.0 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.1 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.2 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.3 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.4 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.5 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.6 PCI bridge: VMware PCI Express Root Port (rev 01)00:16.7 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.0 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.1 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.2 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.3 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.4 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.5 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.6 PCI bridge: VMware PCI Express Root Port (rev 01)00:17.7 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.0 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.1 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.2 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.3 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.4 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.5 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.6 PCI bridge: VMware PCI Express Root Port (rev 01)00:18.7 PCI bridge: VMware PCI Express Root Port (rev 01)02:00.0 USB controller: VMware USB1.1 UHCI Controller02:01.0 Ethernet controller: Intel Corporation 82545EM Gigabit Ethernet Controller (Copper) (rev 01)02:02.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)02:03.0 USB controller: VMware USB2 EHCI Controller

下面进入正题:

1、参照http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml一步步执行,执行到

make menuconfig

2、内核功能:
  能够完成系统的基本功能,上网,收发邮件等,支持xwindows图形界面。
  在menuconfig中配置:
  详细介绍内核配置选项及删改情况

  
        第一部分:Genral setup——>
        除以下选项,其他全部删除
               
其中:               
        System V IPC (IPC:Inter Process Communication)是组系统调用及函数库,它能让程序彼此间同步进行交换信息。某些程序以及DOS模拟环境都需要它。为进程提供通信机制,这将使系统中各进程间有交换信息与保持同步的能力。有些程序只有在选Y的情况下才能运行,所以不用考虑,这里一定要选。
         
        Support for paging of anonymous memory (swap),如果不编译进内核,系统启动时会出现错误
Active /dev/sda[0-9] swapswapon fails  function not implemented
因此将其编入内核。


  第二部分 : [*] Enable loadable module support  ——>  
        除以下选项,其它全部删除
        
        这个选项可以让内核动态加载或卸载模块,所以选上。
        

        第三部分:-*- Enable the block layer  ——> 
        全部删除

        块设备
  

        第四部分:Processor type and features  ——>
        
       它会对每种CPU做最佳化,让它跑的好又快,一般来说,你是什么型号的就选什么型号的就好。我的处理器是i5 520M,所以选择这个选项。
  

        第五部分:Power management and ACPI options  ——>
        除以下选项,其它全部删除
     
                        
  ACPI Support ---〉高级电源接口配置支持,如果BIOS支持,建议选上这项
  []Button 这个选项用于注册基于电源按钮的事件,比如power, sleep等,当你按下按钮时事件将发生,一个守护程序将读取/proc/acpi/event,并执行用户在这些事件上定义的动作比如让系统关机。可以不选择,根据自己的需求。
  

        第六部分:Bus options (PCI etc.)  ——>
        除以下选项,其它全部删除
  
  

        第七部分:Executable file formats / Emulations  ——>  
        除以下选项,其它全部删除
  
        Kernel support for ELF binaries ELF是开放平台下最常用的二进制文件,它支持不同的硬件平台。一定要选。
  
        
        第八部分:-*- Networking support  ——>
        除以下选项,其它全部删除
        
                                 

  
        第九部分:Device Drivers  ——>
        除以下选项,其它全部删除
     
                 
        上面这个选项如不选择,系统启动时会出现错误:         
/etc/init.d/udev[1355]: Error: cannot start udev as udev-mount would not start


       
                         
  []Loopback device support 大部分的人这一个选项都选N,因为没有必要。但是如果你要mount iso文件的话,你得选上Y。这个选项的意思是说,可以将一个文件挂成一个文件系统。如果要烧光盘片的,那么您很有可能在把一个文件烧进去之前,看看这个文件是否符合IS09660的文件系统的内容,是否符合您的需求。而且,可以对这个文件系统加以保护。不过,如果您想做到这点的话,您必须有最新的mount程序,版本是在2.5X版以上的。而且如果您希望对这个文件系统加上保护,则您必须有des.1.tar.gz这个程序。注意:此处与网络无关。建议编译成模块


        
  里面有关于USB支持的,要选择
        
  []SCSI device support USB要用,必须选择
  []legacy /proc/scsi/ support USB要用,必须选择
  []SCSI disk support USB要用,必须选择


        
                   
  根据lspci可知,这些要选上,否则无法识别分区。

        
        
                  
        []Intel PIIX/ICH SATA support 这个必须选择,否则无法产生引导文件
        

        
                  
         上面的选项也是根据lspci选的,个人觉得还有可以删减的地方,还没有试验。


         
          
                            
        我的电脑是千兆网卡所以就选这个。
  

        
        这个没什么好说的,自己随意吧。
                
        这个要选。
 

        
                
         上面选项要选,gentoo安装完有个奇怪的问题,就是时间要吗提前8小时,要么晚了8小时。
         解决方法是
         
date XXXXXXXX /sbin/hwclock --directisa --systohc

        如果不选则上,会出现错误:
hwclock: Cannot access the Hardware Clock via any known method. hwclock: Use the --debug option to see the details of our search for an access method.

         
                 
                          
         这个选项如不选择,启动时会出现下面错误:

May  7 19:48:26 Universe agetty[1560]: /dev/ttyS1: No such file or directoryMay  7 19:48:26 Universe agetty[1559]: /dev/ttyS0: No such file or directoryMay  7 19:48:36 Universe agetty[1561]: /dev/ttyS1: No such file or directoryMay  7 19:48:36 Universe agetty[1562]: /dev/ttyS0: No such file or directory


              
  []Support for frame buffer devices 支持Frame buffer的,一定要选择的。

        
        
               
                          
                                     
        这个是我的声卡。
        

        
              
        HID input layer support 应该选择
        USB Human Interface Device (full HID) support 里面选择usb鼠标和usb键盘,如果你有一定选上这个必需选
        /dev/hiddev raw HID device support如果这里有USB键盘和鼠标选项,一定要选择
  
       
        
               
               
                
                
  []USB device filesystem 这个好象是用U盘必须的
  []EHCI HCD (USB 2.0) support 有usb2.0就选上把,编译成模块
  []OHCI HCD support 必须选择,编译成模块
  []UHCI HCD (most Intel and VIA) support 必须选择,编译成模块
  []USB Mass Storage support 用U盘必须选择
  

        第十部分:File systems  ——>
        除以下选项,其它全部删除
  
  Kernel automounter support 内核自动挂载的,当然要选
  Kernel automounter version 4 support (also supports v3) 当然要选

        至于Inotify,若不选,开机和关机时报错:
* Starting udevd ...    error initializing inotify  * start-stop-daemon: failed to start `/sbin/udevd'                                      


       
               
      CD-ROM/DVD Filesystems ---> 这个是关于挂载ISO文件的,用的话就选。
      <*>ISO 9660 CDROM file system support
      

       
               
       []NLS ISO 8859-1 必须选择,这个是关于U盘挂载的。
 
 
        
              
       这个要选择,否则开机启动时出错:
mounting /dev/shm...mount wrong fs type, bad option, bad superblock on shm, missing codepage, ...

      
     
     Native language support语言支持,这里就支持英语和汉语就行了,不多说了
    

        第十一部分: Kernel hacking  ——> 
        全部删除

  Kernel hacking --->破解核心?可不是当骸客啦,不选

  
        第十二部分:Security options  ——>  
        全部删除
 
  

        第十三部分: [ ] Cryptographic API  ——>
        全部删除
 
        这是核心支持加密的选项

  
        第十四部分:[ ] Virtualization  ——>
        全部删除
  
        
        第十五部分:Library routines  ——> 
        全部删除

        最后: Save an Alternate Configuration File


参考信息:
  http://bbs.chinaunix.net/thread-2263201-1-1.html
        http://www.mygnu.de/index.php/2012/03/udev-182-needs-config_-devtmpfs-in-kernel/
        http://www.linuxidc.com/Linux/2007-12/9639.htm
        http://www.linuxsir.org/bbs/thread355475.html?pageon=1#2019115
        http://forums.gentoo.org/viewtopic-t-374360.html?sid=26dc4f9b996d68e680821eeb3f81da55
        http://www.linuxquestions.org/questions/linux-general-1/2-6-3-swapon-function-not-implemented-155442/
        http://www.linuxquestions.org/questions/linux-general-1/2-6-3-swapon-function-not-implemented-155442/
        http://forums.gentoo.org/viewtopic-t-885942-start-0.html
        http://forums.gentoo.org/viewtopic-t-803794.html?sid=29c0aa912c8f3e3784ede1d79c661c3e
        http://forums.gentoo.org/viewtopic-t-887320-start-0.html
        http://soft.zdnet.com.cn/software_zone/2007/1018/564904.shtml
        http://forums.gentoo.org/viewtopic-t-881249.html


这是第一次弄gentoo,反复重新编译内核弄了大半天,终于可以快速启动了,肯请大家多多指教。