📄 系统引导管理器grub学习笔记 linuxsir_org.htm
字号:
<P></P>
<P>如果要将 GRUB 安装到 /dev/hda5 的引导记录中,应输入:<BR>
<DIV class=codeblock><CODE>grub> setup (hd0,4)</CODE></DIV>
<P></P>
<P>现在,已安装 GRUB。引导系统时,应该立即以 GRUB 的控制台方式结束(如果安装到
MBR)。现在,应创建引导菜单,这样就不必在每次引导系统时都输入那些命令。</P>
<P>从软盘启动grub<BR>制作启动盘后可以用软盘启动引导硬盘上的操作系统,
插入制作好的启动软盘,进入BIOS设定软盘启动。软盘启动成功后就会进入grub的命令行模式<BR>
<DIV class=codeblock><CODE>grub></CODE></DIV>
<P></P>
<P>要启动一个操作系统,首先指定引导哪个分区上的系统,例如要引导指第一个硬盘上的第一个分区的操作系统,先键入<BR>
<DIV class=codeblock><CODE>grub>root (hd0,0)</CODE></DIV>
<P></P>
<P>接着如果要启动的是Windows系统,键入<BR>
<DIV class=codeblock><CODE>grub>chainloader (hd0,0)+1</CODE></DIV>
<P></P>
<P>注意(hd0,0)要随着硬盘和分区的不同而改变数字。<BR>如果要引导Linux或其他系统,应键入<BR>
<DIV class=codeblock><CODE>grub>kernel (hd0,0)/boot/vmlinuz
root=/dev/hda1</CODE></DIV>
<P></P>
<P>注意hda1参数也要随着硬盘和分区的不同而改变,如从第二个硬盘的第一个分区引导则用hdb1。<BR>最后敲入boot就可以启动系统了。<BR>在任何时候不能确定命令或者命令的参数都可以按Tab获得相关的帮助。用上下键可以获得命令的历史记录。其实这些命令就是menu.lst的启动描述,您也可以根据那些描述来自己键入启动命令,最后敲入boot就可以引导系统了。<BR><FONT
size=4><B><BR>七、GRUB的交互性<BR></B></FONT></P>
<P>GRUB 最好的优点之一就是其强健的设计 -- 在不断使用它时请别忘了这点。如果更新内核或更改它在磁盘上的位置,不必重新安装
GRUB。事实上,如有必要,只要更新 menu.lst 文件即可,一切将保持正常。<BR>只有少数情况下,才需要将 GRUB
引导装入器重新安装到引导记录。首先,如果更改 GRUB root 分区的分区类型(例如,从 ext2 改成
ReiserFS),则需要重新安装。或者,如果更新 /boot/grub 中的 stage1 和 stage2 文件,由于它们来自更新版本的
GRUB,很有可能要重新安装引导装入器。其它情况下,可以不必理睬!<BR>GRUB的最大的特点就是交互性特别强。在开机时,按一下“c”,将进入GRUB
控制台。显示如下:<BR>
<DIV class=codeblock><CODE>GRUB version 0.5.96.1 (640K lower / 3072K upper
memory)<BR>[ Minimal BASH-like line editing is supported. For the first
word, TAB<BR>lists possible command completions. Anywhere else TAB lists
the possible<BR>completions of a device/filename.
]<BR>grub></CODE></DIV>
<P></P>
<P>欢迎使用 GRUB 控制台。现在,再研究命令:<BR>将通过GRUB 控制台绕过lilo来启动RedHat linux,<BR>
<DIV class=codeblock><CODE>grub> root (h</CODE></DIV>
<P></P>
<P>现在,按一次 Tab 键。如果系统中有多个硬盘,GRUB 将显示可能完成的列表,从 "hd0" 开始。如果只有一个硬盘,GRUB 将插入
"hd0,"。如果有多个硬盘,继续进行,在 ("hd2") 中输入名称并在名称后紧跟着输入逗号,但不要按 Enter 键。部分完成的 root
命令看起来如下:<BR>
<DIV class=codeblock><CODE>grub> root (hd0,</CODE></DIV>
<P></P>
<P>现在,继续操作,再按一次 Tab 键。GRUB 将显示特定硬盘上所有分区的列表,以及它们的文件系统类型。在我的系统中,按 Tab
键时得到以下列表:<BR>
<DIV class=codeblock><CODE>grub> root (hd0, (tab,按tab一下键)<BR>Possible
partitions are:<BR>Partition num: 0, Filesystem type is fat, partition
type 0x6<BR>Partition num: 2, Filesystem type is ext2fs, partition type
0x83<BR>Partition num: 4, Filesystem type unknown, partition type
0x7<BR>Partition num: 5, Filesystem type is ext2fs, partition type
0x83<BR>Partition num: 6, Filesystem type is fat, partition type
0xb<BR>Partition num: 7, Filesystem type is fat, partition type
0xb<BR>Partition num: 8, Filesystem type is ext2fs, partition type
0x83<BR>Partition num: 9, Filesystem type unknown, partition type
0x82</CODE></DIV>
<P></P>
<P>如您所见,GRUB 的交互式硬盘和分区名称实现功能非常有条理。这些,只需要好好理解 GRUB
新奇的硬盘和分区命名语法,然后就可以继续操作了<BR>
<DIV class=codeblock><CODE>grub> root (hd0,8)</CODE></DIV><BR>现在已安装了
root 文件系统,到装入内核的时候了<BR>
<DIV class=codeblock><CODE>grub> kernel /boot/vmlinuz-2.4.2
root=/dev/hda5 ro<BR>[Linux-bzImage, setup=0x1200,
size=0xe1a30]</CODE></DIV><BR>您已经安装了 root 文件系统并装入了内核。现在,可以引导了。只要输入
"boot",Linux 引导过程就将开始。是不是很cool啊,GRUB的menu.lst更像一个linux下的脚本程序。<BR><FONT
size=4><B><BR>八、常见grub除错方法的思路<BR></B></FONT>
<P></P>
<P>首先进去Linux的rescue模式!<BR>用软盘或光盘启动,然后在启动的提示符输入:linux
rescue<BR>按照提示进入一个Shell状态,你可以到/mnt/下面看到一个sysimage这么目录,进去以后,就是你安装linux的/分区.<BR>使用命令将根分区变为当前目录的根分区:chroot
/mnt/sysimage<BR>然后转到/sbin/这个目录中.<BR>使用fdisk -l 显示当前分区情况,然后使用#grub-install
/dev/hdx(x为你使用的是那块硬盘安装的,一般情况下是hda)<BR>使用exit推出chroot,再使用exit退出linux
rescue模式,系统将重新启动!取出光盘,应该可以看到grub安装好了.<BR>在具体的环境中,编辑/boot/grub/grub.conf文件和menu.lst文件.<BR><FONT
size=4><B><BR>九、GRUB背景,具体做法是怎样?<BR></B></FONT></P>
<P><FONT color=red><BR>问:我想请教一下,要修改Mandrake
9下的GRUB背景,具体做法是怎样?<BR></FONT></P>
<P>答: 文件/boot/grub/splash.xpm.gz 就是GRUB启动后的背景图象。<BR>
<DIV class=codeblock><CODE>#gzip -d splash.xpm.gz</CODE></DIV><BR>然后再<BR>
<DIV class=codeblock><CODE>more splash.xpm<BR>/* XPM */<BR>static char *
splash_xpm[] = {<BR>"640 480 15 1",<BR>" c
None",</CODE></DIV><BR>发现了什么?<BR>我是从中知道了,这个图象是640*480象素的。15,1,不太明白什么意思但大概和色位色深有关系(专业术语不太懂)。
<P></P>
<P>剩下的事,就是把自已喜欢的图片做成的640*480的,然后再用GIMP修改一下色深,好像是14还是16
,我记不太清了,自己试一下吧。<BR>最后将图片保存成*.xpm格式,而且要保证当用more查看该图片时,得到的信息为“640 480 15
1"(记得千成不能弄错了,因为错了的话,有可能会使GRUB垮掉而不能启动系统哦!)</P>
<P>最后将制作成的图片改名为splash.xpm,放在/boot/grub文件夹下(不用管splash.xpm.gz)<BR>怎么样,是不是觉得很棒呢!</P>
<P><FONT size=4><B><BR>十、相关文档<BR></B></FONT></P>
<P><A
href="http://www.linuxsir.org/main/?q=node/129">《系统引导管理器GRUB,为初学者指南》</A><BR><A
href="http://www.linuxsir.org/main/?q=node/123">《GNU GRUB
手册和FAQ》</A><BR><A href="http://www.linuxsir.org/main/?q=node/37">《以WINGRUB
引导安装Fedora 4.0 为例,详述用WINGRUB来引导Linux的安装》</A><BR><A
href="http://www.linuxsir.org/main/?q=node/127">《在Linux系统中存储设备的两种表示方法》</A></P></DIV>
<DIV class=links>By 北南南北 at 2005/12/16 - 10:11 | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/1">Linux</A> | <A
href="http://www.linuxsir.org/main/?q=taxonomy/term/25">基础知识</A> | <A
title=共享你有关本文的思想和意见。
href="http://www.linuxsir.org/main/?q=comment/reply/130#comment">参与评论</A>
| 3384 阅读</DIV></DIV><A id=comment></A>
<FORM action=?q=comment method=post>
<DIV><INPUT type=hidden value=130 name=edit[nid]> </DIV></FORM><!-- end content -->
<DIV id=footer>
<CENTER><A href="http://www.linuxsir.org/"><IMG
src="系统引导管理器GRUB学习笔记 LinuxSir_Org.files/logo.jpg"></A> <BR><A
href="http://www.miibeian.gov.cn/"><FONT color=blue
size=3><B>闽ICP备06025536号</B></FONT></A><BR>
<SCRIPT language=JavaScript
src="系统引导管理器GRUB学习笔记 LinuxSir_Org.files/cyberpolice.htm"></SCRIPT>
<BR><A href="http://www.linuxsir.org/main/?q=node/78"><FONT color=blue
size=3><B>© 2002-2006 LinuxSir.Org</B></FONT></A><BR></CENTER></DIV></TD>
<TD id=sidebar-right>
<DIV class="block block-block" id=block-block-2>
<H2 class=title>基础知识</H2>
<DIV class=content>
<UL>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/23">安装配置</A>
<LI><A
href="http://www.linuxsir.org/main/?q=taxonomy/term/1/25/">基础入门</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/22/">硬件解决</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/21">软件管理</A>
<LI><A
href="http://www.linuxsir.org/main/?q=taxonomy/term/35/48/">重要资源</A>
</LI></UL></DIV></DIV>
<DIV class="block block-block" id=block-block-4>
<H2 class=title>软件应用</H2>
<DIV class=content>
<UL>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/30">网络工具</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/32">图形图像</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/31">音乐视频</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/49">字体中文</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/33">软件其它</A>
</LI></UL></DIV></DIV>
<DIV class="block block-block" id=block-block-5>
<H2 class=title>网络服务器</H2>
<DIV class=content>
<UL>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/27">文件服务器<A>
<LI><A
href="http://www.linuxsir.org/main/?q=taxonomy/term/28">Web服务器</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/29">邮件服务器</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/37">数据库应用</A>
<LI><A href="http://www.linuxsir.org/main/?q=taxonomy/term/50">服务器其它</A>
</LI></UL></DIV></DIV>
<DIV class="block block-comment" id=block-comment-0>
<H2 class=title>最新评论</H2>
<DIV class=content>
<DIV class=item-list>
<UL>
<LI><A
href="http://www.linuxsir.org/main/?q=node/222#comment-624">错了</A><BR>13
min 5 sec 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/222#comment-623">q</A><BR>32
min 42 sec 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/222#comment-622">有些道理</A><BR>54
min 11 sec 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/219#comment-621">"内置的摄像头也能用这个吗?"</A><BR>13
hours 59 min 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/80#comment-620">终于知道了...</A><BR>23
hours 14 min 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/106#comment-619">okok</A><BR>2
days 14 hours 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/93#comment-618">那要除去阴影呢?</A><BR>3
days 19 hours 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/227#comment-617">不错的机会</A><BR>4
days 6 hours 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/221#comment-616">配置可执行程序的路径</A><BR>4
days 12 hours 前
<LI><A
href="http://www.linuxsir.org/main/?q=node/222#comment-615">修改hostname出现的问题</A><BR>5
days 2 hours
前</LI></UL></DIV></DIV></DIV></TD></TR></TBODY></TABLE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -