Linux Kernel 2.6.37.2内核编译实战(2)

mount: could not find filesystem ‘/dev/root’
setuproot: moving /dev failed: No such file or directory
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
switchroot: mount failed: No such file or directory

#make dep 建立编译时需要的从属文 件,没有编译过的代码可以跳过

#make clean 这里也可以跳过

#make

漫长的等待中...

#make modules (编译模块)

#make modules_install

#make install(安装内核)

[root@localhost linux-2.6.37.2]# make install
sh /usr/src/kernels/linux-2.6.37.2/arch/x86/boot/install.sh 2.6.37.2 arch/x86/boot/bzImage \
                System.map "/boot"

4.把新镜像文件放到tmp中

# cp /boot/initrd-2.6.37.2.img /tmp

在tmp中新建一个文件夹

# mkdir /tmp/newinitrd

# cd /tmp/newinitrd

然后解压initrd-2.6.37.2.img到newinitrd文件夹

[root@localhost newinitrd]# zcat ../initrd-2.6.37.2.img | cpio -i
11260 blocks
[root@localhost newinitrd]# ls
bin  dev  etc  init  lib  proc  sbin  sys  sysroot

用vim修改init文件

其中:

echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko
echo "Loading dm-region-hash.ko module"
insmod /lib/dm-region-hash.ko

删去重复的两行,不然启动会echo这个错误!

重新打包镜像

[root@localhost newinitrd]# find . | cpio -c -o > ../initrd-2.6.37.2_new.img
11260 blocks

然后把新的镜像文件移动到/boot

[root@localhost newinitrd]# mv ../initrd-2.6.37.2_new.img /boot
修改/boot/grub/grub.conf

#boot=/dev/sda
default=1    #改为0
timeout=15
splashimage=(hd0,7)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.37.2)
        root (hd0,7)
        kernel /vmlinuz-2.6.37.2 ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.37.2.img         #改为initrd /initrd-2.6.37.2_new.img
title Red Hat Enterprise Linux Server (2.6.18-164.el5)
        root (hd0,7)
        kernel /vmlinuz-2.6.18-164.el5 ro root=LABEL=/ rhgb quiet
        initrd /initrd-2.6.18-164.el5.img
title Other
        rootnoverify (hd0,1)
        chainloader +1

5.重新启动

#reboot

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

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