grub再熟悉

一、 GRUB 简介

系统启动引导管理器,是在计算机启动后运行的第一个程序,他是用来负责加载、传输控制到操作系统的内核,一旦把内核挂载,系统引导管理器的任务就算完成退出,系统引导的其它部份,比如系统的初始化及启动过程则完全由内核来控制完成。

二、 GRUB 软件包版安装

在linux 系统中查看有没有安装grub-0.97-13.2 包,如过没有安装此包,那么可以在光盘中找到grub-0.97-13.2 进行安装即可。一般在安装完系统后该包已经被安装到系统中。如果没有rpm 包可以下载tar 包进行编译安装。(grub-0.97-13.2 是安装grub 到mbr 中的工具包)
[root@rhel5 ~]# rpm -qa grub
grub-0.97-13.2
[root@rhel5 ~]#

三、 GRUB 的配置文件grub.conf 的写法

 1.  设备命名命名习惯

首先 GRUB 要求设备名被括在一个括号中。 fd 表示软盘, hd 表示硬盘(不区分 IDE 还是 SCSI )。其次设备是从 0 开始编号。分区也是如此,分区和设备之间用一个 逗号 分开。
下面给出几个例子 :
(fd0) :表示整个软盘
(hd0,1) 表示 系统 的第一个硬盘的第 2 个分区
(hd0,0) :表示 系统 中的第一个硬盘的第一个分区。
如果没有指定某个分区,则表示使用整个设备,否则只使用指定的分区。

 2.  grub.conf 的写法

default :定义默认引导的操作系统。0 表示第一个操作系统,1 表示第2 个,依此类推。
hiddenmenu :用于启动时隐藏菜单,除非在timeout 之前按下 ESC 才能看到菜单。
timeout :定义多少秒内如果用户没有按下键盘上的某个按键,就自动引导 default 所指定的操作系统。
splashimage :指定启动的背景图片,一般为压缩文件。路径为绝对路径。
title :定义引导项目的名称。
root :指定boot 分区所在磁盘及分区,如:root (hd0,0) 。
kernel :指定kernel 文件所在绝对目录地址,如:kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet 。
initrd :指定ramdisk 盘所在绝对目录地址,如:initrd /boot/initrd-2.6.18-92.el5.img 。
 
注意:
kernel 与initrd 这两个设置项中,指定的路径都是绝对路径。 因为这两个文件都存放在/boot 目录。而且 /boot 所在的分区已经在root (hd[0-n],[0-n]) 中指定,所以就无需再指明kernel 与initrd 在哪个分区了。如果boot 分区为独立分区,那么前面的/boot 省略掉。如果boot 分区为非独立分区,那么必须加上/boot 。

 3. boot 分区为独立分区

[root@RHEL5 grub]# cat grub.conf
default=0
# 启动第一个操作系统。
timeout=5
# 超时时间为5 秒。
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5) # 设置项目标题。
        root (hd0,0)
# 设置boot 分区所在位置,第一个硬盘的第一分区。
        kernel /vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
# 设置kernel 所在位置。注意这里的root 指的系统根所在位置,与上面的root 不同。
        initrd /initrd-2.6.18-92.el5.img
        # 设置initrd 所在位置。
[root@RHEL5 grub]#

 4. boot 分区非独立分区

[root@rhel5 ~]# cat /boot/grub/grub.conf
default=0
# 启动第一个操作系统。
timeout=5
# 超时时间为5 秒。
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5) # 设置项目标题。
        root (hd0,0)
# 设置boot 分区所在位置,第一个硬盘的第一分区。
        kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
# 设置kernel 所在位置。注意这里的root 指的系统根所在位置,与上面的root 不同。
        initrd /boot/initrd-2.6.18-92.el5.img
# 设置initrd 所在位置。
[root@rhel5 ~]#

四、 GRUB 和stage 文件

 

 1.  stage 文件

GRUB 含有几个images 文件,两个必需的文件stage1 和 stage2 ,可选的为stage1_5 和两个网络引导的文件nxgrub 和pxegrub 。stage1 是用于引导GURB 的一个必须的映象文件。通常它是被嵌入到 MBR 。或者一个分区的引导扇区之中。因为 PC 的引导扇区是 512 字节,所以 stage1 也是512 字节。stage1 的作用就是从一个本地磁盘加载stage 2 或者stage1_5 。因为大小的限制,stage1 对stage2 或者stage1_5 的位置进行编码。
stage1 与stage2 文件一般位于/boot/grub/ 目录下,在这个目录下还有很多stage1_5 的文件,而且都是以文件系统格式命名的。它们的目的是在stage1 和stage2 之间搭建一个桥梁,也就是stage1 加载stage1_5, 然后stage1_5 加载stage2 。stage1 和stage1_5 的不同之处是 stage1 无法识别文件系统,stage1_5 可以。因为 Stage2 太大了,无法被嵌入到某个固定的区域,而stage1_5 可以安装在 MBR 之后的位置。

 2. grub 启动方式

 1) stage1_5 -> stage2 方式

首先监测是否是合适的文件系统的驱动,如果存在就使用文件系统逻辑的方式stage2 ;如果找不到就用blocklist 的方式再找stage2 ,找到了挂起来,找不到报错。

 2) stage1 -> stage2 方式

如果确认stage1_5 没有被安装在MBR 之后, stage1 就会使用记录的stage2 的blocklist 寻找stage2, 找到后挂起来,找不到报错。

五、 GRUB 三种安装方式

在linux 系统中可以执行grub 命令。进入grub 的命令界面,在这里面可以使用一些常用的命令。也可以对不太了解的命令进行帮助查看。可以使用TAB 键对命令进行补全操作,系统会给予提示信息。如下:
[root@RHEL5 ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (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> help
blocklist FILE                         boot
cat FILE                                chainloader [--force] FILE
clear                                  color NORMAL [HIGHLIGHT]
configfile FILE                        device DRIVE DEVICE
displayapm                             displaymem
find FILENAME                          geometry DRIVE [CYLINDER HEAD SECTOR [
halt [--no-apm]                        help [--all] [PATTERN ...]
hide PARTITION                         initrd FILE [ARG ...]
kernel [--no-mem-option] [--type=TYPE] makeactive
map TO_DRIVE FROM_DRIVE                md5crypt
module FILE [ARG ...]                  modulenounzip FILE [ARG ...]
pager [FLAG]                           partnew PART TYPE START LEN
parttype PART TYPE                     quit
reboot                                 root [DEVICE [HDBIAS]]
rootnoverify [DEVICE [HDBIAS]]         serial [--unit=UNIT] [--port=PORT] [--
setkey [TO_KEY FROM_KEY]               setup [--prefix=DIR] [--stage2=STAGE2_
terminal [--dumb] [--no-echo] [--no-ed terminfo [--name=NAME --cursor-address
testvbe MODE                           unhide PARTITION
uppermem KBYTES                        vbeprobe [MODE]
grub> help root
root: root [DEVICE [HDBIAS]]
    Set the current "root device" to the device DEVICE, then attempt
    to mount it to get the partition size (for passing the partition
    descriptor in `ES:ESI', used by some chain-loaded bootloaders),
    the BSD drive-type (for booting BSD kernels using their native
    boot format), and correctly determine  the PC partition where a
    BSD sub-partition is located. The optional HDBIAS parameter is a
    number to tell a BSD kernel how many BIOS drive numbers are on
    controllers before the current one. For example, if there is an
    IDE disk and a SCSI disk, and your FreeBSD root partition is on
    the SCSI disk, then use a `1' for HDBIAS.
rootnoverify: rootnoverify [DEVICE [HDBIAS]]
    Similar to `root', but don't attempt to mount the partition. This
    is useful for when an OS is outside of the area of the disk that
    GRUB can read, but setting the correct root device is still
    desired. Note that the items mentioned in `root' which derived
    from attempting the mount will NOT work correctly.
grub>

 1. install 命令

命令格式:
install: install [--stage2=STAGE2_FILE] [--force-lba] STAGE1 [d] DEVICE STAGE2 [ADDR] [p] [CONFIG_FILE] [REAL_CONFIG_FILE]
STAGE1 :指定stage1 文件所在绝对路径。
DEVICE :指定vstage1 装载的位置。
STAGGE2 :指定stage2 文件所在绝对路径。
ADDR :指定装载stage2 的位置,如果不写,系统自动决定。
例如:
boot 为独立分区时:
grub>root (hd0,0)
grub>install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf
 
boot 为非独立分区时:
grub>root (hd0,0)
grub>install (hd0,0)/boot/grub/stage1 (hd0) (hd0,0)/boot/grub/stage2 p (hd0,0)/boot/grub/grub.conf
该句可以写成如下这样:
grub>root (hd0,0)
grub>install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/grub.conf
注意:
boot 分区为独立分区与非独立分区时,安装方法有区别。

 2. setup 命令

命令格式:
setup [--prefix=DIR] [--stage2=STAGE2_FILE] [--force-lba] INSTALL_DEVICE [IMAGE_DEVICE]
INSTALL_DEVICE :指定安装grub 的位置。
IMAGE_DEVICE :指定要安装的镜象文件。
例如:
[root@RHEL5 ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (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> root (hd0,)
  Possible partitions are:
   Partition num: 0,  Filesystem type is ext2fs, partition type 0x83
   Partition num: 1,  Filesystem type unknown, partition type 0x82
   Partition num: 2,  Filesystem type is ext2fs, partition type 0x83
grub> root (hd0,0)
  Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
  Checking if "/boot/grub/stage1" exists... no
  Checking if "/grub/stage1" exists... yes
  Checking if "/grub/stage2" exists... yes
  Checking if "/grub/e2fs_stage1_5" exists... yes
  Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
  Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
grub>

 3. grub-install 命令

grub-install 拷贝grub 镜象文件到DIR/boot 目录中(可以通过参数--root-directory 指定目录),并用grub shell 安装grub 到MBR 中。
命令格式:
grub-install [OPTION] install_device
例如:
[root@RHEL5 ~]# grub-install hd0
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
# this device map was generated by anaconda
(hd0)     /dev/sda
[root@RHEL5 ~]#

 4. 区别

这3 种方式中,最常用的是grub-install ,其中install 是最底层的方式。setup 是更高一层的方式,而grub-install 是最高级最简单的方式。grub-install 命令安装grub 到MBR 中的时候利用的安装源是/usr/share/grub/i386-redhat/ 下的stage1 、stage2 和各种stage1_5 。而install 命令与setup 命令安装grub 的安装源是/boot/grub 目录中的stage1 、stage2 和各种stage1_5 。所以要使用这两种安装方法来安装grub 到MBR 中的时候,确保/boot/grub 目录中的stage1 、stage2 和各种stage1_5 必须存在。同时grub-install 命令安装的grub 只是利用stage1_5 -> stage2 方式的文件系统方式去查找,如果stage2 不存在,那么系统就不能启动。setup 命令安装的grub 是stage1_5 -> stage2 方式去查找stage2 ,首先监测是否是合适的文件系统的驱动,如果存在就使用文件系统逻辑的方式查找stage2 ;如果找不到就用blocklist 的方式再找stage2 。install 命令安装的grub 使用stage1 -> stage2 方式去查找。

六: 测试

 1.  boot 为独立分区

该测试boot 分区为独立分区。分区情况如下:
[root@RHEL5 ~]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks    Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14          78      522112+  82  Linux swap / Solaris
/dev/sda3              79        3916    30828735   83  Linux
[root@RHEL5 ~]#

 1)  grub-install 命令测试

首先使用grub-install 命令对已安装好的系统进行重新安装grub (因为系统默认的安装方式是用install 安装的)。
[root@RHEL5 ~]# grub-install hd0
Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.
# this device map was generated by anaconda
(hd0)     /dev/sda
[root@RHEL5 ~]#
执行完成之后,使用rm 命令删除/boot/grub 下的stage2 文件,重启系统。会看到有如下的错误出现:

grub loading stage1.5
error 15
   这个时候我们只能进入linux rescue 模式对系统进行修复了,而且只可以使用grub-install 命令对系统进行修复。因为/boot/grub 下的stage2 文件已经被我们删掉了。原因是的安装源已被破坏。这个时候插入光盘,设置为cdrom 启动,输入linux rescue 回车进入rescue 模式中。挂起你的系统到/mnt/sysimage 目录下。执行命令grub-install hd0 命令来重新安装grub 系统可以正常启动。具体操作如下:
boot:linux rescue
根据提示进入系统。
chroot后,grub-install hd0
完成后重新启动系统。可以看到系统正常启动成功了。
备注:
那么在什么情况下使用grub-install 命令来重新安装grub 呢?
1 :grub 被擦掉的时候。2 :/boot/grub 目录下的所有镜像文件都给删除时。 2 :使用grub-install 命令安装的grub 且boot/grub 目录下stage2 文件被误删除时(有人会考虑到把/usr/share/grub/i386-redhat/ 下的stage2 拷贝到/boot/grub 目录中,此方法是不成功的)。

 2)  setup 命令测试

使用setup 命令重新安装grub 到MBR 中。
[root@RHEL5 ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (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> root (hd0,0)
  Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
  Checking if "/boot/grub/stage1" exists... no
  Checking if "/grub/stage1" exists... yes
  Checking if "/grub/stage2" exists... yes
  Checking if "/grub/e2fs_stage1_5" exists... yes
  Running "embed /grub/e2fs_stage1_5 (hd0)"...  15 sectors are embedded.
succeeded
  Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
grub> quit
[root@RHEL5 ~]#
使用rm 命令删除/boot/grub/ 目录中的stage2 文件重启系统。系统仍然可以启动,而且重新生成了stage2 文件。如下:
[root@RHEL5 grub]# cd
[root@RHEL5 ~]# cd /boot//grub/
[root@RHEL5 grub]# ls stage2
stage2
[root@RHEL5 grub]#
现在使用shred 命令删除stage2 文件,再使用rm 命令把stage2 文件删除。重新启动系统。
[root@RHEL5 grub]# shred -v stage2
shred: stage2: pass 1/25 (random)...
shred: stage2: pass 2/25 (ffffff)...
shred: stage2: pass 3/25 (492492)...
shred: stage2: pass 4/25 (888888)...
shred: stage2: pass 5/25 (924924)...
shred: stage2: pass 6/25 (249249)...
shred: stage2: pass 7/25 (cccccc)...
shred: stage2: pass 8/25 (222222)...
shred: stage2: pass 9/25 (db6db6)...
shred: stage2: pass 10/25 (777777)...
shred: stage2: pass 11/25 (999999)...
shred: stage2: pass 12/25 (eeeeee)...
shred: stage2: pass 13/25 (random)...
shred: stage2: pass 14/25 (dddddd)...
shred: stage2: pass 15/25 (000000)...
shred: stage2: pass 16/25 (555555)...
shred: stage2: pass 17/25 (111111)...
shred: stage2: pass 18/25 (444444)...
shred: stage2: pass 19/25 (aaaaaa)...
shred: stage2: pass 20/25 (333333)...
shred: stage2: pass 21/25 (bbbbbb)...
shred: stage2: pass 22/25 (b6db6d)...
shred: stage2: pass 23/25 (666666)...
shred: stage2: pass 24/25 (6db6db)...
shred: stage2: pass 25/25 (random)...
[root@RHEL5 grub]#rm –rf stage2
[root@RHEL5 grub]#reboot
这个时候系统不能再启动了,出现如下显示:
grub loading stage1.5
grub loading,please wait....
现在要恢复系统的话,只能是使用grub-install 命令对系统进行恢复。修复方法与上面相同。

 3)  install 命令测试

使用install 命令重新写MBR 。如下:
[root@RHEL5 ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (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> root (hd0,0)
  Filesystem type is ext2fs, partition type 0x83
grub> install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf
grub> quit
[root@RHEL5 ~]#
使用rm 命令删除/boot/grub/ 目录中的stage2 文件重启系统。系统仍然可以启动,而且重新生成了stage2 文件。如下:
[root@RHEL5 grub]# cd
[root@RHEL5 ~]# cd /boot//grub/
[root@RHEL5 grub]# ls stage2
stage2
[root@RHEL5 grub]#
现在使用shred 命令删除stage2 文件,再使用rm 命令把stage2 文件删除。重新启动系统。
[root@RHEL5 grub]# shred -v stage2
shred: stage2: pass 1/25 (random)...
shred: stage2: pass 2/25 (ffffff)...
shred: stage2: pass 3/25 (492492)...
shred: stage2: pass 4/25 (888888)...
shred: stage2: pass 5/25 (924924)...
shred: stage2: pass 6/25 (249249)...
shred: stage2: pass 7/25 (cccccc)...
shred: stage2: pass 8/25 (222222)...
shred: stage2: pass 9/25 (db6db6)...
shred: stage2: pass 10/25 (777777)...
shred: stage2: pass 11/25 (999999)...
shred: stage2: pass 12/25 (eeeeee)...
shred: stage2: pass 13/25 (random)...
shred: stage2: pass 14/25 (dddddd)...
shred: stage2: pass 15/25 (000000)...
shred: stage2: pass 16/25 (555555)...
shred: stage2: pass 17/25 (111111)...
shred: stage2: pass 18/25 (444444)...
shred: stage2: pass 19/25 (aaaaaa)...
shred: stage2: pass 20/25 (333333)...
shred: stage2: pass 21/25 (bbbbbb)...
shred: stage2: pass 22/25 (b6db6d)...
shred: stage2: pass 23/25 (666666)...
shred: stage2: pass 24/25 (6db6db)...
shred: stage2: pass 25/25 (random)...
[root@RHEL5 grub]#rm –rf stage2
[root@RHEL5 grub]#reboot
这个时候系统不能再启动了,出现如下显示:
grub_

2. boot 为非独立分区
该测试系统分区如下:
[root@rhel5 grub]# Last login: Tue Apr 28 08:02:03 2009 from 192.168.88.81
[root@rhel5 ~]# fdisk -l
Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2544    20434648+  83  Linux
/dev/sda2            2545        2609      522112+  82  Linux swap / Solaris
[root@rhel5 ~]#
boot 分区与根在同一分区中。
grub-install 命令与setup 命令与boot 为独立分区时使用方法一样。而install 命令略有不同。就是在指定路径的时候不能省略boot 目录。如下:
grub>root (hd0,0)
grub>install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/grub.conf
 
以下为测试结果:
使用install 命令重新写MBR 。如下:
[root@RHEL5 ~]# grub
Probing devices to guess BIOS drives. This may take a long time.
    GNU GRUB  version 0.97  (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> root (hd0,0)
  Filesystem type is ext2fs, partition type 0x83
grub>install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/grub.conf
grub> quit
[root@RHEL5 ~]#
使用rm 命令删除/boot/grub/ 目录中的stage2 文件重启系统。系统仍然可以启动。
现在使用shred 命令删除stage2 文件,再使用rm 命令把stage2 文件删除。重新启动系统。
[root@RHEL5 grub]# shred -v stage2
shred: stage2: pass 1/25 (random)...
shred: stage2: pass 2/25 (ffffff)...
shred: stage2: pass 3/25 (492492)...
shred: stage2: pass 4/25 (888888)...
shred: stage2: pass 5/25 (924924)...
shred: stage2: pass 6/25 (249249)...
shred: stage2: pass 7/25 (cccccc)...
shred: stage2: pass 8/25 (222222)...
shred: stage2: pass 9/25 (db6db6)...
shred: stage2: pass 10/25 (777777)...
shred: stage2: pass 11/25 (999999)...
shred: stage2: pass 12/25 (eeeeee)...
shred: stage2: pass 13/25 (random)...
shred: stage2: pass 14/25 (dddddd)...
shred: stage2: pass 15/25 (000000)...
shred: stage2: pass 16/25 (555555)...
shred: stage2: pass 17/25 (111111)...
shred: stage2: pass 18/25 (444444)...
shred: stage2: pass 19/25 (aaaaaa)...
shred: stage2: pass 20/25 (333333)...
shred: stage2: pass 21/25 (bbbbbb)...
shred: stage2: pass 22/25 (b6db6d)...
shred: stage2: pass 23/25 (666666)...
shred: stage2: pass 24/25 (6db6db)...
shred: stage2: pass 25/25 (random)...
[root@RHEL5 grub]#rm –rf stage2
[root@RHEL5 grub]#reboot
这个时候系统不能再启动了,出现如下显示:
grub>
同样现在要恢复系统的话,只能是使用grub-install 命令对系统进行恢复。恢复后系统就可以正常启动了。

七、 修复grub.conf

当系统中的grub.conf 文件被删除掉后。在没有备份的情况下我们只能用grub 交互模式来写grub.conf 文件让系统重新启动起来。正如下图所示:
 
这台测试机的分区如下:
 [root@rhel5 ~]# fdisk -l
 Disk /dev/sda: 21.4 GB, 21474836480 bytes
 255 heads, 63 sectors/track, 2610 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
   Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *           1        2544    20434648+  83  Linux
 /dev/sda2            2545        2609      522112+  82  Linux     swap / Solaris
[root@rhel5 ~]#
boot 分区为非独立分区。grub.conf 文件内容如下:
[root@rhel5 grub]# cat grub.conf
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux Server (2.6.18-92.el5)
        root (hd0,0)
        kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
        initrd /boot/initrd-2.6.18-92.el5.img
现在尝试用如下操作修复grub.conf 文件来启动系统。
grub>root (hd0,0)
grub>kernel /boot/vmlinux-2.6.18-92.el5 ro root=/dev/sda1
grub>initrd /boot/initrd-2.6.18-92.el5.img
grub>boot

 
正常进入系统之后在重新编写grub.conf 文件。

八、 附录

grub 的详细使用说明参考info grub 的帮助内容或登陆http://www.gnu.org/software/grub/grub.html 参考官方说明对grub 更深了解。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值