⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 用实验快速掌握grub和lilo.txt

📁 自己搜集的关于linux的grub引导的文章
💻 TXT
字号:
用实验快速掌握grub和lilo

 

[实验目的]

1.灵活应用grub和lilo引导系统。

2.当系统出现无法引导时,会快速修复。

 

[实验要求]

1.RH8.0系统。

2.能够熟练应用rescue模式,应急实验中无法预料的错误。

 

[实验步骤]

1.安装grub。

    情景:假设你现在用grub引导系统,今天grub.conf这个文件突然丢失啦,开机出现的grub如下:grub>,而且你又不能确定系统装在哪个分区。

1) 创建情景,手动删除/boot/grub/grub.conf

   # mv /boot/grub/grub.conf   /boot/grub/grub.conf.BAK

2) 重启,出现假设的情景。

   # reboot

3) 首先,学会在不用光盘rescue模式进入系统。

① 用root (hdx,x)定位到每个分区。

   grub> root (hd0,0)

   注意:a.(hdx,x)是给BIOS看的,hd0表示第1个硬盘,hd1表示第2个硬盘,逗号后面的数字0表示第1个分区,1表示第2个分区以此类推。

   b.作这一步的目的是找到含vmlinuz和initrd*.img文件的那个分区,及根目录分区/。

   c.寻找的方法如下:

   grub> root (hd0,0)

   显示:什么文件系统,什么分区系统

   grub> kernel /<tab键>

   显示:有什么目录和文件。由此找出包含/boot/vmlinuz和initrd*.img文件的分区,及根目录/分区。也有可能,/boot和/在同一个分区。这里姑且,/boot和/独立分区。在同一分区的情况会另有说明。

   d.root后,括弧前有个空格。

②根据上述方法,假设找到/boot分区在(hd0,0),/分区在(hd0,10)。

③现在打如下列命令,进入系统:

  grub> root (hd0,0)<回车键>

  grub> kernel /vmlinuz-<tab键>补全<空格键>ro<空格键>root=/dev/hda11<回车键>

  grub> boot<回车键>

  注意:a./dev/hdax是给linux内核看的,对于同一个分区,hdax里的x要比(hd0,x)里的x大1。

  b.如果,你找出的/和/boot分区不在(hd0,)上,而在(hd1,x)上,那么可能在root=/dev/hda11这而变为:root=/dev/hdbx啦,x根据(hd1,x)里的x而定,比它大1,这个上面说过。

4) 创建一个/boot/grub/grub.conf,方法为拷贝文档里的样本。

   # cp  /usr/share/doc/grub-<tab键>补全/menu.lst    /boot/grub/grub.conf

   原文如下(等于号中间的部分):

=======================================

#

# Sample boot menu configuration file

#

 

# Boot automatically after 30 secs.

timeout 30

 

# By default, boot the first entry.

default 0

 

# Fallback to the second entry.

fallback 1

 

# For booting GNU/Hurd

title  GNU/Hurd

root   (hd0,0)

kernel /boot/gnumach.gz root=hd0s1

module /boot/serverboot.gz

 

# For booting GNU/Linux

title  GNU/Linux

root (hd1,0)

kernel /vmlinuz root=/dev/hdb1

 

# For booting Mach (getting kernel from floppy)

title  Utah Mach4 multiboot

root   (hd0,2)

pause  Insert the diskette now!!

kernel (fd0)/boot/kernel root=hd0s3

module (fd0)/boot/bootstrap

 

# For booting FreeBSD

title  FreeBSD 3.4

root   (hd0,2,a)

kernel /boot/loader

 

# For booting OS/2

title OS/2

root  (hd0,1)

makeactive

# chainload OS/2 bootloader from the first sector

chainloader +1

# This is similar to "chainload", but loads a specific file

#chainloader /boot/chain.os2

 

# For booting Windows NT or Windows95

title Windows NT / Windows 95 boot menu

rootnoverify (hd0,0)

makeactive

chainloader  +1

# For loading DOS if Windows NT is installed

# chainload /bootsect.dos

 

# For installing GRUB into the hard disk

title Install GRUB into the hard disk

root    (hd0,0)

setup   (hd0)

 

# Change the colors.

title Change the colors

color light-green/brown blink-red/blue

===================================================

现在假设,你只想引导linux和windows系统,那么只保留下面部分就行,其他的要么注释掉,要么删除。保留部分如下(等于号中间的部分):

==============================================

# For booting GNU/Linux

title  GNU/Linux

root (hd1,0)

kernel /vmlinuz root=/dev/hdb1

 

# For booting Windows NT or Windows95

title Windows NT / Windows 95 boot menu

rootnoverify (hd0,0)

makeactive

chainloader  +1

# For loading DOS if Windows NT is installed

# chainload /bootsect.dos

==============================================

根据测试,(hd0,0)为/boot分区,(hd0,10)为/分区,而且,用fdisk -l 找到C:\ ,这里假设为:/dev/hda2,那么给BIOS看的东西就是(hd0,1),所以,现在做相应修改如下(等于号中间的部分):

==============================================

# For booting GNU/Linux

title  GNU/Linux

root (hd0,0)

kernel /vmlinuz ro root=/dev/hda11

 

# For booting Windows NT or Windows95

title Windows NT / Windows 95 boot menu

rootnoverify (hd0,1)

makeactive

chainloader  +1

# For loading DOS if Windows NT is installed

# chainload /bootsect.dos

==============================================

如果你有其他系统,请做相应修改。另外,如果你觉的title太土的话,也可以修改一下。

5) 重新安装grub,检查一下上述文件有无错误。

   # grub-install  /dev/hda

6) 重启后,应该能看到grub的选择菜单,虽然土了一点,但绝对能用。

7) 其次,如果你有安装光盘,可以利用rescue模式,进入系统。

① 安装光盘放入光驱,写linux rescue | 选择English | 选择 us 键盘 | 点击Continu| OK

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -