天天看點

Linux 系統裁減指南 (LiPS)》

LiPS 詳細設計說明書

————————————

(Linux 系統裁減指南)

一種建立小型化Linux系統的方法

目 錄

1 引言 6

1.1 編寫目的 6

1.2 背景 6

1.3 定義 6

1.4 參考資料 6

2 總體描述 8

2.1 硬體環境 8

2.2 軟體環境 8

2.3 需求規定和限制 8

3 總體設計 9

3.1 基本設計概念 9

3.2 軟體結構 9

4 核心 10

4.1 建立核心的方法 10

4.2 核心配置 10

4.2.1 概述 10

4.2.2 Loadable module support 11

4.2.3 Processor type and features 11

4.2.4 General setup 12

4.2.5 Plug and Play configuration 12

4.2.6 Block devices 12

4.2.7 Multi-device support (RAID and LVM) 13

4.2.8 Networking options 13

4.2.9 ATA/IDE/MFM/RLL support 14

4.2.10 SCSI support 15

4.2.11 Network device support 15

4.2.12 Character devices 16

4.2.13 File systems 17

4.2.14 Console drivers 18

4.2.15 USB support 18

4.3 提示 19

4.3.1 EXTRAVERSION 19

4.3.2 .config 19

5 根檔案系統 21

5.1 根檔案系統 21

5.2 檔案系統的内容 21

5.2.1 應用程式(applications) 21

5.2.2 裝置檔案(device files) 21

5.2.3 腳本和配置檔案(scripts and configuration files) 22

5.2.4 庫檔案(libraries) 23

5.2.5 必要的目錄 24

5.3 初始化RAM盤(initrd) 24

5.3.1 操作步驟 24

5.3.2 引導選項 24

5.3.3 安裝 25

5.3.4 改變根目錄裝置 26

5.3.5 使用場合 27

5.3.6 淘汰的根轉換機制(change_root) 27

5.4 系統初始化(init) 27

5.4.1 init的任務 28

5.4.2 SysVinit 28

5.4.3 兩種風格:Slackware vs. Debian 28

5.5 PAM 29

5.5.1 什麼是PAM 29

5.5.2 PAM的結構 29

5.5.3 配置檔案 29

5.5.4 other 29

5.6 再論initrd 30

5.6.1 根到底在哪裡 31

5.6.2 linuxrc 31

5.6.3 根轉換機制:新的?舊的? 32

5.7 提示 34

5.7.1 檔案系統目錄層次結構 34

5.7.2 mklips.sh(制作LiPS的腳本) 34

5.7.3 lips.conf(LiPS配置檔案) 34

5.7.4 cp –dpR 35

5.7.5 如何判斷一個程式依賴哪些檔案 35

5.7.6 帶庫檔案複制——lcp() 35

5.7.7 庫檔案的命名 36

6 引導 38

6.1 引導過程概述 38

6.2 幾種引導方式 38

6.3 grub引導器 38

6.4 USB引導 38

6.4.1 制作步驟 39

6.5 提示 40

6.5.1 版本問題? 40

7 遠端式列槽控制台 41

7.1 概述 41

7.2 配置方法 41

7.3 提示 41

7.4 Linux 遠端式列槽控制台指南 41

8 系統安裝CD光牒 44

8.1 概述 44

8.2 boot.isoCD光牒的檔案結構分析 44

8.3 制作步驟 45

9 源代碼(配置檔案和腳本) 46

9.1 lips.conf 46

9.2 mklips.sh 46

1 引言

1.1 編寫目的

  說明Linux系統裁減的過程及解決的主要技術問題。本文檔的編寫是為了說明LiPS的詳細設計過程,也可以作為構造一個小型化Linux系統的指南。

  本文檔内容的組織如下所述:這一部分是引言,第2部分是對項目軟、硬體環境和需求的總體描述,第3部分說明了裁減LINUX的相關基本概念。後面幾個部分是具體實作方法的詳細說明,4~6分别較長的描述了建立核心、建立根檔案系統和引導系統的方法。最後的内容可以看作附錄,其中7說明了一般Linux系統安裝CD光牒的建立方法,8列出了相關的配置檔案和源代碼。

1.2 背景

  華中科技大學計算機存儲系統國家專業實驗室,NAS項目(2003.3——2003.8)。

1.3 定義

O boot loader: 引導器

O kernel: 核心

O root filesystem: 根檔案系統

O USB: 通用串行總線

1.4 參考資料

[1] DIY:自己動手做一個迷你 Linux 系統. IBM developerWorks 中國網站. http://www-900.ibm.com/developerWorks/cn/linux/embed/diy/index.shtml

[2] Linux From Scratch. http://clfsbook.mylab.idv.tw/index.html

[3] Linux啟動過程綜述. http://www.linuxaid.com.cn/forum/showdoc.jsp?l=1&i=15750

[4] The Linux Bootdisk HOWTO (中譯版). http://www.linux.org.tw/CLDP/gb/Bootdisk-HOWTO.html

[5] Using the initial RAM disk (initrd). /usr/src/linux-2.4/Documentation/initrd.txt. (譯文:http://zope.slat.org/Project/3ybaby/discuss-area/cd-boot/cdboot_refer/initrd.htm)

[6] Quickmouse于2003.1發表于白雲黃鶴BBS (http://bbs.whnet.edu.cn Linux讨論區的文章“裁減Linux”。

[7] Filesystem Hierarchy Standard. http://www.pathname.com/fhs/pub/fhs-2.2.pdf

[8] LINUX ALLOCATED DEVICES. /usr/src/linux-2.4/Documentation/device.txt.

或者最新的清單在http://www.kernel.org/pub/linux/docs/device-list/

[9] Karim Yaghmour. Building Embedded Linux Systems. O'Reilly, April 2003.

[10] Alessandro Rubini. Take Command: Init. http://www.linux.it/kerneldocs/init/ , November 1998.

[11] 深入 Linux PAM 體系結構. IBM developerWorks 中國網站. http://www-900.ibm.com/developerWorks/cn/linux/l-pam/index.shtml . 2003.7.

2 總體描述

2.1 硬體環境

  開發主機:

  Intel 845晶片組主機闆,P4賽揚1.8GHz CPU,256M記憶體,60G IDE硬碟,RTL8139網卡。

  目标機:與主機同構。

2.2 軟體環境

  開發主機:

  Redhat Linux 7.3 (kernel 2.4.18-3),或者Redhat Linux 9 (kernel 2.4.20-8)。可以根據需要使用其他版本的核心,比如Redhat 7.3+kernel 2.4.20。

  目标機:LiPS,以及應用程式。

2.3 需求規定和限制

  我們目标系統LiPS,即Linux Powered Storage是一個嵌入式Linux作業系統,主要着眼于提供各種檔案服務,不包括X GUI;并且足夠小,可以裝入32M USB盤或者DOC/DOM等常用裝置引導。

  

3 總體設計

3.1 基本設計概念

  提起“裁減Linux”,最容易想到的方法是以一個已經安裝好的系統為基礎,删除掉不需要的檔案,以減小整個系統的尺寸。而事實上這個方法幾乎是行不通的,因為通過CD光牒安裝的一個Redhat 9 Linux系統,即便是隻選擇了比較少的軟體包,其所占空間也可以輕松達到300~500MB,想在這個基礎上裁減到30MB左右是比較困難的。更困難的是确定哪些東西是可以删除的?如果删除了系統必須的檔案,可能導緻系統不能引導。

  另一個途徑是從零開始根據需要建構整個系統。“Linux From Scratch”采用的就是這種方式,一個個安裝需要的軟體包。類似的,更簡單的方法是,安裝一個完整的Linux系統,然後将必要的軟體(可執行程式)、配置檔案、庫檔案、核心等複制出來建構一個小系統。我們采取後一種方式。

  

3.2 軟體結構

  LiPS包括3部分:Linux核心,根檔案系統和引導器。

  核心(Kernel)提供了一個作業系統的基本功能,如記憶體管理、程序排程、檔案系統、網絡等,以及裝置驅動程式。

  根檔案系統(Root filesystem)是存放運作、維護系統所必須的各種工具軟體、庫檔案、腳本、配置檔案和其他特殊檔案(比如裝置節點)的地方,也可以安裝各種軟體包。通常根檔案系統位于某個磁盤分區,而在LiPS中應用了initrd(初始RAM盤)機制,将根檔案系統放在RAM Disk中。

  引導器(Boot Loader)的任務是從引導裝置裝載核心,引導系統運作。Linux系統常見的引導器包括早期的LILO和近期的GRUB。LiPS用的是GRUB。

  

4 核心

4.1 建立核心的方法

  Linux提供了友善靈活的方法來定制核心,主要步驟包括:下載下傳安裝核心源代碼樹,配置核心,編譯核心。具體方法請參考相關文檔。關鍵指令如下:

cd /usr/src/linux-2.4

make menuconfig

make dep; make clean; make bzImage

  編譯成功的核心檔案為 arch/i386/boot/bzImage.

4.2 核心配置

4.2.1 概述

  make menuconfig之後可以看到類似如下的内容(編号是為了描述友善而加上的)。根據核心版本的不同,列出的項目會有差異。而變化主要發生在發行版為标準核心打的各種更新檔上面,其實标準核心是比較穩定的。

  如下所示,我們配置的核心版本為2.4.20-8,這個“-8”就是Redhat所打的更新檔版本号。更新檔一般是對标準核心錯誤的修正和新增的功能。與2.4.20核心配置選項比較會發現,[10,25,30]都屬于Redhat的更新檔。

  一般地,這些更新檔選項都不是必須的,是以我們的LiPS核心中都沒有包括這些選項。其實,完全可以通過直接配置一個标準的核心版本(比如2.4.20)來産生我們所需要的核心。

Linux Kernel v2.4.20-8-R2Lips Configuration

[1] Code maturity level options --->

[2] Loadable module support --->

[3] Processor type and features --->

[4] General setup --->

[5] Memory Technology Devices (MTD) --->

[6] Parallel port support --->

[7] Plug and Play configuration --->

[8] Block devices --->

[9] Multi-device support (RAID and LVM) --->

[10] Cryptography support (CryptoAPI) --->

[11] Networking options --->

[12] Telephony Support --->

[13] ATA/IDE/MFM/RLL support --->

[14] SCSI support --->

[15] Fusion MPT device support --->

[16] I2O device support --->

[17] Network device support --->

[18] Amateur Radio support --->

[19] IrDA (infrared) support --->

[20] ISDN subsystem --->

[21] Old CD-ROM drivers (not SCSI, not IDE) --->

[22] Input core support --->

[23] Character devices --->

[24] Multimedia devices --->

[25] Crypto Hardware support --->

[26] File systems --->

[27] Console drivers --->

[28] Sound --->

[29] USB support --->

[30] Additional device driver support --->

[31] Bluetooth support --->

[32] Kernel hacking --->

[33] Library routines --->

Load an Alternate Configuration File

Save Configuration to an Alternate File

<Select> < Exit > < Help >

  下面我們以2.4.20核心為例,來詳細說明核心的配置,也就是選哪些東西、不選哪些東西。沒有說明的選項,比如“Code maturity level options”,表示不選。

4.2.2 Loadable module support

Enable loadable module support

[ ] Set version information on all module symbols Kernel module loader

  可加載子產品支援。雖然目前所選項目全部編譯進核心,但是核心是支援子產品的。可以考慮将一些硬體裝置的驅動程式編譯為子產品,進而減小核心尺寸,同時增加适應不同硬體平台的靈活性。

4.2.3 Processor type and features

(Pentium-III/Celeron(Coppermine)) Processor family Machine Check Exception

< > Toshiba Laptop support

< > Dell laptop support

< > /dev/cpu/microcode - Intel IA32 CPU microcode support

< > /dev/cpucpuid - CPU information support

(off) High Memory Support

[ ] Math emulation

[ ] MTRR (Memory Type Range Register) support

[ ] Symmetric multi-processing support

[ ] Local APIC support on uniprocessors

[ ] Unsynced TSC support

  處理器特性。選擇一下Processor family,其餘基本上都沒有選。High Memory Support也可以打開,不清楚有什麼用。

4.2.4 General setup

Networking support

PCI support

(Any) PCI access mode

ISA bus support

PCI device name database

[ ] EISA support

[ ] MCA support

[ ] Support for hot-pluggable devices

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 binaries

Power Management support

< > Kernel support for MISC binaries

Power Management support

<*> Advanced Power Management BIOS support

Ignore USER SUSPEND

Enable PM at boot time

Make CPU Idle calls when idle

Enable console blanking using APM

RTC stores time in GMT

Allow interrupts during APM BIOS calls

Use real mode APM BIOS call to power off

  總體設定。這一部分選項比較重要,包括網絡、總線、程序、二進制檔案格式、電源管理等。其中APM相關的選項比較搞不清楚,有時候halt –p指令不能關閉系統電源跟這裡有關系。

4.2.5 Plug and Play configuration

<*> Plug and Play support

< > ISA Plug and Play support

  即插即用設定。

4.2.6 Block devices

<*> Normal 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

(4096) Default RAM disk size

Initial RAM disk (initrd) support

Per partition statistics in /proc/partitions

  塊裝置。軟驅也可以不選。這裡的關鍵選項是Loopback device,RAM disk和i

nitrd,一定要選中。Default RAM disk size多少都沒有關系。

4.2.7 Multi-device support (RAID and LVM)

Multiple devices driver support (RAID and LVM)

<*> RAID support

<*> Linear (append) mode

<*> RAID-0 (striping) mode

<*> RAID-1 (mirroring) mode

<*> RAID-4/RAID-5 mode

<*> Multipath I/O support

<*> Logical volume manager (LVM) support

  MD支援。軟RAID和LVM的支援在這裡選擇,如果不使用,也可以不選。

4.2.8 Networking options

<*> Packet socket

Packet socket: mmapped IO

< > Netlink device emulation

Network packet filtering (replaces ipchains)

[ ] Network packet filtering debugging

Socket Filtering

<*> Unix domain sockets

TCP/IP networking

IP: multicasting

IP: advanced router

[ ] IP: policy routing

[ ] IP: equal cost multipath

[ ] IP: use TOS value as routing key

[ ] IP: verbose route monitoring

[ ] IP: large routing tables

IP: kernel level autoconfiguration

IP: DHCP support

IP: BOOTP support

IP: RARP support

<*> IP: tunneling

< > IP: GRE tunnels over IP

[ ] IP: multicast routing

[ ] IP: TCP Explicit Congestion Notification support

[ ] IP: TCP syncookie support (disabled per default)

IP: Netfilter Configuration --->

< > 802.1Q VLAN Support

---

< > The IPX protocol

< > Appletalk protocol support

Appletalk devices --->

< > DECnet Support

< > 802.1d Ethernet Bridging

QoS and/or fair queueing --->

Network testing --->

  網絡選項。這裡選項也比較多,如果沒有什麼特殊要求,又不是十分了解這些

選項的意義,基本上可以用預設設定。注意DHCP選項,如果要用到的話要記得選中

這個。

  IP: Netfilter Configuration(跟iptables有關)等幾個子選項都沒有選。

4.2.9 ATA/IDE/MFM/RLL support

<*> ATA/IDE/MFM/RLL support

IDE, ATA and ATAPI Block devices --->

<*> Enhanced IDE/MFM/RLL disk/cdrom/tape/floppy support

--- Please see Documentation/ide.txt for help/info on IDE drives

[ ] Use old disk-only driver on primary interface

<*> Include IDE/ATA-2 DISK support

Use multi-mode by default

Auto-Geometry Resizing support

<*> Include IDE/ATAPI CDROM support

< > Include IDE/ATAPI TAPE support

< > Include IDE/ATAPI FLOPPY support

<*> SCSI emulation support

[ ] IDE Taskfile Access

--- 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

[ ] Boot off-board chipsets first support

[ ] Force enable legacy 2.0.X HOSTS to use DMA

Use PCI DMA by default when available

[ ] Enable DMA only for disks

[ ] AEC62XX chipset support

[ ] ALI M15x3 chipset support

[ ] AMD Viper support

[ ] CMD64X and CMD680 chipset support

[ ] CY82C693 chipset support

[ ] Cyrix CS5530 MediaGX chipset support

[ ] HPT34X chipset support

[ ] HPT366/368/370 chipset support

Intel PIIXn chipsets support

PIIXn Tuning support

[ ] PROMISE PDC202{46|62|65|67|68|69|70} support

[ ] ServerWorks OSB4/CSB5 chipsets support

[ ] SiS5513 chipset support

[ ] SLC90E66 chipset support

[ ] VIA82CXXX chipset support

[ ] Other IDE chipset support

[ ] IGNORE word93 Validation BITS

  IDE裝置支援。要用IDE硬碟,當然要選中。CDROM選項看情況也可以不要。SCS

I emulation似乎對使用USB盤有影響。剩下的很多都是跟IDE chipset有關的。

  最好是用dmesg指令找出目标系統主機闆晶片組,然後選中對應的晶片組支援,這

樣相當于安裝了IDE晶片組的驅動程式。如果沒有指定應該也可以,隻是性能可能會

受到一些影響。

4.2.10 SCSI support

<*> SCSI support

--- SCSI support type (disk, tape, CD-ROM)

<*> SCSI disk support

(40) Maximum number of SCSI disks that can be loaded as modules

< > SCSI tape support

< > SCSI OnStream SC-x0 tape support

< > SCSI CD-ROM support

<*> SCSI generic support

--- Some SCSI devices (e.g. CD jukebox) support multiple LUNs

[ ] Enable extra checks in new queueing code

[ ] Probe all LUNs on each SCSI device

[ ] Verbose SCSI error reporting (kernel size +=12K)

[ ] SCSI logging facility

SCSI low-level drivers --->

  SCSI支援。如果要用到SCSI硬碟等SCSI裝置,這裡當然要選。目前我們的目标

系統其實沒有SCSI硬碟,但是為了使用USB盤,也要選中SCSI支援。

  SCSI low-level drivers子選項中是一些SCSI卡,都不用選。

4.2.11 Network device support

Network device support

ARCnet devices --->

< > Dummy net driver support

< > Bonding driver support

< > EQL (serial line load balancing) support

< > Universal TUN/TAP device driver support

Ethernet (10 or 100Mbit) --->

Ethernet (10 or 100Mbit)

EISA, VLB, PCI and on board controllers

<*> EtherExpressPro/100 support (eepro100, original Becker driv

er

<*> RealTek RTL-8139 PCI Fast Ethernet Adapter support

Ethernet (1000 Mbit) --->

[ ] FDDI driver support

< > PPP (point-to-point protocol) support

< > SLIP (serial line) support

Wireless LAN (non-hamradio) --->

Token Ring devices --->

[ ] Fibre Channel driver support

Wan interfaces --->

  網絡裝置支援。主要選擇網卡類型,Ethernet (10 or 100Mbit)子選項中列出

了核心可以支援的10/100M以太網卡,這裡僅列出了我們選中的2種。其他子選項都

沒有選。

4.2.12 Character devices

Virtual terminal

Support for console on virtual terminal

<*> Standard/generic (8250/16550 and compatible UARTs) serial suppo

rt

Support for console on serial port

[ ] Extended dumb serial driver options

[ ] Non-standard serial port support

[ ] Unix98 PTY support

I2C support --->

Mice --->

Joysticks --->

< > QIC-02 tape support

Watchdog Cards --->

< > AMD 768 Random Number Generator support

< > Intel i8x0 Random Number Generator support

< > AMD 76x native power management (Experimental)

< > /dev/nvram support

< > Enhanced Real Time Clock Support

< > Double Talk PC internal speech card support

< > Siemens R3964 line discipline

< > Applicom intelligent fieldbus card support

Ftape, the floppy tape device driver --->

< > /dev/agpgart (AGP Support)

[ ] Direct Rendering Manager (XFree86 DRI support)

< > ACP Modem (Mwave) support

  字元裝置。這裡主要就是選擇了最前面4個跟終端和序列槽有關的選項,以支援虛

拟終端(遠端登入要用到),支援标準序列槽,支援序列槽控制台。

4.2.13 File systems

Quota support

< > Kernel automounter support

<*> Kernel automounter version 4 support (also supports v3)

<*> Reiserfs support

[ ] Enable reiserfs debug mode

Stats in /proc/fs/reiserfs

<*> Ext3 journalling file system support

[ ] JBD (ext3) debugging support

<*> DOS FAT fs support

<*> MSDOS fs support

< > UMSDOS: Unix-like file system on top of standard MSDOS fs

<*> VFAT (Windows-95) fs support

< > Compressed ROM file system support

Virtual memory file system support (former shm fs)

<*> ISO 9660 CDROM file system support

Microsoft Joliet CDROM extensions

[ ] Transparent decompression extension

< > JFS filesystem support

< > Minix fs support

< > FreeVxFS file system support (VERITAS VxFS(TM) compatible)

< > NTFS file system support (read only)

< > OS/2 HPFS file system support

/proc file system support

< > QNX4 file system support (read only)

< > ROM file system support

<*> Second extended fs support

< > System V/Xenix/V7/Coherent file system support

< > UDF file system support (read only)

< > UFS file system support (read only)

Network File Systems --->

< > Coda file system support (advanced network fs)

<*> NFS file system support

Provide NFSv3 client support

[ ] Root file system on NFS

<*> NFS server support

Provide NFSv3 server support

<*> SMB file system support (to mount Windows shares etc.)

[ ] Use a default NLS

< > NCP file system support (to mount NetWare volumes)

Partition Types --->

Native Language Support --->

Default NLS Option: "iso8859-1"

<*> Codepage 437 (United States, Canada)

<*> Simplified Chinese charset (CP936, GB2312)

<*> Traditional Chinese charset (Big5)

  檔案系統。這部分内容比較多,也很重要。首先是Quota,如果目标系統支援這

個功能,這裡就要選中。然後是選擇要支援的檔案系統,常用的有Reiserfs,Ext3

,FAT,ISO9660,JFS等等,可以根據情況選擇。/proc和ext2一定要選中。

  還有Network File Systems子選項,可以選擇是否支援NFS和SMB。Native Lan

guage Support子選項跟所支援的語言有關,這裡沒有全部列出來,我們選中了英語

和簡體、繁體中文字元集。

4.2.14 Console drivers

VGA text console

[ ] Video mode selection support

  控制台驅動。調試的時候可以給目标系統接顯示器看一下,實際系統應該可以

不選。

4.2.15 USB support

<*> Support for USB

[ ] USB verbose debug messages

--- Miscellaneous USB options

Preliminary USB device filesystem

[ ] Long timeout for slow-responding devices (some MGE Ellipse UP

Se

--- USB Host Controller Drivers

<*> UHCI Alternate Driver (JE) support

<*> OHCI (Compaq, iMacs, OPTi, SiS, ALi, ...) support

--- USB Device Class drivers

< > USB MIDI support

<*> USB Mass Storage support

USB Mass Storage verbose debug

[ ] Freecom USB/ATAPI Bridge support

[ ] ISD-200 USB/ATA Bridge support

[ ] Microtech CompactFlash/SmartMedia support

< > USB Modem (CDC ACM) support

< > USB Printer support

--- USB Human Interface Devices (HID)

<*> USB Human Interface Device (full HID) support

--- Input core support is needed for USB HID input layer or HID

BP

[ ] /dev/hiddev raw HID device support

--- USB Imaging devices

< > USB Kodak DC-2xx Camera support

< > USB Scanner support

< > Microtek X6USB scanner support

--- USB Multimedia devices

--- Video4Linux support is needed for USB Multimedia device suppo

rt

--- USB Network adaptors

--- USB port drivers

USB Serial Converter support --->

--- USB Miscellaneous drivers

< > Texas Instruments Graph Link USB (aka SilverLink) cable suppo

rt

< > USB LCD device support

  USB支援。如果沒有使用USB裝置,這部分可以不選。要使用USB盤,一定要選中

USB Mass Storage support。其餘很多選項我也不清楚是幹什麼用的。

4.3 提示

4.3.1 EXTRAVERSION

  在系統中使用uname可以獲得系統版本資訊。比如Redhat 9:

[[email protected] root]# uname -r

2.4.20-8

[[email protected] root]#

  傳回結果表示了Redhat修訂後的核心版本号。前面我們提到過,這個“-8”就

是Redhat附加在标準核心版本号後面的一個資訊。

  在一個運作LiPS的系統中,我們也需要确定目前使用的核心版本,通過版本信

息來知道這個核心的配置,也可以通過在标準核心版本後面附加特定的編碼來實作

  /usr/src/linux-2.4/Makefile中的變量EXTRAVERSION可以幫助我們達到這個目

标。下面是Makefile檔案的最前面幾行内容:

VERSION = 2

PATCHLEVEL = 4

SUBLEVEL = 20

EXTRAVERSION = -8

KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)

  現在KERNELRELEASE的值就是2.4.20-8。這個資訊會被編譯到核心中,uname工

具會從核心檔案中提取出版本号。如果将Makefile做一些修改,比如,

EXTRAVERSION = -8-R2Lips

  那麼我們可以得到核心版本号2.4.20-8-R2Lips,表示為了建立LiPS而編譯的一

個特定配置的核心,這個核心是以2.4.20-8為基礎,R2Lips(Release 2 Lips)即

第二個版本。

  對Makefile的修改要在編譯核心之前完成。

4.3.2 .config

  核心配置(make menuconfig)完成之後,會詢問:

Do you wish to save your new kernel configuration?

< Yes > < No >

  回答Yes,配置資訊會儲存在/usr/src/linux-2.4/.config檔案中。注意以“.

”開頭的檔案是個隐藏檔案,要用ls –a才看的到。.config是個文本檔案,内容類

似下面:

#

# Loadable module support

#

CONFIG_MODULES=y

# CONFIG_MODVERSIONS is not set

CONFIG_KMOD=y

  是以可以把這個檔案儲存起來,并且給檔案名帶上版本号,友善管理、使用。

cp .config ~/config-2.4.20-8-R2Lips

繼續閱讀