安装 12.04 时如何修复“未找到 grub 错误文件”?

安装 12.04 时如何修复“未找到 grub 错误文件”?

我正在尝试安装 Ubuntu。我不知道这是否重要,但我正在尝试将其安装在外部硬盘上。

最后我有一个外部可启动硬盘,它只显示:

error: file not found
grub recovery>

从一开始就:

  • 我已经下载了 ubuntu-12.04-desktop-i386.iso
  • 我使用 LiLi USB Creator (LinuxLive) 从该映像创建了可启动的 U 盘
  • 我已经从中启动了,它起作用了
  • 我点击了“尝试 ubuntu”,它也能工作。

我使用 GParted 查看驱动程序(磁盘)

我的主嵌入式磁盘被视为 /dev/sda

我附加的外部磁盘为 /dev/sdb

我的 PenDrive 为 /dev/sdc

  • 我在 /dev/sdb 上创建了分区

  • 系统第一个分区(超过200GiB)

  • 第二个已经在那里了(它是 xsf,我不想碰它:P)
  • 第三个是扩展分区,其中有 1 个本地分区(10GiB)用于交换

  • 我已经开始安装

  • 我选择了“其他”...我相信第二个屏幕
  • 然后选择/dev/sdb作为启动盘
  • 对于 /dev/sdb 的第一个分区,我设置了 ext3 文件系统,我选中了“格式化”复选框,并将挂载路径设置为“/”
  • 第一个逻辑分区设置为交换分区

安装完成后,我重新启动了计算机。当我从主磁盘启动时,它工作正常,我以前的操作系统 - vista - 工作正常。当我将 BIOS 设置为从外部磁盘启动时,我只收到该消息:

error: file not found
grub recovery>
  • 我尝试重新安装它,但没有帮助......

无奈之下,我尝试阅读一些有关“grub recovery>”命令行的内容并进行了一些实验...我不确定这是否有任何意义,或者它是否给你提供了一些信息(注意,我不知道我在做什么:P)

当我输入命令时:

insmod (hd1,1)/boot/grub/linux.mod

我收到消息:

unknown filesystem

相同:

insmod (hd1,msdos1)/boot/grub/linux.mod

相同:

insmod ext3

但我在执行命令后没有收到任何消息:

insmod ext2

...

请注意,我真的不知道这个命令到底是做什么的,但我想也许如果我用 ext2 文件系统重新安装 ubuntu,它就会起作用。我已经这样做了,但症状是一样的。

我回到那个 ubuntu 的 Live 版本,文件系统和基本目录似乎存在于 /dev/sdb1 上...我对 GRUB 完全不熟悉。我也不知道它是哪个版本的 GRUB,我希望 ubuntu-12.04-desktop-i386.iso 上只有一个版本

有什么帮助吗?谢谢

======================== 编辑 2012 年 6 月 17 日 22:05 ===========================

这是来自 bootinfoscript 的 RESULTS.txt

sda 是我的内置硬盘

sdb 是外部硬盘(Ubuntu 的磁盘目标)

sdc 是带有 Live Ubuntu 的 PenDrive

                  Boot Info Script 0.61      [1 April 2012]


============================= Boot Info Summary: ===============================

 => Windows is installed in the MBR of /dev/sda.
 => Grub2 (v1.99) is installed in the MBR of /dev/sdb and looks at sector 1 of 
    the same hard drive for core.img. core.img is at this location and looks 
    for (,msdos1)/boot/grub on this drive.
 => Syslinux MBR (4.04 and higher) is installed in the MBR of /dev/sdc.

sda1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  Windows 7: FAT32
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /bootmgr /boot/bcd

sda2: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows Vista/7: NTFS
    Boot sector info:  No errors found in the Boot Parameter Block.
    Operating System:  Windows Vista
    Boot files:        /bootmgr /Boot/BCD /Windows/System32/winload.exe

sda3: __________________________________________________________________________

    File system:       Extended Partition
    Boot sector type:  -
    Boot sector info: 

sda5: __________________________________________________________________________

    File system:       ntfs
    Boot sector type:  Windows Vista/7: NTFS
    Boot sector info:  According to the info in the boot sector, sda5 starts 
                       at sector 63.
    Operating System:  
    Boot files:        

sdb1: __________________________________________________________________________

    File system:       ext2
    Boot sector type:  -
    Boot sector info: 
    Operating System:  Ubuntu 12.04 LTS
    Boot files:        /boot/grub/grub.cfg /etc/fstab /boot/grub/core.img

sdb3: __________________________________________________________________________

    File system:       xfs
    Boot sector type:  -
    Boot sector info: 
    Mounting failed:   mount: /dev/sdb3: can't read superblock

sdb4: __________________________________________________________________________

    File system:       Extended Partition
    Boot sector type:  -
    Boot sector info: 

sdb5: __________________________________________________________________________

    File system:       swap
    Boot sector type:  -
    Boot sector info: 

sdc1: __________________________________________________________________________

    File system:       vfat
    Boot sector type:  SYSLINUX 4.04 2011-04-18
    Boot sector info:  Syslinux looks at sector 3250552 of /dev/sdc1 for its 
                       second stage. SYSLINUX is installed in the  directory. 
                       The integrity check of the ADV area failed. No errors 
                       found in the Boot Parameter Block.
    Operating System:  
    Boot files:        /syslinux/syslinux.cfg /ldlinux.sys

============================ Drive/Partition Info: =============================

Drive: sda _____________________________________________________________________

Disk /dev/sda: 160.0 GB, 160041885696 bytes
16 heads, 63 sectors/track, 310101 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sda1               2,048    20,482,047    20,480,000  1c Hidden W95 FAT32 (LBA)
/dev/sda2    *     20,482,048   176,771,071   156,289,024   7 NTFS / exFAT / HPFS
/dev/sda3         176,771,072   312,580,095   135,809,024   f W95 Extended (LBA)
/dev/sda5         176,773,120   312,580,095   135,806,976   7 NTFS / exFAT / HPFS


Drive: sdb _____________________________________________________________________

Disk /dev/sdb: 640.1 GB, 640135028736 bytes
255 heads, 63 sectors/track, 77825 cylinders, total 1250263728 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sdb1    *          2,048   574,773,569   574,771,522  83 Linux
/dev/sdb3         574,773,570 1,208,315,584   633,542,015   7 NTFS / exFAT / HPFS
/dev/sdb4       1,208,317,950 1,229,289,471    20,971,522   f W95 Extended (LBA)
/dev/sdb5       1,208,317,952 1,229,289,471    20,971,520  82 Linux swap / Solaris


Drive: sdc _____________________________________________________________________

Disk /dev/sdc: 1971 MB, 1971322880 bytes
129 heads, 40 sectors/track, 746 cylinders, total 3850240 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes

Partition  Boot  Start Sector    End Sector  # of Sectors  Id System

/dev/sdc1    *             40     3,850,239     3,850,200   6 FAT16


"blkid" output: ________________________________________________________________

Device           UUID                                   TYPE       LABEL

/dev/loop0                                              squashfs   
/dev/loop1       7aa47a24-93a0-d54f-a03c-495cf2ee0927   ext2       
/dev/sda1        3C98-AC5D                              vfat       RECOVERY
/dev/sda2        94CA2D3CCA2D1BCC                       ntfs       VistaOS
/dev/sda5        A2F09F72F09F4B83                       ntfs       DATA
/dev/sdb1        a4befd4a-f91f-4f09-9d5f-a44991ed6a2e   ext2       
/dev/sdb3        973a36d7-5828-4291-b455-db286cd69668   xfs        
/dev/sdb5        9ce43dea-fd93-4343-969d-1243397724bd   swap       
/dev/sdc1        7232-C522                              vfat       GOODDRIVE

================================ Mount points: =================================

Device           Mount_Point              Type       Options

/dev/loop0       /rofs                    squashfs   (ro,noatime)
/dev/sdc1        /cdrom                   vfat       (rw,relatime,fmask=0022,dmask=0022,codepage=cp437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)


=========================== sdb1/boot/grub/grub.cfg: ===========================

--------------------------------------------------------------------------------
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
  load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function recordfail {
  set recordfail=1
  if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd1,msdos1)'
search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
  insmod part_msdos
  insmod ext2
  set root='(hd1,msdos1)'
  search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
  set locale_dir=($root)/boot/grub/locale
  set lang=pl_PL
  insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
  set timeout=-1
else
  set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
  clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
    set gfxpayload="$1"
    if [ "$1" = "keep" ]; then
        set vt_handoff=vt.handoff=7
    else
        set vt_handoff=
    fi
}
if [ ${recordfail} != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
      else
        set linux_gfx_mode=text
      fi
    else
      set linux_gfx_mode=text
    fi
  else
    set linux_gfx_mode=keep
  fi
else
  set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
menuentry 'Ubuntu, za pomocą systemu Linux 3.2.0-23-generic-pae' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos1)'
    search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
    linux   /boot/vmlinuz-3.2.0-23-generic-pae root=/dev/sdb1 ro   quiet splash $vt_handoff
    initrd  /boot/initrd.img-3.2.0-23-generic-pae
}
menuentry 'Ubuntu, za pomocą systemu Linux 3.2.0-23-generic-pae (tryb ratunkowy)' --class ubuntu --class gnu-linux --class gnu --class os {
    recordfail
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos1)'
    search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
    echo    'Wczytywanie systemu Linux 3.2.0-23-generic-pae...'
    linux   /boot/vmlinuz-3.2.0-23-generic-pae root=/dev/sdb1 ro recovery nomodeset 
    echo    'Wczytywanie początkowego dysku RAM...'
    initrd  /boot/initrd.img-3.2.0-23-generic-pae
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos1)'
    search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
    linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
    insmod part_msdos
    insmod ext2
    set root='(hd1,msdos1)'
    search --no-floppy --fs-uuid --set=root a4befd4a-f91f-4f09-9d5f-a44991ed6a2e
    linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Windows Recovery Environment (loader) (on /dev/sda1)" --class windows --class os {
    insmod part_msdos
    insmod fat
    set root='(hd0,msdos1)'
    search --no-floppy --fs-uuid --set=root 3C98-AC5D
    drivemap -s (hd0) ${root}
    chainloader +1
}
menuentry "Windows Vista (loader) (on /dev/sda2)" --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='(hd0,msdos2)'
    search --no-floppy --fs-uuid --set=root 94CA2D3CCA2D1BCC
    chainloader +1
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
--------------------------------------------------------------------------------

=============================== sdb1/etc/fstab: ================================

--------------------------------------------------------------------------------
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    nodev,noexec,nosuid 0       0
# / was on /dev/sdb1 during installation
UUID=a4befd4a-f91f-4f09-9d5f-a44991ed6a2e /               ext2    errors=remount-ro 0       1
# swap was on /dev/sdb5 during installation
UUID=9ce43dea-fd93-4343-969d-1243397724bd none            swap    sw              0       0
--------------------------------------------------------------------------------

=================== sdb1: Location of files loaded by Grub: ====================

           GiB - GB             File                                 Fragment(s)

               =                boot/grub/core.img                             1
               =                boot/grub/grub.cfg                             1
               =                boot/initrd.img-3.2.0-23-generic-pae           6
               =                boot/vmlinuz-3.2.0-23-generic-pae              3
               =                initrd.img                                     6
               =                vmlinuz                                        3

========================= sdc1/syslinux/syslinux.cfg: ==========================

--------------------------------------------------------------------------------
# D-I config version 2.0
include menu.cfg
default vesamenu.c32
prompt 0
timeout 50
ui gfxboot bootlogo
--------------------------------------------------------------------------------

================= sdc1: Location of files loaded by Syslinux: ==================

           GiB - GB             File                                 Fragment(s)

            ?? = ??             ldlinux.sys                                    1
            ?? = ??             syslinux/chain.c32                             1
            ?? = ??             syslinux/gfxboot.c32                           1
            ?? = ??             syslinux/syslinux.cfg                          1
            ?? = ??             syslinux/vesamenu.c32                          1

============== sdc1: Version of COM32(R) files used by Syslinux: ===============

 syslinux/chain.c32                 :  COM32R module (v4.xx)
 syslinux/gfxboot.c32               :  COM32R module (v4.xx)
 syslinux/vesamenu.c32              :  COM32R module (v4.xx)

=============================== StdErr Messages: ===============================

xz: (stdin): Compressed data is corrupt
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
awk: cmd. line:36: Math support is not compiled in
/home/ubuntu/Pobrane/bootinfoscript-061/bootinfoscript: line 1646: [: 2.73495e+09: integer expression expected

我不得不说脚本在终端上打印:

Boot Info Script 0.61      [1 April 2012]


"gawk" could not be found, using "busybox awk" instead.
This may lead to unreliable results.

Identifying MBRs...
Computing Partition Table of /dev/sda...
Computing Partition Table of /dev/sdb...
Computing Partition Table of /dev/sdc...
Searching sda1 for information... 
Searching sda2 for information... 
Searching sda3 for information... 
Searching sda5 for information... 
Searching sdb1 for information... 
Searching sdb3 for information... 
Searching sdb4 for information... 
Searching sdb5 for information... 
Searching sdc1 for information... 

Finished. The results are in the file "RESULTS.txt"
located in "/home/ubuntu/Pobrane/bootinfoscript-061/".

============== 编辑 2012 年 6 月 18 日 18:38 ===============

好的,这或多或少是我 grub 恢复会话的副本:

error: file not found
grub recovery> set
prefix=(hd0,msdos1)/boot/grub
root=hd0,msdos1
grub recovery> ls
(hd0) (hd0,msdos3) (hd0,msdos1) (hd1) (hd1,msdos5) (hd1,msdos2) (hd1,msdos1)
grub recovery> ls $prefix

error: file not found
grub recovery> 

然后我在一些路径上使用‘ls’cmd,结果很奇怪(我认为):

grub recovery> ls (hd0,msdos1)/boot

grub recovery> ls (hd0,msdos1)/boot/grub

error: file not found
grub recovery> ls (hd0,msdos1)/lib

grub recovery> ls (hd0,msdos1)/bin

grub recovery> ls (hd0,msdos1)/sys
./ ../
grub recovery> ls (hd0,msdos1)/sbin

grub recovery> ls (hd0,msdos1)/usr
./ ../ local/ (and some other things)

这是正常的吗?当我通过 Live Ubuntu 安装此外部硬盘时,我可以看到 /boot/grub 及其内容

答案1

使用 grub 时,您只能看到文件系统上的部分文件,而看不到所有文件,这通常意味着您的 BIOS 存在缺陷,无法正确处理大型驱动器(http://tldp.org/HOWTO/Large-Disk-HOWTO-4.html)。BIOS 无法读取驱动器中某个点之后的块,因此如果您的根文件系统在该限制之前启动,但在该限制之后结束,则某些文件在启动时可以通过 BIOS 访问,而其他文件则不能。解决此问题的标准方法是在驱动器开头附近创建一个小的 /boot/ 分区,以确保可以通过 BIOS 读取的所有内容。

如果是这种情况,我通常会认为 grub 会出现“磁盘不足”错误,但我不知道为什么我们没有看到这些错误。确认问题出在 BIOS 限制的一种方法是进入 BIOS 菜单,查看它列出的驱动器大小,如果列出的驱动器大小小于实际大小,则说明 BIOS 存在错误。另一种方法是,如果您的 BIOS 在其菜单中没有列出大小,则从 grub 运行“ls -l”并查看其中列出的大小。不幸的是,您无法从救援 shell 运行“ls -l”,因此您需要从 grub CD 启动,或者已经修复了 /boot/ 分区较小的问题,然后才能从 grub 内部进行检查。

答案2

更改启动首选项以从外部硬盘启动。计算机正在尝试在内置硬盘上查找 grub,但实际上它在外部硬盘中。因此,您必须更改启动选项,以将外部硬盘作为第一首选项,然后将内置硬盘作为第二首选项。因此,如果您插入外部硬盘,它将自动启动 ubuntu,如果您不插入,它将启动您在内置硬盘中安装的系统。

答案3

如果你仍然遇到问题,请尝试“GRUB Customizer”

sudo apt-get grub-customizer

插入你的 U 盘或外部 USB

从 GUI 管理员工具 Admin->grub-Customizer 或 Q 启动它!

启动后,它将读取类似于 bootinfoscript 的启动脚本,因此等待几秒钟才能完成,然后启动信息窗口的颜色将从灰色变为正常。

然后,您可以编辑找到的每个驱动器的启动信息。

要添加新条目,只需按编辑->添加,然后选择 Linux。使用选项卡按钮验证磁盘 UUID 是否与您要从中启动的磁盘匹配。

单击完成。

点击保存按钮

验证您的编辑手册查看 grub-boot 菜单以确保编辑已保存。我假设您的 grub 引导加载程序位于 hd0 或 sda0 上。cat out

/hd0/boot/grub/grub.cfg # 不要编辑此文件,只需查看或验证它。或者再次运行您的 bootinfoscript。

如果这不能解决问题,那么内核可能存在问题。我不得不以这种方式重新安装我的 Ubuntu-LTS,因为另一个 Linux 64 位安装对引导加载程序进行了过多的干扰。如果您使用的是 64 位机器,请验证 usb 驱动器 /pendrive 是否也是 64 位操作系统。否则,当 USB 驱动程序尝试加载 USB 驱动器时,它会分叉。

最好将新操作系统保持在 6-10MB 左右,这样您就不会达到大 GB-HD 的上限。您还需要在 grub 运行之前验证是否安装了任何外部 USB 驱动程序。为此,请按紫色屏幕上的向下箭头键查看正在安装哪些模块以及哪些模块分叉。

如果这没有帮助,请尝试使用救援磁盘来获取丢失的内核/文件。当 Grub-Customizer 出现问题时,我会使用 bootrecovery-CD (sourceforge:boot-repair-diskx64) 或 Linux-remix-CD (www.ubuntu-rescue-remix.org)。

相关内容