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

Tom*_*ski 6 installation grub2 12.04

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

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

error: file not found
grub recovery>
Run Code Online (Sandbox Code Playgroud)

从一开始就:

  • 我已经下载了 ubuntu-12.04-desktop-i386.iso
  • 我使用 LiLi USB Creator (LinuxLive) 从该映像创建可启动的随身碟
  • 我从它引导,它的工作原理
  • 我点击了“尝试 ubuntu”,它也有效。

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

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

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

我的 PenDrive 为 /dev/sdc

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

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

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

  • 我已经开始安装

  • 我选择了“别的东西”...我相信第二个 screeb
  • 然后选择 /dev/sdb 作为启动盘
  • 对于 /dev/sdb 的第一部分,我设置了我想要 ext3 文件系统,我选中了“formattin”复选框,并将安装路径设置为“/”
  • 第一个逻辑分区设置为交换分区

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

error: file not found
grub recovery>
Run Code Online (Sandbox Code Playgroud)
  • 我尝试重新安装它,但没有帮助...

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

当我输入命令时:

insmod (hd1,1)/boot/grub/linux.mod
Run Code Online (Sandbox Code Playgroud)

我收到消息:

unknown filesystem
Run Code Online (Sandbox Code Playgroud)

与以下相同:

insmod (hd1,msdos1)/boot/grub/linux.mod
Run Code Online (Sandbox Code Playgroud)

与以下相同:

insmod ext3
Run Code Online (Sandbox Code Playgroud)

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

insmod ext2
Run Code Online (Sandbox Code Playgroud)

...

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

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

有什么帮助吗?泰克斯

====================== 编辑 17.06.2012 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
Run Code Online (Sandbox Code Playgroud)

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

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/".
Run Code Online (Sandbox Code Playgroud)

============== 编辑 18.06.2012 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> 
Run Code Online (Sandbox Code Playgroud)

然后我在几条路径上使用了 '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)
Run Code Online (Sandbox Code Playgroud)

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

Jor*_*gla 3

使用 grub 能够在文件系统上看到一些文件但不能看到全部文件的症状通常意味着您的 BIOS 有错误并且无法正确处理大型驱动器 ( http://tldp.org/HOWTO/Large-Disk-HOWTO-4 .html )。发生的情况是 BIOS 无法读取驱动器中超过某个点的块,因此如果您的根文件系统在该限制之前启动,但在该限制之后结束,则某些文件将在引导时通过 BIOS 访问,而其他文件则不会't。解决此问题的标准方法是在驱动器的开头附近创建一个小的 /boot/ 分区,以确保需要通过 BIOS 读取的所有内容都可以。

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