13719654321 发表于 2015-4-6 10:36:01

vmware环境精简linux内核配置及内核代码

  1.内核配置精简
  花了点时间终于弄清了vmware的硬件情况,配置简单内核主要为了学习源码方便
  我的vmware虚拟机把硬盘和cdrom都设置成scsi接口的,这样内核ide选项就不用选了
  在2.6.10和3.2.5都试过了,可以启动,两个内核分别在redhat9和arch上实验的,安装的实验系统的时候也尽量简单,比如分区没有lvm,直接用/dev/sdax表示
  下面是3.2.5内核配置情况,2.6.10也基本相同,菜单结构有些不一样,有些驱动名字变了,但是很容易看出来。因为我把内核模块支持都去掉了,所以下面全是*,也就是编译进内核
  
  Enable loadable module support
  没选
  Power management and ACPI options
  可以全都不选
  Bus options
  只选择了PCI support
  Executable file formats / Emulations
  只选择了kernel support for ELF binaries
  Networking support
  我只选了基本网络协议,其他都去掉了
  Device Drivers
  Connector- unified userspacekernelspace linker
   Block devices-->
                  Normal floppy disk support
                  loopback device support
                  network block device support
                  RAM block device support
  SCSI device support//如果是ide硬盘,这个可以全都不选,选择ata相关的
  SCSI device support
                   legacy /proc/scsi/ support
                   scsi disk support
                   scsi cdrom support
                   scsi generic support
                   Probe all LUNs on each SCSI device
  Fusion MPT device support
                  Fusion MPT ScsiHost drivers for SPI
  I2C support
                      I2C hardware bus support
                               Intel PIIX4 and compatible
  Network device support
                     Ethernet driver support
                               AMD devices
                                       AMD PCnet32 PCI support      
  device配置就选择了这么多,没有带上usb,准备usb以后需要在加               
  File systems
  可以更据实际安装情况配置,我的需要ext2,ext3,还有
       Dnotify support
       Inotify support for userspace
       Filesystem wide access notification
       Quota support
       Report quota messages through netlink interface
       Pseudo filesystems-->
                  没选 HugeTLB support,其他选了
  Kernel hacking
  根据自己需要选择
  Firmware Drivers
  Security options
  Cryptographic API
  Virtualization
  Library routines
  这五项可以都不选
  剩下Processor type and features和其他的可以更具具体情况选择。
  
  2.代码精简
  配置完内核能成功运行后,就可以删除多余代码了,很简单
  首先删除多余.c文件:可以编写脚本或者程序来遍历目录,凡是.c文件没有生成.o文件就删除了。这样会误删的,不过还好很少
  删除.h文件:这个有些麻烦,我是在fs/open.c的open系统调用那里printk所有.h文件,然后分析下
  
  
  
页: [1]
查看完整版本: vmware环境精简linux内核配置及内核代码