grub实验记录

  系统类型:SUSE Linux Enterprise Server 11 (x86_64)

 

一、实验原因:处理用户问题时发现系统在重启的时候总是卡住无法进入正常界面。在反复重启的过程中,不停地进入到grub的界面,所以想探究原因,该界面中有两个启动项可以选择:

SUSE Linux Enterprise Server 11 SP1 - 2.6.32.12-0.7

Failsafe -- SUSE Linux Enterprise Server 11 SP1 - 2.6.32.12-0.7

一般来说,如果需要进入单用户我们会在第一个启动选项boot option处输入init=/bin/bash来进入。而redhat或ubuntu等系统是通过选中启动选项,再按“e”键进入编辑页面,在编辑页面中输入相应命令进入单用户。

此处编辑页面的内容是:

# Modified by YaST2. Last modification on Sat Nov 16 09:16:46 CST 2013
default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,1)/boot/message
##YaST - activate

###Don't change this comment - YaST2 identifier: Original name: linux###
title SUSE Linux Enterprise Server 11 SP1 - 2.6.32.12-0.7
root (hd0,1)
kernel /boot/vmlinuz-2.6.32.12-0.7-default root=/dev/disk/by-id/ata-QEMU_HAR DDISK_QM00001-part2 resume=/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001-part1 splas h=silent crashkernel=256M-:128M showopts vga=0x314 ide_core.noprobe=0.0
initrd /boot/initrd-2.6.32.12-0.7-default

###Don't change this comment - YaST2 identifier: Original name: failsafe###
title Failsafe -- SUSE Linux Enterprise Server 11 SP1 - 2.6.32.12-0.7
root (hd0,1)
kernel /boot/vmlinuz-2.6.32.12-0.7-default root=/dev/disk/by-id/ata-QEMU_HAR DDISK_QM00001-part2 showopts ide=nodma apm=off noresume edd=off powersaved=off n ohz=off highres=off processor.max_cstate=1 nomodeset x11failsafe vga=0x314
initrd /boot/initrd-2.6.32.12-0.7-default

疑问:该文件是什么文件?有什么作用?

 

二、实验过程:

1、经过查找发现,该文件对应的是/boot/grub/menu.lst。

menu.lst文件详解:

default 0 :默认启动第一个启动选项

timeout 8 :在grub界面处停留8秒若无任何操作则执行默认动作

gfxmenu (hd0,1)/boot/message  :(hd0,1)是指第一块盘的第二个分区(该系统中有两个分区,第一个是swap,第二个是系统分区)。该行可能是记录log的意思(猜测)

title SUSE Linux Enterprise Server 11 SP1 - 2.6.32.12-0.7 :给启动分区命名(title是关键字,后面接的名字可以随便填并没有实际意义)

root (hd0,1) :指定第一块盘的第二个分区是将要启动的系统或内核文件所在的分区

kernel /boot/vmlinuz-2.6.32.12-0.7-default ~~~~:指定要运行的内核文件,后面的各种参数暂时未搞明白

initrd /boot/initrd-2.6.32.12-0.7-default :为要运行的内核指定其可用的ramdisk(其版本必须要与内核版本保持一致)

第二个启动选项与第一个基本一致。总结起来最主要的几个参数是:

title

root

kernel

initrd

2、此时将/boot/grub/menu.lst文件备份后删除重启系统。发现系统没有出现启动引导界面,直接进入一个grub命令行。

执行命令find /boot/grub/stage1,显示(hd0,1) 说明系统是安装在(hd0,1)上。

执行root (hd0,1) 指定kernel所在的盘和分区

执行kernel /boot/vmlinuz-2.6.32.12-0.7-default 指定内核

重启,发现启动在卡住,无法起来。发现没有指定initrd。

重复上述步骤并加一条initrd /boot/initrd-2.6.32.12-0.7-default。

系统正常启动。

 

三、总结

实践出真知

posted @ 2018-03-26 11:00  骄傲的肉包  阅读(245)  评论(0编辑  收藏  举报