新闻中心

EEPW首页>嵌入式系统>设计应用> 教你如何学习GRUB

教你如何学习GRUB

作者: 时间:2016-09-12 来源:网络 收藏

只有少数情况下,才需要将引导装入器重新安装到引导记录。首先,如果更改root 分区的分区类型(例如,从 ext2 改成 ReiserFS),则需要重新安装。或者,如果更新 /boot/grub 中的 stage1 和 stage2 文件,由于它们来自更新版本的,很有可能要重新安装引导装入器。其它情况下,可以不必理睬!

GRUB的最大的特点就是交互性特别强。在开机时,按一下“c”,将进入GRUB 控制台。显示如下:

GRUB version 0.5.96.1 (640K lower / 3072K upper memory)

[ Minimal BASH-like line editing is supported. For the first word, TAB

lists possible command completions. Anywhere else TAB lists the possible

completions of a device/filename. ]

grub>

欢迎使用 GRUB 控制台。现在,再研究命令:

将通过GRUB 控制台绕过lilo来启动RedHat

grub> root (h

现在,按一次 Tab 键。如果系统中有多个硬盘,GRUB 将显示可能完成的列表,从 hd0 开始。如果只有一个硬盘,GRUB 将插入 hd0,。如果有多个硬盘,继续进行,在 (hd2 中输入名称并在名称后紧跟着输入逗号,但不要按 Enter 键。部分完成的 root 命令看起来如下:

grub> root (hd0,

现在,继续操作,再按一次 Tab 键。GRUB 将显示特定硬盘上所有分区的列表,以及它们的文件系统类型。在我的系统中,按 Tab 键时得到以下列表:

grub> root (hd0, (tab,按tab一下键)

Possible partitions are:

Partition num: 0, Filesystem type is fat, partition type 0x6

Partition num: 2, Filesystem type is ext2fs, partition type 0x83

Partition num: 4, Filesystem type unknown, partition type 0x7

Partition num: 5, Filesystem type is ext2fs, partition type 0x83

Partition num: 6, Filesystem type is fat, partition type 0xb

Partition num: 7, Filesystem type is fat, partition type 0xb

Partition num: 8, Filesystem type is ext2fs, partition type 0x83

Partition num: 9, Filesystem type unknown, partition type 0x82

如您所见,GRUB 的交互式硬盘和分区名称实现功能非常有条理。这些,只需要好好理解 GRUB 新奇的硬盘和分区命名语法,然后就可以继续操作了

grub> root (hd0,8)

现在已安装了 root 文件系统,到装入内核的时候了

grub> kernel /boot/vmlinuz-2.4.2 root=/dev/hda5 ro

[Linux-bzImage, setup=0x1200, size=0xe1a30]

您已经安装了 root 文件系统并装入了内核。现在,可以引导了。只要输入 boot,Linux 引导过程就将开始。是不是很cool啊,GRUB的menu.lst更像一个下的脚本程序。

5 常见grub除错方法的思路

首先进去Linux的rescue模式!

用软盘或光盘启动,然后在启动的提示符输入:rescue

按照提示进入一个Shell状态,你可以到/mnt/下面看到一个sysimage这么目录,进去以后,就是你安装linux的/分区.

使用命令将根分区变为当前目录的根分区:chroot /mnt/sysimage

然后转到/sbin/这个目录中.

使用fdisk -l 显示当前分区情况,然后使用#grub-install /dev/hdx(x为你使用的是那块硬盘安装的,一般情况下是hda)

使用exit推出chroot,再使用exit退出linux rescue模式,系统将重新启动!取出光盘,应该可以看到grub安装好了.

在具体的环境中,编辑/boot/grub/grub.conf文件和menu.lst文件.


上一页 1 2 3 4 5 下一页

关键词:GRUBlinux

评论


相关推荐

技术专区

关闭