Fedora平台上怎样编译构建一个自定义内核(4)

2.7 安装新内核
    现在去新的rpm内核包存在的目录(基于你的平台类型, 比如. ~/rpmbuild/RPMS/i386/)安装rpm包:
cd ~/rpmbuild/RPMS/i386
rpm -ivh kernel-2.6.18custom2.6.18.2-1.i386.rpm

(现在你甚至能够拷贝到其它的Fedora系统, 通过上面的方式安装. 你将不再需要编译内核.)

接下来我们为新内核创建一个ramdisk, 否则系统将不能引导新内核:
mkinitrd /boot/initrd-2.6.18-custom-2.6.18.2.img 2.6.18-custom-2.6.18.2

然后编辑/boot/grub/menu.lst文件, 看一下你系统上已经存在(正在工作的)引导内核信息, 拷贝其中的一个实例, 替换为你新的内核和ramdisk:
vi /boot/grub/menu.lst

比如, 我的menu.lst, 在我添加新的内核信息前的情况:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,0)
kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-1.2798.fc6.img

修改后的情况:

# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu

title Fedora Core (2.6.18-custom-2.6.18.2)
root (hd0,0)
kernel /vmlinuz-2.6.18-custom-2.6.18.2 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-custom-2.6.18.2.img

title Fedora Core (2.6.18-1.2798.fc6)
root (hd0,0)
kernel /vmlinuz-2.6.18-1.2798.fc6 ro root=/dev/VolGroup00/LogVol00
initrd /initrd-2.6.18-1.2798.fc6.img

(你可以通过下面命令发现正确的vmlinuz和initrd文件:
ls -l /boot
)

现在重启系统:
shutdown -r now

如果一切进展顺利, 你的新内核正常工作. 你还可以通过运行下面命令来检查新内核是否运行:
uname -r

这将会显示如:
2.6.18-custom-2.6.18.2

如果系统没有起来, 重启一下, 你会看到:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzwjgy.html