科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道Linux基础知识:内核编译-2.4至2.6 (3)

Linux基础知识:内核编译-2.4至2.6 (3)

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

找到行: action $"Mounting proc filesystem: " mount -n -t proc /proc /proc, 在其下面增加这样一行:

作者:Rongkai Zhan(LinuxSir.Org) 来源:赛迪网技术社区 2007年11月1日

关键字: 编译 内核 基础 Linux

  • 评论
  • 分享微博
  • 分享邮件
 

7. 体验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

8. 支持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 usbhid 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

好了, 到此为止, 我们应该可以重新启动机器了, 赶快去体验最新的kernel-2.6.4吧:-)

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章