现在的位置: 首页 > 综合 > 正文

VMware(虚拟机下)Linux2.4.30升级到2.6.0的记录

2013年10月23日 ⁄ 综合 ⁄ 共 5086字 ⁄ 字号 评论关闭

软件环境:
主系统:XP系统
主系统安装:Thunder5.8.7.625.exe(用于下载文件),FlashFXP_3.6.0.1240_SC.exe(FTP工具),UltraEdit_11.10b_SC.exe(在windows下查看linux下的文件)
虚拟机软件版本:VMware workstation 5.0
虚拟机内安装的操作系统:Linux 2.4.20-8 (Red Hat)

需要下载的文件:

Linux-2.6.0.tar.gz
下载地址:http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.0.tar.gz

module-init-tools-3.2-pre9.tar.gz
下载地址:http://www.kernel.org/pub/linux/utils/kernel/module-init-tools/module-init-tools-3.2.tar.gz

mkinitrd-3.5.14-1-i386.rpm
下载地址:ftp://ftp.mbl.is/pub/fedora/1/i386/os/Fedora/RPMS/mkinitrd-3.5.14-1.i386.rpm
ftp://ftp.mbl.is/pub/fedora/1/i386/os/Fedora/RPMS/mkinitrd-3.5.15.1-2.i386.rpm

1、重新编译内核。
下载Linux内核,版本号为2.6.0,解压缩后置于/usr/src/linux目录下。
具体步骤如下:
a、从网站下载内核(Linux-2.6.0.tar.gz),mkinitrd-3.5.14-1-i386.rpm和module-init-tools-3.2-pre9.tar.gz

b、启动虚拟机

c、通过网络访问或共享文件夹方式,将Linux-2.6.0.tar.gz,mkinitrd-3.5.14-1-i386.rpm,module-init-tools-3.2-pre9.tar.gz拷贝到Linux系统下
共享文件的位置/mnt/hgfs
d、解压内核

# cp module-init-tools-3.2.tar.gz /usr/src
# cp linux-2.6.0.tar.gz /usr/src
# cp mkinitrd-3.5.14-1.i386.rpm /usr/src
# cd /usr/src
# tar zxvf module-init-tools-3.2.tar.gz
# tar zxvf linux-2.6.0.tar.gz
# rpm -Uvh mkinitrd-3.5.14-1.i386.rpm
# rpm -qa|grep initrd
mkinitrd-3.5.14-1-i386
# cd module-init-tools-3.2
# ./configure --prefix=/
# make moveold
# make
# make install
# cd ..
# ln -s  linux-2.6.0 linux

e、编译内核
# cd /usr/src/linux
# make mrproper (该命令可确保源代码目录下没有不正确的.o文件)
# make menuconfig (配置内核各选项)

几个重要的配置:
* 关于"Code maturity level options"选项, 一定要选上"Prompt for development and/or incomplete code/drivers"
* 关于"Loadable Module support"选项, 一定要选上"Module unloading"和"Automatic kernel module loading"这两个选项.
* 关于"Processor type and features"选项, 一定要选上"Preemptible Kernel"选项, 这是2.6.x内核优于2.4.x内核的重要原因之一.
* 关于"Device Drivers -->Block Devices"的配置, 一定要选上对"Loopback device support"和"Ramdisk support"的支持.
* 关于"Device Drivers -->Multi-device support(RAID and LVM)", 要选上"Device mapper support".
* 关于"Device Drivers -->Input device support", 记得要选上"Keyboards,Sun XT Newton"和"Mice"的支持.
* 关于"Device Drivers -->Graphics support -->Console display driver support", 要选上对"Framebuffer Console support"的支持.
* 关于"Sound -->Sound card support,Advanced Linux Sound Architecture -->"ALSA, 要选上"OSS API emulation"选项. OSS可以不用了.
* 关于USB, 能选的都选上吧,能*的选*,M的选M
* 文件系统 ,请务必要选中ext3文件系统,
File systems--->
[*] Ext3 journalling file system support
[*] Ext3 Security Labels
[*] JBD (ext3) debugging support
以上三项一定要选上,而且要内建(即标*). 这个非常重要,在配置完后一定要检查一下.config文件有没有"CONFIG_EXT3_FS=y"这一项. 如果不是"CONFIG_EXT3_FS=y"而是"CONFIG_EXT3_FS=m",你在运行内核时就会遇上以下错误: pivotroot: pivot_root(/sysroot,/sysroot/initrd) failed

* 网卡驱动
请务必把自己网卡对应的驱动编译进内核,比较普遍的网卡是realtek 8139,以下就是这种网卡的配置,以供参考
Device Drivers--->
Networking support--->
Ethernet (10 or 100Mbit) --->
<*> Ethernet (10 or 100Mbit)
<*> RealTek RTL-8139 C+ PCI Fast Ethernet Adapter support (EXPERIMENTAL)
<*> RealTek RTL-8139 PCI Fast Ethernet Adapter support
<*> AMD PCInet32 PCI support

* 声卡驱动
也要选择自己声卡对应的驱动编译进内核,比较普遍的声卡是i810_audio,以下就是这种声卡的配置,以供参考
Device Drivers --->
Sound --->
<*> Sound card support
Advanced Linux Sound Architecture --->
<*> Advanced Linux Sound Architecture
<*> Sequencer support
< > Sequencer dummy client
<*> OSS Mixer API
<*> OSS PCM (digital audio) API[*] OSS Sequencer API
<*> RTC Timer support
PCI devices --->
<*> Intel i8x0/MX440, SiS 7012; Ali 5455; NForce Audio; AMD768/8111
Open Sound System --->
< > Open Sound System (DEPRECATED)

*Ramdisk大小
Device Drivers --->Block device->Default Ramdisk的大小应为1024的整数倍。默认值为4096,我们改为12288。

注意,如果用vmware进行编译,那么需要注意一些地方:
如果你在vmware下重新编译内核,硬盘用的是scsi的,以下选项必选:
Device Drivers  --->SCSI device support  ---> <*>  SCSI disk support
Device Drivers  --->SCSI device support  --->SCSI low-level drivers  ---> <*> BusLogic SCSI support

# make dep (建立编译时所需的从属文件。注意:如果内核从未编译过,此步可跳过)
# make clean  (清除内核编译的目标文件。注意:如果内核从未编译过,此步可跳过)
# make bzImage
# make modules
# make modules_install

# gedit /etc/modules.conf
将"alias scsi hostadapter BusLogic"这行注释掉,
即#alias scsi hostadapter BusLogic
保存 /etc/modules.conf,退出

# grub-install /dev/sda

# make install

我使用的grub启动系统,那么将 /boot/grub/grub.conf 中 linux2.6域中
kernel /vmlinux-2.6.0 项后面的" ro root=LABEL=/" 改成"ro root=/dev/sda1"这个参数去掉,然后就可以用了
#cd /boot/grub
#vi grub.conf
然后进行相应的修改。

#reboot
之后选择升级后的2.6内核的启动。

如果现在重启就会出现:
错误:VFS:cannot open root device "XXXX"or 00:00
错误的解决办法是:
将Grub.conf中"root=LABEL=/"改为"root=/dev/sda1"。

运行新内核之前,请检查一下/boot/grub/grub.conf的内容,下面的配置可作参考

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You do not have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /, eg.
#          root (hd0,0)
#          kernel /boot/vmlinuz-version ro root=/dev/sda1
#          initrd /boot/initrd-version.img
#boot=/dev/sda
default=1
timeout=10
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
title Red Hat Linux (2.6.0)
root (hd0,0)
kernel /boot/vmlinuz-2.6.0 ro root=/dev/sda1
initrd /boot/initrd-2.6.0.img
title Red Hat Linux (2.4.20-8)
root (hd0,0)
kernel /boot/vmlinuz-2.4.20-8 ro root=LABEL=/
initrd /boot/initrd-2.4.20-8.img

然后编辑启动配置文件,重新启动系统,在启动时选择新的内核。

RAMDISK: incomplete write (ramdisk too small?) (-28 != 32768)表示ramdisk太小了,要修改内核中ramdisk的大小。ramdisk的大小:->block 的device->Default Ramdisk的大小应为1024的整数倍。默认值为4096,我们改为12288。
Kernel panic: VFS: Unable to mount root fs on unknown-block(0,0)

如果你是ext3文件系统,则在定制内核配置文件时把对Ext3、Ext2文件的支持直接编译进内核,否则,等你启用新内核时机器就会当掉,出错信息如下:kernel panic : no init found ,try passing init = option to kernel......或者是:kernel panic:VFS:Unable to mount root fs on unknown-block(0,0),我一开始不知道,编译了好几次,系统总给我冷板凳坐,最后把对Ext3、Ext2文件系统的支持直接编译进内核,才解决此问题,还有把对“Module unloading“选项也选上,否则的话,你在新内核环境下无法卸载内核模块(rmmod命令不能用)。

抱歉!评论已关闭.