+ -
当前位置:首页 → 问答吧 → [已解决]Grub启动-Error 2: Bad file or directory type<求助>

[已解决]Grub启动-Error 2: Bad file or directory type<求助>

时间:2009-02-14

来源:互联网

在ubuntu下安装Gentoo,安装过程一切正常.修改的是ubuntu的menu.lst,启动提示grub 2号错误.
安装过程倒不难,现被卡在这里,请大家帮忙!谢谢!

menu.lst内容:
title Gentoo Linux 2.6.27-r8
root (hd0,11)
kernel /boot/kernel-2.6.27-gentoo-r8 root=/dev/sda12 ro

title Debian GNU/Linux, kernel 2.6.27-11-generic
root (hd0,8)
kernel /boot/vmlinuz-2.6.27-11-generic root=UUID=0831f4db-27d6-40fa-a1f8-a5ca086980cf ro quiet splash locale=zh_CN
initrd /boot/initrd.img-2.6.27-11-generic
boot

ubuntu启动正常, 我确认(hd0,11)/boot/kernel-2.6.27-gentoo-r8是存在的。
Google了很多没找到合适方法(可能心急吧!)
我修改:kernel /boot/kernel-2.6.27-gentoo-r8 root=/dev/sda12 ro
这行内容不止十次了,电脑重启也不止十次,没法解决,问题是否出在内核(怎么确认内核是否有问题)?
Btw, 这个问题可能很简单,知道怎么解决的兄弟麻烦告诉我详细过程,新手,请不见笑!^_^

作者: kentty   发布时间: 2009-02-14

1.看看你的/boot文件系统类型,在内核里面是否已经被选择支持了。 如果ex2默认好像是不支持的。需要手工选择。
另外,你可以在grub报错后,可以在grub里面手工输入来选择你的boot分区。方法是进入grub命令提示下,然后kernel (hd0,按<tab> 就会有提示, 这样就知道你是否配置grub.conf(menu.lst)是否有错了。

作者: dutongtie   发布时间: 2009-02-14

/boot没有单独分开,文件系统类型是ext3,内核配置时ext2,ext3都选上了支持的。
grub安装是正常的,开机报错后提示:
“Error 2:Bad file or directory type
press any key to continue ...”
在grub命令提示下?--我现在重启进去看看!谢谢!

作者: kentty   发布时间: 2009-02-14

http://www.linuxplanet.com/linuxplan...orials/6480/1/

楼主可以参考一下这个~

好像是由于ext3和e2fsprogs造成的

作者: kimux   发布时间: 2009-02-14

grub> kernel (hd0, (tab,按tab一下键)
Possible partitions are:
Partition num: 0, Filesystem type unknown, partition type 0x7
Partition num: 4, Filesystem type unknown, partition type 0x7
Partition num: 5, Filesystem type unknown, partition type 0x7
Partition num: 6, Filesystem type unknown, partition type 0x7
Partition num: 7, Filesystem type unknown, partition type 0x83
Partition num: 8, Filesystem type unknown, partition type 0x83
Partition num: 9, Filesystem none, partition type 0x82
Partition num: 10, Filesystem type unknown, partition type 0x83
Partition num: 11, Filesystem type unknown, partition type 0x83

grub>kernel (hd0,7)/ (tab,按tab一下键)
grub>kernel (hd0,8)/ (tab,按tab一下键)
grub>kernel (hd0,10)/ (tab,按tab一下键)
正常显示。

grub>kernel (hd0,11)/ (tab,按tab一下键)
Error 2:Bad file or directory type

看来真的是grub没法分辨(hd0,11)这个区.

于是用之前的/boot单独的分区(hd0,10)引导,没出现Error 2错误,可是启动时提示错误:
VFS: Cannot open root device "root=/dev/sda11" or unknown-block(2,0)
 Please append a correct "root=" boot option
 Kernel panic - not syncing: VFS: unable to mount root fs on unknown-block(2,0)

问题先帖出来,搜了一下,网上有些例子,忙了一上午,先吃了饭再研究。^_^
哪位有空也请帮忙找一下答案.

作者: kentty   发布时间: 2009-02-14

网上找了些文章,不知道是不是内核问题?有什么办法可以知道内核是不是有问题?
以下是现在的menu.lst:
title Gentoo Linux 2.6.27-r8
root (hd0,10)
kernel /boot/kernel-2.6.27-gentoo-r8 root=/dev/sda12

title Debian GNU/Linux, kernel 2.6.27-11-generic
root (hd0,8)
kernel /boot/vmlinuz-2.6.27-11-generic root=UUID=0831f4db-27d6-40fa-a1f8-a5ca086980cf ro quiet splash locale=zh_CN
initrd /boot/initrd.img-2.6.27-11-generic
boot

fatab:
/dev/sda11 /boot ext3 noauto,noatime 1 2
/dev/sda12 / ext3 noatime 0 1
/dev/sda10 none swap sw 0 0
/dev/cdrom /mnt/cdrom auto noauto,ro 0 0

作者: kentty   发布时间: 2009-02-14

引用:
作者: kentty
网上找了些文章,不知道是不是内核问题?有什么办法可以知道内核是不是有问题?
以下是现在的menu.lst:
title Gentoo Linux 2.6.27-r8
root (hd0,10)
kernel /boot/kernel-2.6.27-gentoo-r8 root=/dev/sda12

title Debian GNU/Linux, kernel 2.6.27-11-generic
root (hd0,8)
kernel /boot/vmlinuz-2.6.27-11-generic root=UUID=0831f4db-27d6-40fa-a1f8-a5ca086980cf ro quiet splash locale=zh_CN
initrd /boot/initrd.img-2.6.27-11-generic
boot

fatab:
/dev/sda11 /boot ext3 noauto,noatime 1 2
/dev/sda12 / ext3 noatime 0 1
/dev/sda10 none swap sw 0 0
/dev/cdrom /mnt/cdrom auto noauto,ro 0 0
我觉得和内核没有关系,你都没有找到内核文件,你到你的Debian里面用fsck去看看你那个不认的分区把,可能磁盘有错也不一定。

突然想起,忘了问了,你是安装 AMD64 ,还是x86的版本???

作者: dutongtie   发布时间: 2009-02-14

网上有很多文章说到如果内核编译配置时有的模块没有选上也会出现VFS的错误提示,我应该没有漏选的。我安装的是x86版本,因现在的ubuntu也是i686,如果安装AMD64的,在ubuntu下好像34跟64的不兼容sudo chroot /mnt/gentoo /bin/bash没法进去。
fsck结果如下:
$sudo fsck /dev/sda11
fsck 1.41.3 (12-Oct-2008)
e2fsck 1.41.3 (12-Oct-2008)
/dev/sda11: clean, 14/26104 files, 12702/104388 blocks

$sudo fsck /dev/sda12
fsck 1.41.3 (12-Oct-2008)
e2fsck 1.41.3 (12-Oct-2008)
/dev/sda12: clean, 392081/1048576 files, 805562/4188940 blocks

作者: kentty   发布时间: 2009-02-14

是不是grub的版本的问题呀,你在gentoo里面安装重装grub试试。

作者: dutongtie   发布时间: 2009-02-14

chroot到gentoo里重装过grub了,问题依旧。

作者: kentty   发布时间: 2009-02-14

请问怎么看电脑启动时的信息,我想把错误信息帖出来.我找不到log文件.

作者: kentty   发布时间: 2009-02-14

引用:
作者: kentty
请问怎么看电脑启动时的信息,我想把错误信息帖出来.我找不到log文件.
在/var/log/目录里面。

作者: dutongtie   发布时间: 2009-02-14

引用:
作者: kentty
请问怎么看电脑启动时的信息,我想把错误信息帖出来.我找不到log文件.
好像是这样...不过我没用过..机器一切正常也不需要记录

如果用openrc

在/etc/rc.conf里

rc_logger="YES"

作者: kimux   发布时间: 2009-02-14

代码:
Error 2: Bad file or directory type
这个问题出在 GRUB 上,是分区类型没设置正确。进入 fdisk 或者 cfdisk,把 Linux 分区的类型改为 83(Linux)。

代码:
VFS: Cannot open root device "root=/dev/sda11" or unknown-block(2,0)
 Please append a correct "root=" boot option
 Kernel panic - not syncing: VFS: unable to mount root fs on unknown-block(2,0)
请使用 genkernel 生成内核,容易成功,以后熟练后再精简。如使用 genkernel,内核参数可以改为 “real_root=/dev/sda11 root=/dev/ram0 rootfstype=ext3”。

作者: coderoar   发布时间: 2009-02-14

$ls /mnt/gentoo/var/log
emerge-fetch.log emerge.log lastlog news portage sandbox wtmp
好像没有需要的。^_^

在/etc/rc.conf里还没有这句:
rc_logger="YES"

错误信息中有:
Root-NFS:No NFS server avilable,giving up.
VFS:Unable to mount root fs via NFS, trying floppy.

我现在从新编译内核,多选一些模块,再看看行不行.

作者: kentty   发布时间: 2009-02-14

把 ext3 编译进内核

作者: coderoar   发布时间: 2009-02-14

"这个问题出在 GRUB 上,是分区类型没设置正确。进入 fdisk 或者 cfdisk,把 Linux 分区的类型改为 83(Linux)。"
coderoar兄,
Partition num: 10, Filesystem type unknown, partition type 0x83
Partition num: 11, Filesystem type unknown, partition type 0x83
这个显示不就是83了吗?

我从编了一下内核,一会试完了不行就用genkernel 试试.
谢谢楼上各位!

作者: kentty   发布时间: 2009-02-14

"把 ext3 编译进内核."

应该是已经编进去的了。

作者: kentty   发布时间: 2009-02-14

重新编译了,多加了知道的和不知道的模块,问题还是一样.
现在准备用genkernel 生成内核,但手册里有一句:
复制安装光盘上的内核配置文件到genkernel搜索配置文件的默认位置:
# zcat /proc/config.gz > /usr/share/genkernel/x86/kernel-config-2.6

我在ubuntu下没有config.gz这个文件,快崩溃了,搞了一天了!
现在去刻盘,用光盘启动找config.gz这个文件.

作者: kentty   发布时间: 2009-02-14

用光盘启动,cp了config.gz这个文件出来.
再用genkernel生成内核,终于成功进入字符界面的Gentoo Linux了,试了一下网络,ping不通,估计是网络配置的问题,这个慢慢研究了(估计是个简单问题)。

"如使用 genkernel,内核参数可以改为 “real_root=/dev/sda11 root=/dev/ram0 rootfstype=ext3”。"---coderoar
coderoar兄,我的/是在sda12,上面那句我改11为12,可以正常启动到Gentoo了.
sda11我没试过,不知道能不能成功.

我的理解是root ()这个是/boot所在分区.
kernel real_root=这个是/所在分区.
不知道是不是这样理解,不过我这样做可以正常进系统了。^_^

再次感谢楼上所有兄弟姐妹的帮忙。累了一天了,还好,问题解决了。呵呵。。。

作者: kentty   发布时间: 2009-02-15

引用:
作者: kentty
现在准备用genkernel 生成内核,但手册里有一句:
复制安装光盘上的内核配置文件到genkernel搜索配置文件的默认位置:
# zcat /proc/config.gz > /usr/share/genkernel/x86/kernel-config-2.6
其实,在 /usr/share/genkernel 内就有 genkernel 默认的内核配置文件,比如 x86 架构的,就在 x86/kernel-config。不知道和安装光盘上的有没有不同。

引用:
作者: kentty
我的理解是root ()这个是/boot所在分区.
kernel real_root=这个是/所在分区.
是这样的,root 是启动时的临时分区,如果不用 initrd 可以直接设为 root 分区,如果用了,就要设为 ramdisk,并且设置 real_root

---

很费解你的 GRUB 会不认 ext3,后来还有“Error 2: Bad file or directory type”吗?

作者: coderoar   发布时间: 2009-02-15

上不了网是因为/etc/resolv.conf文件内容空了。(不知道什么时候弄没的)
添加DNS后可以上了。我的是DHCP自动获取IP的。

作者: kentty   发布时间: 2009-02-15

"很费解你的 GRUB 会不认 ext3,后来还有“Error 2: Bad file or directory type”吗?"

-coderoar兄,我把/boot放在/下,同一分区,就会出现Error 2错误提示,把/boot单独分出来就没有这个错误了.grub不认sda12,认sda11,两个区都是用同一软件格式化的.
安装gentoo是这样的:
ext3格式分sda11,sda12两个区,把sda12挂到/mnt/gentoo,解压stage3到/mnt/gentoo/,sda11挂到/mnt/gentoo/boot,chroot进去根据手册来的.
后在ubuntu下改menu.lst,grub就不认sda12了.

我现在也不明白为什么grub不认得sda12.

作者: kentty   发布时间: 2009-02-15

那你现在的 menu.lst 呢?

作者: coderoar   发布时间: 2009-02-15

之前跟现在只有选择的启动分区不一样,如下:
开始的menu.lst
menu.lst内容:
title Gentoo Linux 2.6.27-r8
root (hd0,11)
kernel /boot/kernel-2.6.27-gentoo-r8 root=/dev/sda12 ro

现在的menu.lst:
title Gentoo Linux 2.6.27-r8
root (hd0,10)
kernel /boot/kernel-2.6.27-gentoo-r8 real_root=/dev/sda12 root=/dev/ram0 rootfstype=ext3

作者: kentty   发布时间: 2009-02-15