一. 最小系統要求
1. 接受鍵盤輸入,能顯示字符信息
2. 能處理普通linux發行版中的大部分基本命令,如:ls, mv...
3. 具有網絡功能
4. 不使用ramdisk, 所需驅動全部編譯進內核
二. 主機環境
1. VMware 7.0 / windows 7
2. 主機系統Ubuntu 10.04 x86
3. 最小系統內核版本 linux-2.6.38
三. 詳細構建過程
1. 下載linux-2.6.38內核
- #cd /usr/src
- #wget http://kernel.org/pub/linux/kernel/v2.6/linux-2.6.38.tar.gz
- #tar xvf linux-2.6.38.tar.gz
- #cd linux-2.6.38
2.編譯內核
這一步主要就是內核的配置,如果配置錯了可能導致系統無法啟動,因此需要非常仔細。
- #make mrproper
- #make allnoconfig
- #make menuconfig
首先利用lspci查看硬件信息:
- #lspci
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 Adapter
00: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: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: Intel Corporation 82371AB/EB/MB PIIX4 USB
02:01.0 Ethernet controller: Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE] (rev 10)
02:02.0 Multimedia audio controller: Ensoniq ES1371 [AudioPCI-97] (rev 02)
02:03.0 USB Controller: VMware USB2 EHCI Controller
根據查到的硬件型號配置.config文件
以下詳細介紹內核的配置
General setup --->
[*] System V IPC
[*] Enable loadable module support --->
Processor type and features --->
Processor family (Pentium Pro) --->
[*] Generuc x86 support
Bus options (PCI etc.) --->
[*] PCI support
PCI access mode (Any) --->
Executable file formats / Emulations --->
[*] Kernel support for ELF binaries
[*] Write ELF core dumps with partial segments
[*] Networking support --->
Networking options --->
<*> Packet socket
<*> Unix domain sockets (NEW)
[*] TCP/IP networking
<*> IP: IPsec transport mode (NEW)
<*> IP: IPsec tunnel mode (NEW)
<*> IP: IPsec BEET mode (NEW)
<*> Large Receive Offload (ipv4/tcp) (NEW)
<*> INET: socket monitoring interface (NEW)
Device Drivers --->
[*] Block devices --->
<*> Loopback device support
SCSI device support --->
<*> SCSI device support
[*] legacy /proc/scsi/ support (NEW)
<*> SCSI disk support
[*] SCSI low-level drivers (NEW) --->
<*> BusLogic SCSI support
[*] Fusion MPT device support --->
<*> Fusion MPT ScsiHost drivers for SPI
<*> Fusion MPT ScsiHost drivers for FC
<*> Fusion MPT ScsiHost drivers for SAS
<*> Fusion MPT misc device (ioctl) driver
[*] Network device support --->
[*] Ethernet (10 or 100Mbit) --->
[*] EISA, VLB, PCI and on board controllers
<*> AMD PCnet32 PCI support
Graphics support --->
<*> Support for frame buffer devices --->
File systems --->
<*> Second extended fs support
[*] Ext2 extended attributes
[*] Ext2 POSIX Access Control Lists
[*] Ext2 Security Labels
[*] Ext2 execute in place support
<*> Ext3 journalling file system support
[*] Default to 'data=ordered' in ext3 (NEW)
[*] Ext3 extended attributes (NEW)
[*] Ext3 POSIX Access Control Lists
[*] Ext3 Security Labels
CD-ROM/DVD Filesystems --->
<*> ISO 9660 CDROM file system support
<*> Native language support --->
<*> Codepage 437 (United States, Canada)
<*> Simplified Chinese charset (CP936, GB2312)
配置完成後就可以開始編譯了:
- #make bzImage
注意:在make menuconfig的時候一定要選對磁盤驅動,否則會出現kernel panic -- VFS error:
這裡我用的是SCSI的磁盤,IDE的要做相應修改。