使用 grubrescue 恢复移动的 .mod 文件

Doc*_*ger 33 grub2 grubrescue

我做了一件愚蠢的事情......我忘记了 Ubuntu 10.04(Lucid Lynx)切换到GRUB  2,它在/boot/grub. 我以为它们是放错地方的配乐文件,于是我移动了它们。不用说,下一次重启是创伤性的。我看到了一些我从来没有见过的东西......一个'grub rescue>'提示。

修复 GRUB 错误的帮助下:“错误:未知文件系统”然而,我能够恢复......

  • 我发现 GRUB 救援没有 'cd'、'cp' 或任何其他文件系统命令,除了它自己的 'ls' 变体。
  • 所以首先我必须找到/boot包含vmlinuz文件和其他启动映像文件的目录的分区...... (从失败尝试的记忆中近似,以及为清晰起见,由 docsalvage 于 2014-07-10 添加)

    grub rescue>  ls  
    (hd0,4) (hd0,3) (hd0,2) (hd0,1)  
    
    grub rescue>  ls (hd0,4)/boot
    ... some kind of 'not found' message
    
    grub rescue>  ls (hd0,3)/boot
    ... some kind of 'not found' message
    
    grub rescue>  ls (hd0,2)/boot
    ... grub ... initrd.img-2.6.32-33-generic ... vmlinuz-2.6.32-33-generic 
    
    Run Code Online (Sandbox Code Playgroud)
  • 我在 partition 上找到了一个/boot包含该vmlinuz文件的目录。vmlinuz-2.6.32-33-generic(hd0,2)

  • 然后我从“grub rescue>”提示手动启动。以下命令将...

    • 将 设置root为使用/boot分区上的目录(hd0,2)
    • 加载内核模块linux
    • 将该模块设置为使用内核映像vmlinuz-2.6.32-33-generic
    • 设置 initrd(初始化 RAM 磁盘)以使用该映像initrd.img-2.6.32-33-generic
    • 启动 Linux。
  • grub rescue>  set root=(hd0,2)/boot  
    grub rescue>  insmod linux  
    grub rescue>  linux (hd0,2)/boot/vmlinuz-2.6.32-33-generic root=/dev/sda2
    grub rescue>  initrd (hd0,2)/boot/initrd.img-2.6.32-33-generic  
    grub rescue>  boot  
    
    Run Code Online (Sandbox Code Playgroud)
  • 这会启动并崩溃到 BusyBox 提示,其中确实有一些基本的文件系统命令。

  • 然后我将 *.mod 文件移回/boot/grub目录...

    busybox>  cd /boot  
    busybox>  mv mod/* grub
    busybox>  reboot
    
    Run Code Online (Sandbox Code Playgroud)
  • 重新启动成功了,但这需要大量工作。

有更容易的方法吗?

小智 7

以下是一些有助于解决引导错误的一般和基本说明,例如GRUB loading stage 1.5 error 15 (例如,在不同的磁盘驱动器上安装 Windows 之后):

  1. 使用 LiveDVD(例如,Ubuntu 桌面磁盘)启动。

  2. 打开终端,并使用以下命令重新编写 grub 配置:

    • sudo mount /dev/sdXY /mnt
    • sudo grub-install --root-directory=/mnt /dev/sdX

哪里/dev/sdX是Ubuntu安装所在的磁盘,并且/dev/sdXY是Ubuntu安装在硬盘上的分区。换句话说,/dev/sdXY包含/boot等等。

使用fdisk -l验证Ubuntu的安装位置。


Sta*_*mer 5

不,我认为您几乎找到了使用grub 救援从系统状态中恢复的最简单方法;它是一个非常简约的系统,提供了足够的能力来引导系统。

顺便说一句,我相信你一定已经找到了.mod文件并执行了,insmod linux否则linux命令会失败。

如前所述,唯一的另一种方法是引导 Live CD 并在 chroot 到“损坏的”系统后重新安装 grub2。