Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux綜合 >> Linux 核心

CentOS 內核升級實錄:從 2.4 到 2.6 的完整配置清單

先說明:文中帶 # 的行都是在終端機中輸入的命令,全部操作都需要 root 權限。

一、準備工作

1. 確認目前版本

uname -a

顯示 2.6.x 就不必往下看了;若是 2.4.x,恭喜,可以繼續。

2. 下載 2.6 內核源碼
linux-2.6.18.tar.bz2 可從 kernel.org 的 v2.6 目錄取得。

3. 下載四個升級工具

module-init-tools-3.2.tar.bz2、mkinitrd-4.1.18-2.i386.rpm、lvm2-2.00.25-1.01.i386.rpm、device-mapper-1.00.19-2.i386.rpm,同樣來自 kernel.org 與 freshrpms 鏡像站。這四個缺一不可。

二、配置與安裝

4. 全部放進 /usr/src

5. 解壓新內核

cd /usr/src
rm -rf linux          # 若從未編譯過內核,此目錄不存在,可略過
tar jvxf linux-2.6.18.tar.bz2
ln -s linux-2.6.18 linux

6. 編譯 module-init-tools

cd /usr/src
tar jvxf module-init-tools-3.2.tar.bz2
cd module-init-tools-3.2
./configure --prefix=/
make moveold
make all install
./generate-modprobe.conf /etc/modprobe.conf

7. 安裝其餘三個工具(務必帶 --nodeps)

rpm -ivh --nodeps mkinitrd-4.1.18-2.i386.rpm
rpm -ivh --nodeps lvm2-2.00.25-1.01.i386.rpm
rpm -ivh --nodeps device-mapper-1.00.19-2.i386.rpm

不更新這幾個套件,後面 make install 會直接丟出 mkinitrd failed 的錯誤。

8. 設定內核選項

cd linux-2.6.18
make mrproper
make menuconfig

絕大多數選項保持預設即可,但以下幾項必須勾選,否則編譯很可能白忙一場:

1)Loadable Module support 中務必選上 Module unloading 與 Automatic kernel module loading。

2)Device Drivers → Block Devices 選 Loopback device support;Multi-device support (RAID and LVM) 中選 device mapper support;Graphics support 選 Support for frame buffer devices;USB support 選 USB Mass Storage support;Network device support → Ethernet (10 or 100Mbit) 選 AMD PCnet32 PCI support。

3)File system 中把 ext2 與 ext3 的九個選項全部選上:Second extended fs support、Ext2 extended attributes、Ext2 POSIX Access Control Lists、Ext2 Security Labels、Ext3 journalling file system support、Ext3 extended attributes、Ext3 POSIX Access Control Lists、Ext3 Security Labels、JBB (ext3) debugging support。另外 DOS/FAT/NT Filesystems 選 NTFS file system support,Miscellaneous filesystems 選 Compressed ROM file system support (cramfs)。

4)若在 VMware 下使用 SCSI 虛擬硬碟,還要選 SCSI disk support 與 SCSI low-level drivers 中的 BusLogic SCSI support。

最關鍵的一條警告

ext2/ext3 的支援不可等閒視之。若把對 Ext3、Ext2 的支援直接編進內核,重開機時機器會當掉,常見的錯誤訊息有:

kernel panic: no init found, try passing init= option to kernel
VFS: Cannot open root device "hdxy" or unknown-block(0,0)
Kernel panic: VFS: Unable to mount root fs on unknown-block(0,0)
mount: error 19 mounting ext3
Kernel panic - not syncing: No init found. Try passing init = option to kernel

我當時就是遇到第三種,開不了機,最後只能重裝。與其冒險,不如把 ext2/ext3 編為模組,讓 initrd 去掛載根檔案系統,穩妥得多。

Copyright © Linux教程網 All Rights Reserved