环境介绍:Centos5.2+2.6.18-8.el5内核,编译器是GCC4.1.2。
要编译的内核2.6.18-8.el3
仅仅修改了部分内核的配置信息,没有大的变化。
然后:make ;make modules;make modules_install;
编译没有出问题,生成了内核,mkinitrd生成了initrd,加到lilo.conf中,重启选择新内核,出现一下问题:
hub 3-0:1.0: USB hub found
hub 3-0:1.0: 2 ports detected
Scanning and configuring dmraid supported devices
Trying to resume from LABEL=SWAP-hdc4
No suspend signature on swap, not resuming.
Creating root device.
Mounting root filesystem.
mount: could notKernel panic - not syncing: Attempted to kill init!
find filesystem '/dev/root'
Setting up other filesystems.
Setting up new root fs
setuproot: moving /dev failed: No such file or directory
no fstab.sys, mounting internal defaults
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
Switching to new root and running init.
unmounting old /dev
unmounting old /proc
unmounting old /sys
switchroot: mount failed: No such file or directory
两者区别就是编译器版本一个是gcc3.4,一个是gcc4.1,后者编译通过,但是不能引导系统。
解决方法:
Here's the fix
After almost giving up on Fedora 5, I finally got the fix to this problem.
The suspend signature on swap error, "Trying to resume from LABEL=SWAP-hdd3. No suspend signature on swap, not resuming", can be ignored. It gives this error because when the volumes are activated (look at the output previous to this error), it resumes the swap partition in that step. Therefore, it's trying to resume something that isn't suspended.
The error that causes all the trouble is "mount: could not find filesystem '/dev/root'". Appartently, in the init script within initrd-2.6.15-1.2054_FC5.img, the command 'mount /sysroot' is trying to mount /dev/root to /sysroot. Fedora 5 does not use /dev/root like in the previous versions of Fedora. Instead, it uses '/dev/VolGroup00/LogVol00' or '/dev/hda1' (or whereever '/' is located) to mount to /sysroot. For some reason, when init calls 'mount /sysroot', it's trying to mount /dev/root to /sysroot, instead of /dev/VolGroup00/LogVol00 to /sysroot. This messes up everything after this step in the init process. When it does a switchroot at the end, it fails. After killing init, it causes the kernel panic.
Here's the fix:
1) Boot with the rescue CD
2) Type 'chroot /mnt/sysimage' (wherever it mounts the Fedora 5 partition)
3) 'cd /boot'
4) 'mkdir newinit'
5) 'cd newinit'
6) 'gunzip -c ../initrd-2.6.31.6.img | cpio -idmv '
7) 'vi init'
8) Find 'mount /sysroot' (near the end of the file)
9) Delete or comment this out
10) Replace with 'mount -o defaults --ro -t ext3 /dev/VolGroup00/LogVol00 /sysroot' where /dev/VolGroup00/LogVol00 is the mount point for /
11) ':wq' out of vi
12) 'find . | cpio --quiet -c -o >../newinitrd '
13) 'cd ..' - you are now in /boot
14) 'mv initrd-2.6.31.6.img initrd-2.6.31.6.img.bak' - backup current initrd img file (just in case)
15) gzip -9 < newinitrd >initrd-2.6.31.6.img
16) Reboot the computer without the CD
* Steps 4-6,12,13,15 were taken from another site, but I couldn't post the URL. I'll try in my next post.
This should fix it. I'm glad I can finally run Fedora 5 on my box.
MarkCole, I'm not sure if you were experiencing the exact same problems I was with mounting root. However, I hope this helps anyone else experiencing the same problems I had.
Cent OS 5.4(2.6.18-164.el5)升级到2.6.31出错
重启时崩溃,提示错误,键盘上的灯还不停的闪,旧内核可以启动。
Red Hat nash version 5.1.19.6 starting
insmod : error inserting '/lib/dm-region-hash.ko' : -1 File exists
Reading all physical volumes. This may take a while...
Volume gruop "VolGroup00" not found
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
setuproot: mount failed: No such file or directory
Kernel panic - not syncing: Attempted to kill init!
insmod: error inserting '/lib/dm-region-hash.ko' : -1 File exists
---------------------------------------------------------------------------
[root@ljj ljj]# cd /boot
[root@ljj boot]# cp initrd-2.6.31.img ~/ #查到说是BUG,拷贝initrd到另一处
[root@ljj ~]# mkdir initrd31
[root@ljj ~]# cd initrd31
[root@ljj initrd31]# ll
总计 0
[root@ljj initrd31]# zcat ../initrd-2.6.31.img | cpio -i #解开这个包进行检查
10999 blocks
[root@ljj initrd31]# ll
总计 32
drwx------ 2 root root 4096 09-13 21:38 bin
drwx------ 3 root root 4096 09-13 21:38 dev
drwx------ 2 root root 4096 09-13 21:38 etc
-rwx------ 1 root root 2135 09-13 21:38 init
drwx------ 3 root root 4096 09-13 21:38 lib
drwx------ 2 root root 4096 09-13 21:38 proc
lrwxrwxrwx 1 root root 3 09-13 21:38 sbin -> bin
drwx------ 2 root root 4096 09-13 21:38 sys
drwx------ 2 root root 4096 09-13 21:38 sysroot
[root@ljj initrd31]#vi init
1 #!/bin/nash
2
3 mount -t proc /proc /proc
4 setquiet
5 echo Mounting proc filesystem
6 echo Mounting sysfs filesystem
7 mount -t sysfs /sys /sys
8 echo Creating /dev
9 mount -o mode=0755 -t tmpfs /dev /dev
10 mkdir /dev/pts
11 mount -t devpts -o gid=5,mode=620 /dev/pts /dev/pts
12 mkdir /dev/shm
13 mkdir /dev/mapper
14 echo Creating initial device nodes
15 mknod /dev/null c 1 3
16 mknod /dev/zero c 1 5
17 mknod /dev/systty c 4 0
18 mknod /dev/tty c 5 0
19 mknod /dev/console c 5 1
20 mknod /dev/ptmx c 5 2
21 mknod /dev/rtc c 10 135
22 mknod /dev/tty0 c 4 0
23 mknod /dev/tty1 c 4 1
24 mknod /dev/tty2 c 4 2
25 mknod /dev/tty3 c 4 3
26 mknod /dev/tty4 c 4 4
27 mknod /dev/tty5 c 4 5
28 mknod /dev/tty6 c 4 6
29 mknod /dev/tty7 c 4 7
30 mknod /dev/tty8 c 4 8
31 mknod /dev/tty9 c 4 9
32 mknod /dev/tty10 c 4 10
33 mknod /dev/tty11 c 4 11
34 mknod /dev/tty12 c 4 12
35 mknod /dev/ttyS0 c 4 64
36 mknod /dev/ttyS1 c 4 65
37 mknod /dev/ttyS2 c 4 66
38 mknod /dev/ttyS3 c 4 67
39 echo Setting up hotplug.
40 hotplug
41 echo Creating block device nodes.
42 mkblkdevs
43 echo "Loading ehci-hcd.ko module"
44 insmod /lib/ehci-hcd.ko
45 echo "Loading ohci-hcd.ko module"
46 insmod /lib/ohci-hcd.ko
47 echo "Loading uhci-hcd.ko module"
48 insmod /lib/uhci-hcd.ko
49 mount -t usbfs /proc/bus/usb /proc/bus/usb
50 echo "Loading jbd.ko module"
51 insmod /lib/jbd.ko
52 echo "Loading ext3.ko module"
53 insmod /lib/ext3.ko
54 echo "Loading scsi_mod.ko module"
55 insmod /lib/scsi_mod.ko
56 echo "Loading sd_mod.ko module"
57 insmod /lib/sd_mod.ko
58 echo "Loading libata.ko module"
59 insmod /lib/libata.ko
60 echo "Loading ata_piix.ko module"
61 insmod /lib/ata_piix.ko
62 echo "Loading dm-mod.ko module"
63 insmod /lib/dm-mod.ko
64 echo "Loading dm-log.ko module"
65 insmod /lib/dm-log.ko
66 echo "Loading dm-region-hash.ko module"
67 insmod /lib/dm-region-hash.ko
68 echo "Loading dm-region-hash.ko module"
69 insmod /lib/dm-region-hash.ko
70 echo Waiting for driver initialization.
71 stabilized --hash --interval 1000 /proc/scsi/scsi
72 mkblkdevs
73 echo Scanning and configuring dmraid supported devices
74 resume /dev/hda4
75 echo Creating root device.
76 mkrootdev -t ext3 -o defaults,ro hda3
77 echo Mounting root filesystem.
78 mount /sysroot
79 echo Setting up other filesystems.
80 setuproot
81 echo Switching to new root and running init.
82 switchroot
将66、67和68、69这两对重复的删去一对,我是把66和67这两行dd掉了。其它还有什么错吗?不知道
---------------------------------------------------------------------------
重新打包Initrd,起个新名字叫initrd-2.6.31new,有5兆多
[root@ljj initrd31]# find . | cpio -c -o > ../initrd-2.6.31new
11000 blocks
[root@ljj initrd31]# cd ..
[root@ljj ~]# ll
总计 8048
-rw------- 1 root root 1660 08-27 00:30 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 08-27 14:32 Desktop
-rw------- 1 root root 2507281 09-13 21:35 initrd-2.6.31.img
-rw-r--r-- 1 root root 5632000 09-13 21:58 initrd-2.6.31new
drwxr-xr-x 9 root root 4096 09-13 21:56 initrd31
-rw-r--r-- 1 root root 39511 08-27 00:30 install.log
-rw-r--r-- 1 root root 5712 08-27 00:27 install.log.syslog
-rw-r--r-- 1 root root 702 09-08 13:29 scsrun.log
-------------------------------------------------------------------
压缩这个镜像,变2兆多了
[root@ljj ~]# gzip -9 < initrd-2.6.31new > initrd-2.6.31new.img
[root@ljj ~]# ll
总计 10504
-rw------- 1 root root 1660 08-27 00:30 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 08-27 14:32 Desktop
-rw------- 1 root root 2507281 09-13 21:35 initrd-2.6.31.img
-rw-r--r-- 1 root root 5632000 09-13 21:58 initrd-2.6.31new
-rw-r--r-- 1 root root 2507271 09-13 22:02 initrd-2.6.31new.img
drwxr-xr-x 9 root root 4096 09-13 21:56 initrd31
-rw-r--r-- 1 root root 39511 08-27 00:30 install.log
-rw-r--r-- 1 root root 5712 08-27 00:27 install.log.syslog
-rw-r--r-- 1 root root 702 09-08 13:29 scsrun.log
------------------------------------------------------------------
把名字改回去
[root@ljj ~]# rm initrd-2.6.31.img
rm:是否删除 一般文件 “initrd-2.6.31.img”? y
[root@ljj ~]# rm initrd-2.6.31new
rm:是否删除 一般文件 “initrd-2.6.31new”? y
[root@ljj ~]# mv initrd-2.6.31new.img initrd-2.6.31.img
[root@ljj ~]# ll
总计 2536
-rw------- 1 root root 1660 08-27 00:30 anaconda-ks.cfg
drwxr-xr-x 2 root root 4096 08-27 14:32 Desktop
-rw-r--r-- 1 root root 2507271 09-13 22:02 initrd-2.6.31.img
drwxr-xr-x 9 root root 4096 09-13 21:56 initrd31
-rw-r--r-- 1 root root 39511 08-27 00:30 install.log
-rw-r--r-- 1 root root 5712 08-27 00:27 install.log.syslog
-rw-r--r-- 1 root root 702 09-08 13:29 scsrun.log
-----------------------------------------------------------------
覆盖回去,再重启试试
[root@ljj ~]# mv initrd-2.6.31.img /boot
mv:是否覆盖“/boot/initrd-2.6.31.img”? y
[root@ljj ~]#reboot
重启后没有dm-region-hash.ko错误了(上面错误无关紧要,不影响系统启动),但还是起不来,提示
system bootup error: could not find filesystem /dev/root
也找不到/proc和/sys
在最近的2.6.33内核编译升级时,也出现“mount: could not find filesystem '/dev/root'”提示,最后找到问题所在,要设置.config文件:
CONFIG_SYSFS_DEPRECATED_V2=Y
具体位置,可以在make menuconfig时使用查找功能,查找
CONFIG_SYSFS_DEPRECATED_V2会有提示在什么配置节设置:
Symbol: SYSFS_DEPRECATED_V2 [=y]
Prompt: enable deprecated sysfs features to support old userspace tools
Defined at init/Kconfig:627
Depends on: SYSFS [=y]
Location:
-> General setup
Selects: SYSFS_DEPRECATED [=y]
即
General setup
--> [*] enable deprecated sysfs features to support old userspace tools