- 论坛徽章:
- 0
|
Linux kernel 2.4.20升级到Linux kernel 2.6.17
环境: 主操作系统windows xp vmware5.5
虚拟操作系统redhat linux 9 kernel 2.4.20 虚拟硬盘是scsi的
安装module-init-tools-3.2.tar.gz.
下载地址:http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/
# pwd
/usr/src/
# tar zxvf module-init-tools-3.2.tar.gz
# cd module-init-tools-3.2
# ./configure --prefix=/
# make moveold
# make all install
# ./generate-modprobe.conf /etc/modprobe.conf
安装hotplug-ng-002.tar.gz
如果没有此工具,则USB鼠标即使在启动显示ok 加载上了也不能用
下载地址:http://www.kernel.org/pub/linux/utils/kernel/hotplug/
# pwd
/usr/src/
# tar zxvf hotplug-ng-002.tar.gz
# cd hotplug-ng-002
# make install
安装linux-2.6.17.tar.bz2
下载地址:http://www.kernel.org/pub/linux/kernel/v2.6/
# pwd
/usr/src/
# tar xvfj linux-2.6.17.tar.bz2
# cd linux-2.6.17
#make menuconfig
关于"Loadable Module support"选项, 一定要把"Module unloading"和"Automatic kernel module loading"这两个选项编译进内核。
关于"Block Devices"的配置, 一定要选上对loopback和ramdisk的支持,编译进内核。
注意,如果你在vmware下重新编译内核,硬盘用的是scsi的,以下选项必选:
Device Drivers --->SCSI device support ---><*> SCSI disk support
Device Drivers --->SCSI device support --->SCSI low-level drivers ---> <*> BusLogic SCSI support
关于“File system”ext2和ext3文件系统配置为: (全部选择)
File systems --->
<*>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
<*>JBD (ext3) debugging support
注意:
如果你是ext3文件系统,则在定制内核配置文件时把对Ext3、Ext2文件的支持直接编译进内核,否则,等你启用新内核时机器就会当掉,出错信息如下:
VFS: Cannot open root device "LABEL=/" or 0.0
Please append a correct "root=" boot option
kernel panic: VFS: Unable to mount root fs
把对Ext3、Ext2文件系统的支持直接编译进内核,可解决此问题,还有把对“Module unloading“选项也选上(*),否则的话,你在新内核环境下将无法卸载
内核模块(rmmod命令不能用)。
其它选项,我都采用默认的。
# make dep (编译2.6内核无需此步骤)
# make -jn (n代表同时编译的进程,可以加快编译速度,n由你的配置决定。)
# make bzImage
# make modules
# make modules_install (安装内核模块到/lib/modules/2.x.x下)
# make install (完成mkinitrd命令及内核(bzImage)和System.map的拷贝)
这里如果出现 "NO MODULE BUSLOGIC FOUND",
解决方法第1种方法:
编辑文件 /etc/modules.conf
将"alias scsi hostadapter BusLogic"这行注释掉,
即#alias scsi hostadapter BusLogic
保存 /etc/modules.conf,退出
第2种方法:
手动添加启动项
#depmod -a
#cp /usr/src/linux/System.map /boot/System.map-2.6.17
#cp /usr/src/linux/arch/i386/bzImage /boot/vmlinuz-2.6.17
支持Hotplug
当然, 首先要在内核配置时配置了HOTPLUG的支持. 然后, 由于/proc/ksyms改名为/proc/kallsyms, 所以必需修改启动脚本/etc/rc.sysinit. 为了兼容原有的linux-2.4.x系统, 可以加上下面几行:
#
# ----- KERNEL 2.6.x support ------
# This is for compatibility between kernel-2.4.x and kernel-2.6.x
#
UNAME=`uname -r`
KERNELVER=${UNAME:0:3}
if [ "$KERNELVER" = "2.6" ]; then
#
# This is kernel-2.6.x
#
KSYMS=/proc/kallsyms
else
#
# This is kernel-2.4.x
#
KSYMS=/proc/ksyms
fi
然后, 把rc.sysinit文件中所有出现/proc/ksyms的地方都换成"$KSYMS"变量引用。
Sysfs问题
首先, 创建目录/sys:
# mkdir /sys
然后, 按照下列步骤修改启动脚本/etc/rc.sysinit文件:
找到行: mount -f /proc", 在下面增加:
if [ "$KERNELVER" = "2.6" ]; then
mount -f /sys
fi
找到行: action $"Mounting proc filesystem: " mount -n -t proc /proc /proc, 在其下面增加这样一行:
#
# Mount /sys for kernel-2.6.x
#
if [ "$KERNELVER" = "2.6" ]; then
action $"Mounting sysfs filesystem: " mount -n -t sysfs /sys /sys
fi
接下来, 在/etc/fstab文件中, 加入这样一行:
none /sys sysfs defaults 0 0
最后, 修改/etc/init.d/halt脚本中的halt_get_remaining函数:
将:
awk '$2 ~ /^\/$|^\/proc|^\/dev/{next}
改为:
awk '$2 ~ /^\/$|^\/proc|^\/sys|^\/dev/{next}
支持USB设备
linux-2.6.x的USB驱动模块的名字已经改变了, 所以由此引起的问题多多......, 对应于USB-2.0的host控制器的内核模块名字仍然是ehci-hcd, 对应USB-1.1的host控制器的内核模块名字已经从usb-ohci改为ochi-hcd, 对应于通用USB host控制器的内核模块名字已经从usb-uhci该为uhci-hcd.
然而不幸的是, 在安装module-init-tools程序包时生成的/etc/modprobe.conf配置文件却仍然使用usb-ohci这个名字. 例如:
alias usb-controller usb-ohci
alias usb-controller1 ehci-hcd
因此, 要把它改为:
alias usb-controller ohci-hcd
alias usb-controller1 ehci-hcd
如果不做这样的修改, 那么使用USB-1.1 host控制器的机器在启动内核的时候将着不到相应的驱动模块.
支持USB键盘的模块名字也从keybdev变为usbkbd, 支持USB鼠标的模块名字也从mousedev改为usbmouse. 因此, 我们必需修改启动脚本/etc/rc.sysinit文件. 同时为了兼容原有的2.4.x系统, 我们在脚本的一开始定义两个变量:
#
# ----- KERNEL 2.6.x support ------
# This is for compatibility between kernel-2.4.x and kernel-2.6.x
#
UNAME=`uname -r`
KERNELVER=${UNAME:0:3}
if [ "$KERNELVER" = "2.6" ]; then
#
# This is kernel-2.6.x
#
KSYMS=/proc/kallsyms
KEYBDEV_NAME=usbkbd
MOUSEDEV_NAME=usbmouse
else
#
# This is kernel-2.4.x
#
KSYMS=/proc/ksyms
KEYBDEV_NAME=keybdev
MOUSEDEV_NAME=mousedev
fi
然后, 把/etc/rc.sysinit脚本文件中出现keybdev和mousedev的地方都改为$KEYBDEV_NAME和$MOUSEDEV_NAME. 把脚本文件/etc/rc.sysinit中的needusbstorage部分从:
needusbstorage=
if [ $usb = "1" ]; then
needusbstorage=`LC_ALL=C grep -e "^I.*Cls=08" /proc/bus/usb/devices 2>/dev/null`
LC_ALL=C grep 'hid' /proc/bus/usb/drivers || action $"Initializing USB HID interface: " modprobe hid 2> /dev/null
action $"Initializing USB keyboard: " modprobe $KEYBDEV_NAME 2> /dev/null
action $"Initializing USB mouse: " modprobe $MOUSEDEV_NAME 2> /dev/null
fi
改为:
needusbstorage=
if [ $usb = "1" ]; then
if [ "$KERNELVER" = "2.6" ]; then
needusbstorage=`LC_ALL=C grep -e "^I.*Cls=08" /sys/bus/usb/devices 2>/dev/null`
LC_ALL=C grep 'hid' /sys/bus/usb/drivers || action $"Initializing USB HID interface: " modprobe hid 2> /dev/null
else
needusbstorage=`LC_ALL=C grep -e "^I.*Cls=08" /proc/bus/usb/devices 2>/dev/null`
LC_ALL=C grep 'hid' /proc/bus/usb/drivers || action $"Initializing USB HID interface: " modprobe hid 2> /dev/null
fi
action $"Initializing USB keyboard: " modprobe $KEYBDEV_NAME 2> /dev/null
action $"Initializing USB mouse: " modprobe $MOUSEDEV_NAME 2> /dev/null
fi
然后重启机器。
# reboot
RPM问题
进入编译好的内核后,与RPM相关的命令有些不能使用,并出现下列错误:
rpmdb: unable to join the environment
error: db4 error(11) from dbenv->open: Resource temporarily unavailable
error: cannot open Packages index using db3 - Resource temporarily unavailable (11)
error: cannot open Packages database in /var/lib/rpm
no packages
解决方法是执行
#export LD_ASSUME_KERNEL=2.2.25 |
|