如何从 Grub Shell 启动

use*_*239 7 linux grub linux-mint

我已经安装了 Linux Mint Cinnamon,但是每当我打开电脑时,它就会进入 grub shell,我不知道为什么,而且我也不知道如何从 shell 启动 GUI Linux Mint,请帮助我

Joa*_*ela 12

我也有同样的问题!解决方案在这里:\n https://www.linux.com/tutorials/how-rescue-non-booting-grub-2-linux/

\n\n

引自上述网站。

\n\n

[...]

\n\n
\n

GRUB 2 命令 shell 与旧版 GRUB 中的 shell 一样强大。您可以使用它来发现启动映像、内核和根文件系统。事实上,它使您可以完全访问本地计算机上的所有文件系统,无论权限或其他保护如何。有些人可能会认为这是一个安全漏洞,但你知道古老的 Unix 格言:谁对机器有物理访问权限,谁就拥有它。

\n\n

当您在 grub> 提示符下\xe2\x80\x99 时,您将拥有许多与任何命令 shell 类似的功能,例如历史记录和制表符补全。grub rescue> 模式受到更多限制,没有历史记录,也没有制表符补全。

\n\n

如果您正在正常运行的系统上进行练习,请在 GRUB 引导菜单出现时按 C 键以打开 GRUB 命令 shell。您可以通过使用箭头键上下滚动菜单条目来停止启动倒计时。在 GRUB 命令行中进行实验是安全的,因为您在那里所做的任何事情都不是永久的。如果您已经盯着 grub> 或 grub saving> 提示符,那么您\xe2\x80\x99 就准备好了。

\n\n

接下来的几个命令适用于grub>grub rescue>。您应该运行的第一个命令调用分页器,以对长命令输出进行分页:

\n
\n\n
grub> set pager=1\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

等号两边不能有空格。现在让\xe2\x80\x99s 做一些探索。键入ls以列出 GRUB 看到的所有分区:

\n
\n\n
grub> ls\n(hd0) (hd0,msdos2) (hd0,msdos1)\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

这些msdos东西是什么\xe2\x80\x99?这意味着该系统具有旧式 MS-DOS 分区表,而不是闪亮的新全局唯一标识符分区表 (GPT)。如果您\xe2\x80\x99正在运行GPT,它会显示(hd0,gpt1). 现在让\xe2\x80\x99s 进行窥探。使用 ls 命令查看系统上有哪些文件:

\n
\n\n
grub> ls (hd0,1)/\nlost+found/ bin/ boot/ cdrom/ dev/ etc/ home/  lib/\nlib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ \nsrv/ sys/ tmp/ usr/ var/ vmlinuz vmlinuz.old\ninitrd.img initrd.img.old\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

万岁,我们找到了根文件系统。您可以省略msdosgpt标签。如果省略斜杠,它将打印有关分区的信息。您可以使用以下命令读取系统上的任何文件cat

\n
\n\n
grub> cat (hd0,1)/etc/issue\nUbuntu 14.04 LTS n l\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

阅读/etc/issue在多重引导系统上可能对识别各种 Linux 很有用。

\n\n

Booting From grub> \n 这是设置引导文件并从提示符引导系统的方法grub>。通过运行ls命令我们知道 上有一个 Linux 根文件系统(hd0,1),您可以继续搜索,直到确认位置/boot/grub为止。然后使用您自己的根分区、内核和 initrd 映像运行这些命令:

\n
\n\n
grub> set root=(hd0,1)\ngrub> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1\ngrub> initrd /boot/initrd.img-3.13.0-29-generic\ngrub> boot\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

第一行设置根文件系统所在的分区。第二行告诉 GRUB 您要使用的内核的位置。开始输入/boot/vmli,然后使用制表符补全来填写其余部分。键入root=/dev/sdX以设置根文件系统的位置。是的,这似乎是多余的,但如果你忽略它,你\xe2\x80\x99将会出现内核恐慌。你怎么知道正确的分区?hd0,1 = /dev/sda1。hd1,1 = /dev/sdb1。hd3,2 = /dev/sdd2。我想你可以推断剩下的。\n 第三行设置 initrd 文件,它必须与内核的版本号相同。

\n\n

第四行启动您的系统。

\n\n

在某些 Linux 系统上,当前内核和 initrd 被符号链接到根文件系统的顶层:

\n
\n\n
$ ls -l /\nvmlinuz -> boot/vmlinuz-3.13.0-29-generic\ninitrd.img -> boot/initrd.img-3.13.0-29-generic\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以你可以像这样从 grub> 启动:

\n\n
grub> set root=(hd0,1)\ngrub> linux /vmlinuz root=/dev/sda1\ngrub> initrd /initrd.img\ngrub> boot\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

从 grub-rescue 引导>

\n\n

如果您\xe2\x80\x99re在GRUB救援外壳中,命令是不同的,并且您必须加载normal.modlinux.mod模块:

\n
\n\n
grub rescue> set prefix=(hd0,1)/boot/grub\ngrub rescue> set root=(hd0,1)\ngrub rescue> insmod normal\ngrub rescue> normal\ngrub rescue> insmod linux\ngrub rescue> linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1\ngrub rescue> initrd /boot/initrd.img-3.13.0-29-generic\ngrub rescue> boot\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

加载两个模块后,制表符补全应该开始工作。

\n\n

进行永久性修复

\n\n

成功引导系统后,运行以下命令来永久修复 GRUB:

\n
\n\n
# update-grub\nGenerating grub configuration file ...\nFound background: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga\nFound background image: /usr/share/images/grub/Apollo_17_The_Last_Moon_Shot_Edit1.tga\nFound linux image: /boot/vmlinuz-3.13.0-29-generic\nFound initrd image: /boot/initrd.img-3.13.0-29-generic\nFound linux image: /boot/vmlinuz-3.13.0-27-generic\nFound initrd image: /boot/initrd.img-3.13.0-27-generic\nFound linux image: /boot/vmlinuz-3.13.0-24-generic\nFound initrd image: /boot/initrd.img-3.13.0-24-generic\nFound memtest86+ image: /boot/memtest86+.elf\nFound memtest86+ image: /boot/memtest86+.bin\ndone\n# grub-install /dev/sda\nInstalling for i386-pc platform.\nInstallation finished. No error reported.\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n

当您运行时,grub-install请记住您\xe2\x80\x99将其安装到硬盘驱动器的引导扇区而不是分区,因此不要使用像/dev/sda1.

\n
\n\n

作者:卡拉·施罗德

\n