grub4dos初级教程
CHM图文版 下载:
http://lianjiang2007.ys168.com
http://lianjiang2004.ys168.com
===============================================
grub4dos初级教程
lianjiang 2009年4月
前言: 为何写此初级教程?
假如你是第一次听说grub,你可能说我不需要grub。那么,你是否用过“一键ghost”,或者“矮人DOS工具箱”?如果你用过的话,那么你实际上已经在用grub了。包括本人的“GGhost一键恢复”在内的大多数windows下安装的一键恢复类工具及其它dos类维护工具合集,都是基于grub的。
grub4dos相关的资料互联网上并不少,grub4dos软件包里也有说明文件,可是绝大多数资料并不适合刚接触grub的人。初学者下载了grub4dos软件包后,即使大概看了readme.txt文件后,也很可能仍然是一团雾水,不知从何处入手。出现这种状况的一个主要原因是,此软件是作者利用业余时间开发的,开发者在有限的时间里集中精力于排除软件bug,从而无过多剩余精力撰写文档。
其实,初步使用这个软件并不难,可以说非常简单。下面的内容参考了有关资料,并结合自己的使用经验,供初学者参考,希望能对你入门grub有所帮助。我自身也是接触grub不久,对grub的了解还很肤浅,错误之处,在所难免,还望不吝指出。
--------------------------------------------------------------------------------
致谢
本文的完成,参考、引用了众多的资料,不少已找不到原始出处。初稿完成后,网友们提出了不少意见和建议,也得到了软件开发者的支持和鼓励。在此一并表示感谢。
lianjiang 2007.03 初稿
2009.04 最后修改
【注: 我的网盘:
http://lianjiang2007.ys168.com http://lianjiang2004.ys168.com 也提供部分grub相关文件及资料的下载。】
目录
1 grub4dos初级教程-入门篇
1.1 grub简介
1.2 如何获得grub4dos最新版
1.3 如何安装grub4dos
1.3.1 通过Windows NT的启动菜单进入grub4dos
1.3.2 通过DOS启动grub
1.3.3 通过mbr启动grub
1.3.4 通过Windows VISTA/Window 7的启动菜单进入grub4dos
1.4 如何使用grub4dos
1.5 结言
2 grub4dos初级教程-应用篇
2.1 硬盘上的应用
2.1.1 加载软盘镜像
2.1.2 启动WinPE
2.1.3 启动系统
2.1.4 引导光盘镜像(ISO仿真)
2.2 光盘上的应用
2.2.1 grub引导的可启动光盘
2.2.2 BCDW引导GRUB的可启动光盘
2.3 软盘上的应用
2.3.1 通过DOS启动grub的软盘应用
2.3.2 引导扇区安装了GRLDR引导记录的软盘应用
2.4 优盘上的应用
2.5 结言
3 grub4dos初级教程-进阶篇
3.1 设置密码
3.2 菜单内置
3.3a 使用个性化grub4dos文件名 (grubinst)
3.3b 用批处理自动给grldr改名 (适用于最新版grldr)NEW!
3.4 安装Windows XPE到逻辑分区
3.5 利用savedefault命令传递参数的方法与应用
3.6 利用dd命令传递参数的方法与应用 NEW!
4 附录
Grub legacy
4.01 Grub 命令索引
4.02 Grub 简体中文化版使用方法
4.03 GRUB安装配置使用汇总
4.04 Grub命令使用详解
4.05 GRUB三步通
4.06 Grub相关安装配置及使用实例汇总讲析
Grub2资料
4.07 GRUB2使用简介 by bean NEW!
4.08 GRUB2高级教程 by bean NEW!
Grub4dos资料
4.09 gfxmenu定制高级教程(新增可定制菜单) by bean NEW!
4.10 如何使用grubinst_gui by bean
Grub4dos官方文档
4.11 Grub4dos_tutorial (英文)
4.12 Grub4dos简介
4.13 Grub4dos安装和启动
4.14 Grub4dos新手指南
4.15 Grub4dos高级功能
4.16 Grub4dos命令索引
4.17 Grubinst使用介绍
4.18 Grub4dos readme (英文)
4.19 Grub4dos readme (中文)
--------------------------------------------------------------------------------
正文:
1 grub4dos初级教程-入门篇
1.1 grub简介
GRUB 是一个遵从Multiboot(多重启动)规范的启动管理程序。现在接触到的有3种,即GNU Grub Lagecy , GNU Grub2 和 Grub for dos(grub4dos)。
GNU GRUB Lagecy其实就是原来的 GNU GRUB 0.xx ,最新版是2005年发布的GNU GRUB 0.97。 目前已停止开发,并改名为 GNU GRUB Lagecy。
GNU GRUB2是第二代GRUB,它将取代原来的GNU GRUB(例如0.9x版),但目前还处于开发阶段,尚未发布正式版。
GNU GRUB Lagecy和GNU GRUB2都是 GNU 组织的项目。
GRUB for DOS(GRUB4DOS)是一个以 GNU GRUB 为基础的功能强大的引导器。它可以在 DOS 和 LINUX下运行,也可以通过其他引导器来运行,还可以作为MBR运行。GRUB4DOS内置了功能完善的 BIOS 级磁盘仿真。
下面以比较广泛使用的GRUB4DOS为基础进行说明。GNU GRUB与GRUB4DOS的不同之处,可参看相关说明文件。
1.2 如何获得grub4dos最新版
可从以下网址下载GRUB4DOS最新版及较早版本。
http://download.gna.org/grub4dos/
http://download.gna.org/grubutil/
http://grub4dos.jot.com/WikiHome
https://gna.org/projects/grub4dos/
http://grub4dos.sourceforge.net/wiki (官方说明文档)
1.3 如何安装grub4dos?
下载grub4dos后,解压缩后就可以了。核心文件有下面这几个:grldr和grub.exe,及menu.lst(此为样本,需修改)。如果你需要中文支持,就用chinese子目录中的文件。
安装方法常见的有下面3种。
1.3.1 通过Windows NT的启动菜单进入grub4dos
将grldr文件复制到c:\,去掉boot.ini的只读属性,然后修改c:\boot.ini文件,在boot.ini的最后面加一行:
c:\grldr="Start GRUB4DOS"
并将boot.ini中的timeout值设置为大于0的数字,如:timeout=5,然后保存boot.ini,改回只读属性。
编辑boot.ini前,可在cmd下输入:
attrib -s -r -h c:\boot.ini
解除boot.ini的只读属性,编辑完后输入:
attrib +s +r +h c:\boot.ini
恢复boot.ini的原有属性。
这样,编辑完重新启动计算机,在NT的启动菜单就会出现“Start GRUB4DOS”这一项,选择该项即可进入grub4dos的环境。【图1】
此方法的优点是:不需要修改MBR。
初学者使用grub一般都需要grub菜单,把准备好的menu.lst文件放到C:\下(也可放到其它分区根目录或其它指定目录)。menu.lst的编写方法可参考readme.txt或者别人提供的menu.lst。在下面的“1.4 如何使用grub4dos”中将作简单介绍。
1.3.2 通过DOS启动grub
将机器通过任何可能的方式(软盘,U盘,光盘等)启动到DOS环境(最好是纯DOS环境,即不加载任何驱动程序和TSR程序的DOS环境),然后在DOS下或者AUTOEXEC.BAT中运行grub.exe,即可进入grub4dos。
也可在DOS/Windows9x的CONFIG.SYS中使用下列任一方式启动grub。
DEVICE=GRUB.EXE
INSTALL=GRUB.EXE
SHELL=GRUB.EXE
此方法的优点是:不需要修改MBR;可根据需要在脚本或者其它DOS程序中启动GRUB4DOS。
菜单文件menu.lst可保存在grub文件所在目录或其它指定路径。
1.3.3 通过mbr启动grub
通过软件包里的bootlace.com(可运行于DOS/Win9x)安装GRLDR引导记录到硬盘或者硬盘映像文件的主引导记录,或者安装到软盘或者软盘映像的引导扇区。电脑启动时,通过击热键(默认为空格键,可自定义)来启动grub。
比如:
在DOS下安装GRLDR代码到主引导记录:
bootlace.com 0x80
在DOS下安装GRLDR代码到软盘:
bootlace.com --floppy --chs 0x00
在DOS下安装GRLDR代码到软盘映像:
bootlace.com --floppy --chs floppy.img
我所使用的命令为:
bootlace --force-backup-mbr --boot-prevmbr-first --time-out=3 --hot-key=0x3920 --mbr-disable-floppy 0x80
表示安装GRLDR代码到MBR时,备份原MBR(--force-backup-mbr),默认启动原MBR,即启动原windows xp系统(--boot-prevmbr-first),等待时间3秒(--time-out=3),热键为空格键(--hot-key=0x3920), 不搜索软盘上的GRLDR(--mbr-disable-floppy)。
也就是说启动时等待3秒,3秒内不击热键的话,启动windows xp;3秒内击热键则启动grub4dos。
bootlace的其它参数及自定义热键用法可参看readme.txt文件。
装入mbr后,再将grldr和menu.lst文件复制到某分区的根目录(现在支持的文件系统是FAT12,FAT16, FAT32, NTFS,EXT2 or EXT3 的分区。对于Windows用户,最好是fat分区),menu.lst也可保存到其它指定位置。
此方法的优点是:不依赖于操作系统;能够自动搜索硬盘上各个分区的grldr文件。
另外,2000/xp/2003/vista环境下可用另一软件grubinst来把GRLDR引导记录安装到硬盘的MBR。grubinst具有图形界面和命令行两种工作模式供选用,并附有比较详细的使用说明,很易于使用。
1.4 如何使用grub4dos
对于多数没有或很少接触过linux的windows用户来说,刚开始使用grub时离不开菜单。也就是说,使用grub前,我们要准备menu.lst文件。
下面是一个menu.lst的例子。(以#开始的行,表示注释,不执行)
# 默认延迟时间(秒)
timeout 30
# 第一项为默认值
default 0
# 设置图形背景文件
splashimage (hd0,0)/boot/grub/xp2008.gz
# 设置中文支持的字体文件
fontfile (hd0,0)/boot/grub/fonts
title 使用map启动本地硬盘上的瑞星杀毒软盘镜像文件
map (hd0,0)/boot/grub/rav.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title 使用memdisk启动本地 Win98 软盘镜像文件
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/win98.img
title 使用memdisk启动本地硬盘上的瑞星杀毒软盘压缩镜像文件
root (hd0,0)
kernel /boot/grub/memdisk.gz c=80 h=12 s=36 floppy
initrd /boot/rav.zip
title 启动第一主分区(hd0,0)上的操作系统
rootnoverify (hd0,0)
makeactive
chainloader +1
title 启动第二主分区(hd0,1)上的操作系统
rootnoverify (hd0,1)
makeactive
chainloader +1
title 重启
reboot
title 关机
halt
此菜单文件的运行效果如下图。【图2】
参考这个例子,我们就可以根据自己需要对菜单进行修改。
比如从网上下载了效率源的镜像文件,文件名为XLY.IMG。我们只需把
title 使用memdisk启动本地 Win98 软盘镜像文件
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/win98.img
改成
title 硬盘检测修复工具 效率源 (memdisk)
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/xly.img
或者改成
title 硬盘检测修复工具 效率源 (map)
map (hd0,0)/boot/grub/xly.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
同时把xly.img文件保存到第一主分区(一般是C:)的boot\grub目录下。
当然也可以保存到其它路径。
比如xly.img文件保存到C:\boot下,则menu.lst文件相应改为:
map (hd0,0)/boot/xly.img (fd0)
又如xly.img文件保存到D:\test下,则menu.lst文件相应改为:
map (hd0,4)/test/xly.img (fd0)
(参看下面的注意d)
从上面的例子可以看出,启动软盘镜象,有两种方式,即用memdisk或用map。
用memdisk时,img文件可压缩;在img文件大小为非1.44MB或2.88MB标准镜像时,需要指定CHS参数。img文件的CHS参数可用winimage获得。
即例子中的:
title 使用memdisk启动本地硬盘上的瑞星杀毒软盘压缩镜像文件
root (hd0,0)
kernel /boot/grub/memdisk.gz c=80 h=12 s=36 floppy
initrd /boot/rav.zip
另外,菜单文件中的文件路径可用相对路径(如:/boot/rav.zip)或绝对路径(如:(hd0,0)/boot/grub/xly.img)表示。
map方式对软盘映像大小没有限制,但要求必须连续存放。改进的map --mem则无此限制。
比如:
map --mem /boot/xxx.ima (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
注意:
a, 菜单文件中所用的memdisk.gz文件,不包括在grub4dos的发行包里,需自行准备。可从gnu grub软件包或从其它基于grub的工具(如一键ghost,本人的gghost)中获得。
b, 菜单中所用的其它文件如xp2008.gz(背景文件)、fonts(中文字体文件)及各种镜像文件等,均需拷贝到文件中指定路径。 fontfile命令不可单独使用,需与splashimage一起使用。
c, 菜单文件中的命令全部使用小写。
d, 初学者使用绝对路径时要注意GRUB对设备的命名方法。系统的第一个硬盘驱动器表示成(hd0),其上的第一个分区表示为(hd0,0),也就是说对于硬盘,采用(hdx,y)的形式来表示,x、y都是从0开始计数的,x表示硬盘号,y表示分区号。
由于主分区只能有四个,所以第一硬盘的四个主分区分别用(hd0,0)~(hd0,3)来表示;逻辑分区则从(hd0,4)开始算,即第一逻辑分区用(hd0,4),第二逻辑分区用(hd0,5)来表示,依次类推。
一般机子的硬盘都是一个主分区,其余是逻辑分区。因此C盘用(hd0,0),D盘用(hd0,4)来表示。 光盘用(cd)表示,第一软驱用(fd0)表示。
如我的硬盘有两个主分区,其余为逻辑分区。用(hdx,y)的方法表示如下图:
下面是我现在使用的菜单效果图及menu.lst文件,供参考。【图3】
color white/green yellow/green
default 1
timeout 3
#fontfile /boot/grub/fonts
#splashimage /boot/grub/bg.xpm.gz
#password --md5 $1$8$D0mfzTIQXv2Ma2b5bWH0b.
title 0, Boot from Hard Drive (hd0,0)
root (hd0,0)
chainloader +1
title 1, GreenGhost (MAP-HOOK)
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title 2, GreenGhost (MEMDISK)
kernel /boot/grub/memdisk.gz c=200 h=2 s=36 floppy
initrd /boot/grub/gghost.img
title 3, GreenGhost (MAP-HOOK)
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader --disable-a20 (fd0)+1
rootnoverify (fd0)
title 4, Microsoft Windows NT/2K/XP
find --set-root /ntldr
chainloader /ntldr
title 5, Microsoft Windows Vista
find --set-root /bootmgr
chainloader /bootmgr
title 6, Boot from Hard Drive (hd0,1)
root (hd0,1)
chainloader +1
title 7, Reboot
reboot
title 8, Shutdown
halt
1.5 结言
Grub4dos具有强大的功能,上面介绍的只是grub4dos的一些最基本用法,更多的用法可在掌握基本用法的基础上,自己查阅资料了解。
--------------------------------------------------------------------------------
2 grub4dos初级教程-应用篇
2.1 硬盘上应用
硬盘上应用grub,首先要进行安装,安装/启动方式主要有3中,即通过Windows NT的启动菜单进入grub4dos;通过DOS启动grub;通过mbr启动grub。【参看1.3 如何安装grub4dos】
安装完grub后,需要准备菜单文件menu.lst。
2.1.1 加载软盘镜像
对于Windows用户,用grub加载软盘镜象是最常用的功能之一。由于windows2k/xp已脱离了dos,因此进行包括系统备份/恢复在内的一些dos下操作,成为初学者的一个难题。以前我们可能就需要用启动光盘等才能进入dos,光盘的特性决定了很难及时方便地更新光盘上的工具。grub的出现与应用,解决了这个难题。我们不仅无需借助其它的介质就能进入dos环境,而且能及时更新工具。网上下载的各种系统维护工具,很多都是img形式,无需把文件提取出来,稍微修改menu.lst就能使用,各种工具也能和谐共处,使用非常方便。
如何把下载的xxx.img加入grub启动菜单呢?
你只要把xxx.img保存到C:\boot\grub目录下,编辑menu.lst,加入下面内容就行了。
title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
注意:
a, 这几行内容不能加在最前面,因为前面是一些对全局有效的设置。
b, 你需要的工具都可以这种方式加进去。
c, 也许你有很多工具,都加进menu的话,显得很乱。平时常用的可能也就一两个工具,不少只是偶尔一用。对于这种情况,可以采取下面的方法。即:把常用的写入菜单,同时在菜单中写一个通用启动img文件的内容。
比如上面的:
title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
可以在启动grub进入菜单后,选择“Boot from Floppy image XXX”后,按“e”进入编辑状态,移动方向键,修改xxx.img为需要启动的文件名,回车,按“b”启动即可。(img文件保存在其它路径的话,则改成相应的路径。)
2.1.2 启动WinPE
有些系统维护操作在dos下操作不太方便,甚至不能进行。WinPE的出现,给我们带来了很多方便。
下面以广受好评的“老九 WinPE 老毛桃修改版_1111 版”为例,介绍如何用grub启动WinPE。 (ISO中已带有安装程序,我这里介绍的是在menu.lst中加入通用的winpe选项。)
步骤:
1, 下载“老九 WinPE 老毛桃修改版_1111 版”,解压后得到BootCD.ISO。
2, 用虚拟光驱或UltraISO等提取iso中的WINPE.IS_,WINNT.XPE和WXPE\SETUPLDR.BIN,把这3个文件拷贝到C:\,并把SETUPLDR.BIN改名为ldrxpe。需要外置程序的,还需把XPEMENU.INI和“外置程序”目录一起拷贝到任一盘符的根目录。【图4】【图5】
3,在menu.lst中加入
title Micro Windows XPE (by LaoMaotao)
chainloader /ldrxpe
启动grub时选择“Micro Windows XPE (by LaoMaotao)”就能启动WinPE了。这样就能在windows界面下进行系统维护、安装等操作。【图6】【图7】【图8】
2.1.3 启动系统
对于单一硬盘装了多系统及多硬盘装了多系统的,用grub可以方便地对各系统进行启动管理。
比如在menu.lst中可加入下面的选项:
title 启动第一硬盘第一主分区(hd0,0)上的操作系统
rootnoverify (hd0,0)
makeactive
chainloader +1
title 启动第一硬盘第二主分区(hd0,1)上的操作系统
rootnoverify (hd0,1)
makeactive
chainloader +1
title 启动Windows NT/2000/XP/2003
find --set-root /ntldr
chainloader /ntldr
title 启动Microsoft Windows Vista
find --set-root /bootmgr
chainloader /bootmgr
title 启动DOS/Windows 95/98/Me
find --set-root /io.sys
chainloader /io.sys
2.2 光盘上的应用
下面介绍两种在光盘上应用grub的方法。
2.2.1 grub引导的可启动光盘
以grldr作为光盘的启动文件引导光盘,加载menu.lst,通过menu菜单选择启动项目。
步骤:
1) 准备必要的img文件,及grldr,menu.lst(根据需要准备字体,背景图片,memdisk.gz等文件)。
2) 编辑menu.lst。引导光盘上的img文件的格式如下:
title GreenGhost (MAP-HOOK)
map --mem (cd)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
菜单中也可引导硬盘上的img文件,比如:
title GreenGhost (MEMDISK)
kernel (hd0,4)/boot/grub/memdisk.gz c=200 h=2 s=36 floppy
initrd (hd0,4)/boot/grub/gghost.img
3) 组织文件。比如在E:\3333下建个grubcd目录,把menu.lst拷贝到此目录下,menu.lst文件将在光盘根目录下。在grubcd目录下建boot\grub目录,保存各种img,字体等文件(也可以保存到其它路径,与menu.lst中的指定的路径要一致)。注意:menu.lst文件中引用的所有文件的文件名在硬盘上显示的需是小写,大写的要改成小写。【图9】
4) 制作ISO。用UltraISO新建一个ISO文件,把E:\3333\grubcd目录下的所有文件加入iso文件;执行“启动光盘”-“加载引导文件”,选择grldr(需把grldr改名为grldr.bin或grldr.bif等)文件。再执行“文件”-“属性”,选上“允许小写字母”选项,保存ISO文件。【图10】【图11】【图12】
也可使用mkisofs.exe或CDIMAGE.EXE等工具制作启动iso(grldr不需改名)。
比如我用CDIMAGE制作iso的批处理是:
cdimage -lgrubcd -t01/01/2007,00:00:00 -h -n -o -d -m -bgrldr grubcd grubcd.iso
5) 用nero等把制作的可启动ISO刻盘。有条件的可先在虚拟机上测试通过后刻盘,或用CD-RW/DVD+RW刻盘。
2.2.2 BCDW引导GRUB的可启动光盘
此法是用BCDW制作启动光盘,通过BCDW执行grldr来加载menu.lst菜单。
步骤:
1) 首先下载BCDW软件包,解压后获取所需文件。
2)组织文件。比如在E:\3333下建个bcdwcd目录,此目录下文件将在光盘根目录下,下面建boot\grub目录和bcdw目录,把软件包中bcdw目录下的bcdw.bin,bcdw.ini和loader.bin拷贝到所建的bcdwcd\bcdw目录下;把grldr、各种img、字体等文件拷贝到bcdwcd\boot\grub目录。menu.lst文件的编辑方法与上面2.1中介绍的相同。
3) 编辑bcdw.ini文件。打开bcdw.ini,找到部分,比如:
C:\ ; Boot from drive C:
\I386\setupldr.bin ; Microsoft Windows XP Setup
上面的就是BCDW启动菜单的例子。在其中加上grub等项,变成:
\images\gghost.img ; GGhost v6.0 (Ghost8.3/11)
\images\mynet.img ; My net (Ghost8.3)(tcp/ip,cd/usb)
\boot\grub\grldr ; Grub4dos
\WXPE\SETUPLDR.BIN ; Micro Windows XPE (by LaoMaotao)
C:\ ; Boot from drive C:
\I386\setupldr.bin ; Microsoft Windows XP Setup
4)制作ISO文件与刻录ISO的方法与2.1中的基本相同。所不同的只是在制作ISO文件时,要把loader.bin(或bcdw.bin)作为ISO的引导文件。【图13】
也可使用mkisofs.exe或CDIMAGE.EXE等工具制作启动iso。
比如我用CDIMAGE制作iso的批处理是:
cdimage -lbcdwcd -t01/01/2007,00:00:00 -h -n -d -o -m -bload.bin bcdwcd bcdwcd.iso
运行后bcdw界面与grub界面的效果如下图。【图14】【图15】
2.3 软盘上的应用
在软盘上应用grub,主要有两种方式,即通过DOS启动grub和把GRLDR引导记录安装到软盘的引导扇区。【参看1.3 如何安装grub4dos】
2.3.1 通过DOS启动grub的软盘应用
先把软盘制作成启动盘,最简单的一种,软盘中只需io.sys,msdos.sys和command.com三个文件。
再把grub.exe和menu.lst拷贝到软盘根目录。
新建一个autoexec.bat文件,里面只需写上4个字母。
grub
然后编辑menu.lst,由于软盘容量所限,一般很难直接在menu中调用软盘上的img文件,因此,主要可用来启动硬盘上的img文件,还可用于对各系统进行启动管理。菜单文件中使用的指定路径的文件(如字体,img文件等),应预先准备好,否则该选项不能运行。(网上也有在软盘有限的容量里,包括众多维护工具的实例,感兴趣的可自行搜索。)
menu.lst文件的例子:
timeout 10
default 0
splashimage (fd0)/boot/grub/xp2008.gz
fontfile (fd0)/boot/grub/fonts
title GreenGhost (MAP-HOOK)
map --mem (hd0,4)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title 寻找硬盘上的/menu.lst
find --set-root /menu.lst
configfile /menu.lst
title 启动第一硬盘第一主分区(hd0,0)上的操作系统
rootnoverify (hd0,0)
makeactive
chainloader +1
title 启动第一硬盘第二主分区(hd0,1)上的操作系统
rootnoverify (hd0,1)
makeactive
chainloader +1
title 重启
reboot
title 关机
halt
2.3.2 引导扇区安装了GRLDR引导记录的软盘应用
GRLDR引导记录安装后,在软盘上只需保留有grldr和menu.lst及menu.lst中引用到的文件。menu.lst文件与“2.3.1 通过DOS启动grub”的软盘中使用的是一样的。
2.4 优盘上的应用
在优盘上应用grub,与软盘类似,主要有两种方式,即通过DOS启动grub和把GRLDR引导记录安装到优盘的引导扇区。【参看1.3 如何安装grub4dos】
首先把U盘用优盘自带工具或usboot,flashboot等制作成dos启动盘,同时设置电脑的cmos里相应的选项,看优盘能否启动进入dos,能的话,可继续往下阅读;不能启动的话,可尝试不同模式、用其它制作工具等,能启动后再往下阅读。
不同的启动模式,U盘启动进入dos后,在你的电脑上可能是A盘,也可能C盘。
由于u盘容量大,在u盘上就可以存放各种工具及WinPE。
当显示为A盘时,使用方法类似于软盘。
menu.lst文件中启动img镜像文件的用法如:
title GreenGhost (MAP-HOOK)
map --mem (fd0)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
当显示为C盘时,使用方法类似于硬盘。
menu.lst文件中启动img镜像文件的用法如:
title GreenGhost (MAP-HOOK)
map --mem (hd0,0)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
在上面的例子里,menu.lst中引用文件使用的是绝对路径,即(fd0)/boot/grub/gghost.img和(hd0,0)/boot/grub/gghost.img,这种用法对于特定的机子是没有问题的。但在同一U盘,要使用到不同机子时,可能带来一个问题。也就是可能不同的机子,要用不同的menu.lst文件,否则不能正常启动工具。那么,能否用什么办法,不用这么麻烦呢?答案是肯定的,那就是使用"find --set-root"和相对路径来实现。这样就不必为U盘被识别为fd还是hd烦恼了。
比如,你可以在u盘根目录建一个特征文件,如myudisk.txt
这样在启动u盘上的img镜像文件就可用下面的方法来实现:
title GreenGhost (MAP-HOOK)
find --set-root /myudisk.txt
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
启动u盘上的WinPE就可用:
title Micro Windows XPE (by LaoMaotao)
find --set-root /myudisk.txt
chainloader /ldrxpe
参考其它示例,通过编辑你的menu.lst,你就能够充分发挥U盘的效能。
2.5 结言
本文写的仅仅是grub4dos的一些最基本应用,Grub4dos更多的功能有待你去尝试和挖掘。
希望这篇文章能有助于你更快地把grub4dos使用起来。
更期待能分享你的成果。
推荐论坛:
时空论坛:
http://bbs.znpc.net
中国DOS联盟论坛:
http://www.cn-dos.net/forum/
无忧启动论坛:
http://bbs.wuyou.com
【注: 我的网盘:
http://lianjiang2004.ys168.com 也提供部分grub相关文件及资料的下载。】
3 致谢
本文的完成,参考、引用了众多的资料,不少已找不到原始出处。初稿完成后,不少网友指出了其中的不足之处,并提出了修改的建议,也得到了软件开发者的支持和鼓励。在此一并表示感谢。
lianjiang 2007.03.09 初稿
2007.03.27 修改
4 附录
这里提供的是部分网络上收集的grub相关资料,供参考。为统一格式,对部分文档进行了重新排版。
4.1 如何使用grubinst_gui
grubinst 可用于在Windows NT/2K/XP 和 Linux/FreeBSD 下把Grub4Dos启动代码安装到MBR/BS。其用法类似于bootlace.com。
grubinst_gui 是运行于Windows系统下的图形界面,利用它可以方便的使用grubinst的功能。
注意:grubinst只负责把GRLDR启动代码安装到 MBR/BS, 你还需要手动把GRLDR文件拷贝到某一FAT16/FAT32分区的根目录里。
grubinst_gui运行后界面如下图。
4.1.1 grubinst_gui新手指南
在Windows NT/2000/XP 下,用以下的步骤可以快速地把Grub4Dos安装到MBR或分区中
前提:你必须拥有FAT16/FAT32的分区。如果全部分区均为NTFS,则请参考最后的部分。
1、下载grubinst,解压
2、双击grubinst_gui.exe
3、在"磁盘"右面的列表中选择需要安装Grub4Dos的硬盘/软盘,如果你有多个磁盘(包括USB移动硬盘&),请留意中显示的磁盘大小,以便选择正确的磁盘。
4、若需要安装到分区,可点击"分区列表"右面的"刷新"按钮,然后从下拉列表中选择需要的分区(支 持FAT12/FAT16/FAT32/EXT2/EXT3)。若需要安装到MBR,这一步可省略。
5、若想以后能恢复原来的MBR/BS,则在"保存文件"中输入用于保存的文件名字。
6、点"安装",出现命令窗口,如果看到"The MBR/BS has been successfully installer", 则说明安装成功。
当然,以上步骤只是安装启动代码,要能正常启动Grub4Dos,还需要以下的步骤:
7、从
http://grub4dos.jot.com/WikiHome 或
http://download.gna.org/grub4dos/ 中下载最新版的Grub4Dos。
8、在压缩包中找到grldr,把它放到FAT16/FAT32分区的根目录中。
9、编辑menu.lst文件(应该放在和GRLDR一样的目录里),以配置启动菜单。
若没有FAT16/FAT32分区,则不能把Grub4Dos安装到MBR/BS,而只能利用NT的启动管理器启动Grub4Dos:
1、下载Grub4Dos,把GRLDR解压到系统盘的根目录里(C:\)
2、编辑C:\boot.ini(此文件是隐藏的),在文件的最后加上
C:\GRLDR="Load Grub4Dos"
这样一行
3、编辑C:\menu.lst文件,以配置启动菜单。
4、下次启动Windows时,会增加"Load Grub4Dos"一项,选择它便能进入Grub4Dos
4.1.2 grubinst_gui使用指南
1、安装Grub4Dos到硬盘/软盘映像中。
在"文件"右面的输入框中输入映像文件名,则按"安装"时会安装到指定的映像中。
当修改的是软盘映像时,需要勾上选项"软盘映像"。
2、选项设置
只读模式:
模拟所需的操作,但不真正地把MBS/BS写到硬盘/映像中。
输出详细信息:
让后台程序grubinst输出更详细的信息,建议使用。
不保存原来的MBR (适用于安装到MBR时)
在修改原来的MBR前,grubinst会把原来的MBR保存到第二个扇区中。若选了这个选项,则屏蔽这一功能。
启动时不搜索软盘 (适用于安装到MBR时)
启动时,若在硬盘上找不到GRLDR,Grub4Dos会试图到软盘上去寻找。若选了这个选项,则屏蔽这一功能。
不引导原来的MBR (适用于安装到MBR时)
若原来的MBR保存在第二个扇区里,则当Grub4Dos找不到GRLDR时,会用原来的MBR来启动。若选了这个选项,则屏蔽这一功能。
优先引导原来的MBR (适用于安装到MBR时)
若选了这个选项,则优先使用原来的MBR来启动。
注意1: Grub4Dos只保留了一个扇区的空间来存储原来的MBR,若原来的MBR超过一扇区,则只有第一扇区被保存,因此不能用原来的MBR来启动。
注意2: 若使用了这一选项,则在启动时会有5秒的等待时间,若你在5秒内按了空格键,则启动Grub4Dos,按其他键或5秒超时的话便引导原来的MBR。等待时间和按键可以定制。
软盘映像
当你把Grub4Dos安装到软盘映像时,请勾上这一选项
注意1: 安装到物理软盘时,并不需要点这一选项
注意2:当你选择了映像文件,并刷新了分区列表时,程序会根据映像文件的类型自动设置这一参数。
注意3:安装到软盘映像或分区时,以上的适用于安装到MBR的各参数将不起作用
等待时间:
设置当优先引导原来的MBR时,启动的等待时间,缺省值是5
热键:
设置当优先引导原来的MBR时,启动Grub的热键,缺省值是空格。
注意:原来版本的grubinst(bootlace.com也一样)利用扫描码来代表按键,比如说,空格是 0x3920。但新版的grubinst允许用字符串来表示按键。比如说,a , ctrl-a , shift-a, alt-a, F1, home, end, space, key-5 (小键盘上的5键) 等等。
额外参数:
你可以在这里输入其他传给后台程序grubinst.exe的参数
3、恢复功能
保存文件:
指定用于保存/恢复的外部文件
从文件中恢复
没有使用了这一选项时,"安装"按钮是正常的安装操作,若保存文件框不是空,则指定用于保存原来的MBR/BS的文件
使用了这一选项时,"安装"按钮的操作变为从指定的保存文件中恢复原来的MBR/BS
从原来的MBR中恢复
使用了这一选项时,"安装"按钮的操作是从第二个扇区中恢复原来的MBR
注意1: 原来的MBR必须是单扇区,否则恢复后不能启动
注意2: 使用这一功能时,"保存文件"应该为空,并且不能选择"从文件中恢复"
4、"测试"按钮
用于显示传给grubinst的参数,但并不真正地调用grubinst。
注意: 这和"只读模式"是不同的。使用"只读模式"时调用了后台的grubinst,只是grubinst 不进行修改MBR/BS的操作。
特别说明:
1,此部分"附录:如何使用grubinst_gui"内容是应部分网友的要求增加的,全部引用自作者的说明文件。计划在官方文档中grubinst_gui相关内容发布后,删除此部分内容。
2,新版已增加对NTFS文件系统的支持,但目前可能仍存在不完善的地方,相关说明及使用方法可参看作者的帖子。
Last edited by lianjiang2004 on 2010-5-3 at 20:25 ]
GRUB4DOS Beginner's Tutorial
CHM graphic version download:
http://lianjiang2007.ys168.com
http://lianjiang2004.ys168.com
===============================================
GRUB4DOS Beginner's Tutorial
Lianjiang April 2009
Foreword: Why write this beginner's tutorial?
If you're hearing about GRUB for the first time, you might say you don't need GRUB. But have you ever used "One-Click Ghost" or "矮人DOS Toolkit"? If you have, then you've actually been using GRUB. Most one-click recovery tools and other DOS-based maintenance tool collections installed under Windows, including my "GGhost One-Click Recovery", are based on GRUB.
There are quite a few materials related to GRUB4DOS on the Internet, and there are also instructions in the GRUB4DOS software package. However, most of these materials are not suitable for those new to GRUB. After downloading the GRUB4DOS software package, even if you roughly read the readme.txt file, you are likely still confused and don't know where to start. One of the main reasons for this situation is that the software is developed by the author in his spare time. The developer focuses on fixing software bugs in a limited time, so there isn't much remaining energy to write documentation.
In fact, using this software initially isn't difficult; it can be said to be very simple. The following content refers to relevant materials and combines my own usage experience, for the reference of beginners. I hope it can help you get started with GRUB. I myself have only been in contact with GRUB for a short time, and my understanding of GRUB is still very superficial. There are bound to be errors, and I hope you will point them out.
--------------------------------------------------------------------------------
Thanks
The completion of this article refers to and quotes from many materials, and many of them can't find the original source. After the initial draft was completed, netizens put forward many opinions and suggestions, and they also received support and encouragement from the software developers. Thanks are expressed here.
Lianjiang March 2007 First draft
April 2009 Final modification
【Note: My cloud disk:
http://lianjiang2007.ys168.com http://lianjiang2004.ys168.com also provides downloads of some GRUB-related files and materials.】
Table of Contents
1 GRUB4DOS Beginner's Tutorial - Introduction
1.1 Introduction to GRUB
1.2 How to obtain the latest version of GRUB4DOS
1.3 How to install GRUB4DOS
1.3.1 Enter GRUB4DOS through the boot menu of Windows NT
1.3.2 Start GRUB through DOS
1.3.3 Start GRUB through MBR
1.3.4 Enter GRUB4DOS through the boot menu of Windows VISTA/Window 7
1.4 How to use GRUB4DOS
1.5 Conclusion
2 GRUB4DOS Beginner's Tutorial - Application
2.1 Applications on the hard disk
2.1.1 Loading floppy disk images
2.1.2 Starting WinPE
2.1.3 Starting the system
2.1.4 Booting CD-ROM images (ISO emulation)
2.2 Applications on the CD-ROM
2.2.1 Bootable CD-ROM guided by GRUB
2.2.2 Bootable CD-ROM with BCDW guiding GRUB
2.3 Applications on the floppy disk
2.3.1 Floppy disk application of starting GRUB through DOS
2.3.2 Floppy disk application with GRLDR boot record installed in the boot sector
2.4 Applications on the USB flash drive
2.5 Conclusion
3 GRUB4DOS Beginner's Tutorial - Advanced
3.1 Setting passwords
3.2 Menu built-in
3.3a Using personalized GRUB4DOS file name (grubinst)
3.3b Automatically renaming grldr with batch processing (applicable to the latest version of grldr)NEW!
3.4 Installing Windows XPE to a logical partition
3.5 Method and application of passing parameters using the savedefault command
3.6 Method and application of passing parameters using the dd command NEW!
4 Appendix
Grub legacy
4.01 GRUB command index
4.02 Usage method of the simplified Chinese version of GRUB
4.03 Summary of GRUB installation, configuration and usage
4.04 Detailed explanation of GRUB commands
4.05 GRUB three-step pass
4.06 Summary and analysis of GRUB-related installation, configuration and usage examples
Grub2 materials
4.07 Introduction to GRUB2 usage by bean NEW!
4.08 Advanced tutorial on GRUB2 by bean NEW!
Grub4dos materials
4.09 Advanced tutorial on gfxmenu customization (new customizable menu) by bean NEW!
4.10 How to use grubinst_gui by bean
GRUB4DOS official documents
4.11 Grub4dos_tutorial (English)
4.12 Introduction to GRUB4DOS
4.13 Installation and startup of GRUB4DOS
4.14 Newcomer's guide to GRUB4DOS
4.15 Advanced functions of GRUB4DOS
4.16 GRUB4DOS command index
4.17 Introduction to Grubinst usage
4.18 Grub4dos readme (English)
4.19 Grub4dos readme (Chinese)
--------------------------------------------------------------------------------
Text:
1 GRUB4DOS Beginner's Tutorial - Introduction
1.1 Introduction to GRUB
GRUB is a boot manager that complies with the Multiboot specification. There are 3 types currently, namely GNU Grub Legacy, GNU Grub2 and Grub for dos (grub4dos).
GNU GRUB Legacy is actually the original GNU GRUB 0.xx, and the latest version is GNU GRUB 0.97 released in 2005. Currently, development has stopped and it has been renamed GNU GRUB Legacy.
GNU GRUB2 is the second generation of GRUB, which will replace the original GNU GRUB (such as version 0.9x), but it is still in the development stage and has not been released as an official version.
GNU GRUB Legacy and GNU GRUB2 are both projects of the GNU organization.
GRUB for DOS (GRUB4DOS) is a powerful bootloader based on GNU GRUB. It can run under DOS and LINUX, can also run through other bootloaders, and can also act as an MBR. GRUB4DOS has a fully functional BIOS-level disk emulation built-in.
The following is explained based on the widely used GRUB4DOS. For the differences between GNU GRUB and GRUB4DOS, please refer to the relevant instructions.
1.2 How to obtain the latest version of GRUB4DOS
You can download the latest and earlier versions of GRUB4DOS from the following URLs.
http://download.gna.org/grub4dos/
http://download.gna.org/grubutil/
http://grub4dos.jot.com/WikiHome
https://gna.org/projects/grub4dos/
http://grub4dos.sourceforge.net/wiki (official documentation)
1.3 How to install GRUB4DOS?
After downloading GRUB4DOS, just unzip it. The core files are the following: grldr and grub.exe, and menu.lst (this is a sample and needs to be modified). If you need Chinese support, use the files in the chinese directory.
There are usually 3 common installation methods.
1.3.1 Enter GRUB4DOS through the boot menu of Windows NT
Copy the grldr file to c:\, remove the read-only attribute of boot.ini, then modify the c:\boot.ini file, add a line at the end of boot.ini:
c:\grldr="Start GRUB4DOS"
And set the timeout value in boot.ini to a number greater than 0, such as:timeout=5, then save boot.ini and change it back to the read-only attribute.
Before editing boot.ini, you can enter in cmd:
attrib -s -r -h c:\boot.ini
To remove the read-only attribute of boot.ini, after editing, enter:
attrib +s +r +h c:\boot.ini
To restore the original attributes of boot.ini.
In this way, after editing, restart the computer, and "Start GRUB4DOS" will appear in the NT boot menu. Select this item to enter the GRUB4DOS environment. 【Figure 1】
The advantage of this method is: no need to modify the MBR.
Beginners generally need a GRUB menu when using GRUB. Put the prepared menu.lst file in C:\ (it can also be placed in the root directory of other partitions or other specified directories). The writing method of menu.lst can refer to readme.txt or menu.lst provided by others. A simple introduction will be made in the following "1.4 How to use GRUB4DOS".
1.3.2 Start GRUB through DOS
Boot the machine to the DOS environment through any possible way (floppy disk, USB flash drive, CD-ROM, etc.) (preferably a pure DOS environment, that is, a DOS environment without loading any drivers and TSR programs), then run grub.exe under DOS or in AUTOEXEC.BAT to enter GRUB4DOS.
You can also use any of the following methods to start GRUB in CONFIG.SYS of DOS/Windows9x.
DEVICE=GRUB.EXE
INSTALL=GRUB.EXE
SHELL=GRUB.EXE
The advantage of this method is: no need to modify the MBR; GRUB4DOS can be started in scripts or other DOS programs as needed.
The menu file menu.lst can be saved in the directory where the GRUB file is located or other specified paths.
1.3.3 Start GRUB through MBR
Install the GRLDR boot record to the master boot record of the hard disk or hard disk image file through bootlace.com in the software package (runnable under DOS/Win9x), or install it to the boot sector of the floppy disk or floppy disk image. When the computer starts, press the hot key (default is the space bar, which can be customized) to start GRUB.
For example:
Install the GRLDR code to the master boot record under DOS:
bootlace.com 0x80
Install the GRLDR code to the floppy disk under DOS:
bootlace.com --floppy --chs 0x00
Install the GRLDR code to the floppy disk image under DOS:
bootlace.com --floppy --chs floppy.img
The command I use is:
bootlace --force-backup-mbr --boot-prevmbr-first --time-out=3 --hot-key=0x3920 --mbr-disable-floppy 0x80
It means that when installing the GRLDR code to the MBR, back up the original MBR (--force-backup-mbr), start the original MBR by default, that is, start the original Windows XP system (--boot-prevmbr-first), wait for 3 seconds (--time-out=3), the hot key is the space bar (--hot-key=0x3920), and do not search for GRLDR on the floppy disk (--mbr-disable-floppy).
That is, wait for 3 seconds when starting. If you don't press the hot key within 3 seconds, start Windows XP; if you press the hot key within 3 seconds, start GRUB4DOS.
For other parameters of bootlace and the usage of custom hot keys, please refer to the readme.txt file.
After loading the MBR, copy the grldr and menu.lst files to the root directory of a partition (now supported file systems are FAT12, FAT16, FAT32, NTFS, EXT2 or EXT3 partitions. For Windows users, it is best to be a fat partition), and menu.lst can also be saved to other specified locations.
The advantage of this method is: not dependent on the operating system; can automatically search for grldr files on each partition of the hard disk.
In addition, in the 2000/xp/2003/vista environment, another software grubinst can be used to install the GRLDR boot record to the MBR of the hard disk. grubinst has two working modes: graphical interface and command line for selection, and comes with relatively detailed usage instructions, which is very easy to use.
1.4 How to use GRUB4DOS
For most Windows users who have no or little contact with Linux, the menu is indispensable when they first use GRUB. That is to say, before using GRUB, we need to prepare the menu.lst file.
The following is an example of menu.lst. (Lines starting with # are comments and are not executed)
# Default delay time (seconds)
timeout 30
# The first item is the default value
default 0
# Set the graphic background file
splashimage (hd0,0)/boot/grub/xp2008.gz
# Set the font file for Chinese support
fontfile (hd0,0)/boot/grub/fonts
title Start the瑞星 anti-virus floppy disk image file on the local hard disk using map
map (hd0,0)/boot/grub/rav.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title Start the local Win98 floppy disk image file using memdisk
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/win98.img
title Start the瑞星 anti-virus floppy disk compressed image file on the local hard disk using memdisk
root (hd0,0)
kernel /boot/grub/memdisk.gz c=80 h=12 s=36 floppy
initrd /boot/rav.zip
title Start the operating system on the first primary partition (hd0,0)
rootnoverify (hd0,0)
makeactive
chainloader +1
title Start the operating system on the second primary partition (hd0,1)
rootnoverify (hd0,1)
makeactive
chainloader +1
title Reboot
reboot
title Shutdown
halt
The running effect of this menu file is shown in the following figure. 【Figure 2】
Refer to this example, and you can modify the menu according to your needs.
For example, if you download the efficiency source image file from the Internet with the file name XLY.IMG. You only need to change
title Start the local Win98 floppy disk image file using memdisk
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/win98.img
to
title Hard disk detection and repair tool Efficiency Source (memdisk)
kernel (hd0,0)/boot/grub/memdisk.gz
initrd (hd0,0)/boot/grub/xly.img
Or change it to
title Hard disk detection and repair tool Efficiency Source (map)
map (hd0,0)/boot/grub/xly.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
At the same time, save the xly.img file in the boot\grub directory of the first primary partition (usually C:).
Of course, it can also be saved in other paths.
For example, if the xly.img file is saved in C:\boot, then the menu.lst file should be changed accordingly:
map (hd0,0)/boot/xly.img (fd0)
If the xly.img file is saved in D:\test, then the menu.lst file should be changed accordingly:
map (hd0,4)/test/xly.img (fd0)
(Refer to note d below)
As can be seen from the above example, there are two ways to start the floppy disk image, namely using memdisk or map.
When using memdisk, the img file can be compressed; when the size of the img file is not a standard image of 1.44MB or 2.88MB, the CHS parameters need to be specified. The CHS parameters of the img file can be obtained with winimage.
That is, in the example:
title Start the瑞星 anti-virus floppy disk compressed image file on the local hard disk using memdisk
root (hd0,0)
kernel /boot/grub/memdisk.gz c=80 h=12 s=36 floppy
initrd /boot/rav.zip
In addition, the file path in the menu file can be expressed in relative path (such as: /boot/rav.zip) or absolute path (such as: (hd0,0)/boot/grub/xly.img).
The map method has no limit on the size of the floppy disk image, but it is required to be stored continuously. The improved map --mem has no such limit.
For example:
map --mem /boot/xxx.ima (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
Notes:
a, The memdisk.gz file used in the menu file is not included in the GRUB4DOS release package and needs to be prepared by yourself. It can be obtained from the GNU GRUB software package or from other GRUB-based tools (such as One-Click Ghost, my gghost).
b, Other files used in the menu, such as xp2008.gz (background file), fonts (Chinese font file) and various image files, etc., need to be copied to the path specified in the file. The fontfile command cannot be used alone and needs to be used together with splashimage.
c, All commands in the menu file are in lowercase.
d, Beginners should pay attention to the device naming method of GRUB when using the absolute path. The first hard disk drive of the system is represented as (hd0), and the first partition on it is represented as (hd0,0), that is, for the hard disk, it is represented in the form of (hdx,y), where x and y are both counted from 0, x represents the hard disk number, and y represents the partition number.
Since there can be only four primary partitions, the four primary partitions of the first hard disk are respectively represented by (hd0,0)~(hd0,3); logical partitions start from (hd0,4), that is, the first logical partition is represented by (hd0,4), the second logical partition is represented by (hd0,5), and so on.
Generally, the hard disk of most computers has one primary partition, and the rest are logical partitions. Therefore, the C drive is represented by (hd0,0), and the D drive is represented by (hd0,4). The CD-ROM is represented by (cd), and the first floppy drive is represented by (fd0).
For example, my hard disk has two primary partitions, and the rest are logical partitions. The method of representing with (hdx,y) is shown in the following figure:
The following is the menu effect diagram and menu.lst file I am currently using for reference. 【Figure 3】
color white/green yellow/green
default 1
timeout 3
#fontfile /boot/grub/fonts
#splashimage /boot/grub/bg.xpm.gz
#password --md5 $1$8$D0mfzTIQXv2Ma2b5bWH0b.
title 0, Boot from Hard Drive (hd0,0)
root (hd0,0)
chainloader +1
title 1, GreenGhost (MAP-HOOK)
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title 2, GreenGhost (MEMDISK)
kernel /boot/grub/memdisk.gz c=200 h=2 s=36 floppy
initrd /boot/grub/gghost.img
title 3, GreenGhost (MAP-HOOK)
map --mem /boot/grub/gghost.img (fd0)
map --hook
chainloader --disable-a20 (fd0)+1
rootnoverify (fd0)
title 4, Microsoft Windows NT/2K/XP
find --set-root /ntldr
chainloader /ntldr
title 5, Microsoft Windows Vista
find --set-root /bootmgr
chainloader /bootmgr
title 6, Boot from Hard Drive (hd0,1)
root (hd0,1)
chainloader +1
title 7, Reboot
reboot
title 8, Shutdown
halt
1.5 Conclusion
GRUB4DOS has powerful functions. The above introduction is only some of the most basic usages of GRUB4DOS. More usages can be understood by referring to materials on the basis of mastering the basic usages.
--------------------------------------------------------------------------------
2 GRUB4DOS Beginner's Tutorial - Application
2.1 Applications on the hard disk
When applying GRUB on the hard disk, you first need to install it. The installation/boot methods are mainly 3 types, namely entering GRUB4DOS through the boot menu of Windows NT; starting GRUB through DOS; starting GRUB through MBR. 【Refer to 1.3 How to install GRUB4DOS】
After installing GRUB, you need to prepare the menu file menu.lst.
2.1.1 Loading floppy disk images
For Windows users, using GRUB to load floppy disk images is one of the most commonly used functions. Since Windows 2k/xp has been separated from DOS, it has become a problem for beginners to perform some DOS operations such as system backup/restoration. In the past, we might need to use a boot CD-ROM to enter DOS, and the characteristics of the CD-ROM determine that it is difficult to update the tools on the CD-ROM in a timely and convenient manner. The appearance and application of GRUB have solved this problem. We can not only enter the DOS environment without using other media, but also update tools in a timely manner. Many of the system maintenance tools downloaded from the Internet are in img format. Without extracting the files, you can use them by slightly modifying menu.lst. Various tools can coexist harmoniously and are very convenient to use.
How to add the downloaded xxx.img to the GRUB boot menu?
You only need to save xxx.img in the C:\boot\grub directory, edit menu.lst, and add the following content.
title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
Notes:
a, These lines of content cannot be added at the front, because the front are some settings that are effective for the whole.
b, All the tools you need can be added in this way.
c, Maybe you have many tools, and adding them all to the menu will make it messy. Usually, there may be only one or two commonly used tools, and many are only used occasionally. For this situation, the following method can be adopted. That is, write the commonly used ones into the menu, and at the same time write the content of a general startup img file in the menu.
For example, the above:
title Boot from Floppy image XXX
map --mem /boot/grub/xxx.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
After starting GRUB and entering the menu, select "Boot from Floppy image XXX", press "e" to enter the editing state, move the direction key, modify xxx.img to the file name you need to start, press Enter, and press "b" to start. (If the img file is saved in other paths, change it to the corresponding path.)
2.1.2 Starting WinPE
Some system maintenance operations are not easy or even impossible to perform under DOS. The appearance of WinPE has brought us a lot of convenience.
Take the widely praised "Lao Jiu WinPE Lao Maotao Modified Version_1111 Edition" as an example to introduce how to start WinPE with GRUB. (The ISO already has an installation program. Here, I will introduce how to add a general winpe option in menu.lst.)
Steps:
1, Download "Lao Jiu WinPE Lao Maotao Modified Version_1111 Edition", unzip it to get BootCD.ISO.
2, Use a virtual CD-ROM or UltraISO to extract WINPE.IS_, WINNT.XPE and WXPE\SETUPLDR.BIN in the ISO, copy these 3 files to C:\, and rename SETUPLDR.BIN to ldrxpe. If external programs are needed, also copy XPEMENU.INI and the "external program" directory to the root directory of any disk. 【Figure 4】【Figure 5】
3, Add the following in menu.lst
title Micro Windows XPE (by LaoMaotao)
chainloader /ldrxpe
Select "Micro Windows XPE (by LaoMaotao)" when starting GRUB to start WinPE. In this way, you can perform system maintenance, installation and other operations under the Windows interface. 【Figure 6】【Figure 7】【Figure 8】
2.1.3 Starting the system
For a single hard disk with multiple systems installed and multiple hard disks with multiple systems installed, GRUB can be used to conveniently manage the boot of each system.
For example, the following options can be added in menu.lst:
title Start the operating system on the first primary partition (hd0,0) of the first hard disk
rootnoverify (hd0,0)
makeactive
chainloader +1
title Start the operating system on the second primary partition (hd0,1) of the first hard disk
rootnoverify (hd0,1)
makeactive
chainloader +1
title Start Windows NT/2000/XP/2003
find --set-root /ntldr
chainloader /ntldr
title Start Microsoft Windows Vista
find --set-root /bootmgr
chainloader /bootmgr
title Start DOS/Windows 95/98/Me
find --set-root /io.sys
chainloader /io.sys
2.2 Applications on the CD-ROM
The following introduces two methods of applying GRUB on the CD-ROM.
2.2.1 Bootable CD-ROM guided by GRUB
Use grldr as the boot file of the CD-ROM to guide the CD-ROM, load menu.lst, and select the boot item through the menu.
Steps:
1) Prepare necessary img files, and grldr, menu.lst (prepare font, background image, memdisk.gz and other files as needed).
2) Edit menu.lst. The format for guiding the img file on the CD-ROM is as follows:
title GreenGhost (MAP-HOOK)
map --mem (cd)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
The menu can also guide the img file on the hard disk, such as:
title GreenGhost (MEMDISK)
kernel (hd0,4)/boot/grub/memdisk.gz c=200 h=2 s=36 floppy
initrd (hd0,4)/boot/grub/gghost.img
3) Organize files. For example, create a grubcd directory under E:\3333, copy menu.lst to this directory, and the menu.lst file will be in the root directory of the CD-ROM. Create a boot\grub directory under the grubcd directory, and save various img, fonts and other files (it can also be saved in other paths, and the path specified in menu.lst should be consistent). Note: The file names of all files referenced in the menu.lst file that are displayed on the hard disk need to be in lowercase, and uppercase ones need to be changed to lowercase. 【Figure 9】
4) Make ISO. Use UltraISO to create a new ISO file, add all files in the E:\3333\grubcd directory to the ISO file; perform "Bootable CD-ROM" - "Load boot file", select the grldr file (need to rename grldr to grldr.bin or grldr.bif, etc.). Then perform "File" - "Properties", select the "Allow lowercase letters" option, and save the ISO file. 【Figure 10】【Figure 11】【Figure 12】
It can also use tools such as mkisofs.exe or CDIMAGE.EXE to make a bootable ISO (grldr does not need to be renamed).
For example, the batch processing I use to make ISO with CDIMAGE is:
cdimage -lgrubcd -t01/01/2007,00:00:00 -h -n -o -d -m -bgrldr grubcd grubcd.iso
5) Burn the made bootable ISO with Nero and other software. It is better to test it in a virtual machine first before burning it, or use CD-RW/DVD+RW to burn it.
2.2.2 Bootable CD-ROM with BCDW guiding GRUB
This method is to use BCDW to make a bootable CD-ROM, and execute grldr through BCDW to load the menu.lst menu.
Steps:
1) First download the BCDW software package, unzip it to get the required files.
2) Organize files. For example, create a bcdwcd directory under E:\3333. The files in this directory will be in the root directory of the CD-ROM. Create a boot\grub directory and a bcdw directory under it. Copy bcdw.bin, bcdw.ini and loader.bin in the bcdw directory of the software package to the created bcdwcd\bcdw directory; copy grldr, various img, fonts and other files to the bcdwcd\boot\grub directory. The editing method of the menu.lst file is the same as that introduced in 2.1 above.
3) Edit the bcdw.ini file. Open bcdw.ini, find the part, for example:
C:\ ; Boot from drive C:
\I386\setupldr.bin ; Microsoft Windows XP Setup
The above is an example of the BCDW boot menu. Add items such as GRUB here to become:
\images\gghost.img ; GGhost v6.0 (Ghost8.3/11)
\images\mynet.img ; My net (Ghost8.3)(tcp/ip,cd/usb)
\boot\grub\grldr ; Grub4dos
\WXPE\SETUPLDR.BIN ; Micro Windows XPE (by LaoMaotao)
C:\ ; Boot from drive C:
\I386\setupldr.bin ; Microsoft Windows XP Setup
4) The method of making the ISO file and burning the ISO is basically the same as in 2.1. The only difference is that when making the ISO file, loader.bin (or bcdw.bin) should be used as the boot file of the ISO. 【Figure 13】
It can also use tools such as mkisofs.exe or CDIMAGE.EXE to make a bootable ISO.
For example, the batch processing I use to make ISO with CDIMAGE is:
cdimage -lbcdwcd -t01/01/2007,00:00:00 -h -n -d -o -m -bload.bin bcdwcd bcdwcd.iso
After running, the effects of the BCDW interface and the GRUB interface are shown in the following figures. 【Figure 14】【Figure 15】
2.3 Applications on the floppy disk
There are mainly two ways to apply GRUB on the floppy disk, namely starting GRUB through DOS and installing the GRLDR boot record in the boot sector of the floppy disk. 【Refer to 1.3 How to install GRUB4DOS】
2.3.1 Floppy disk application of starting GRUB through DOS
First, make the floppy disk into a bootable disk. The simplest one, the floppy disk only needs three files: io.sys, msdos.sys and command.com.
Then copy grub.exe and menu.lst to the root directory of the floppy disk.
Create a new autoexec.bat file, which only needs to write four letters.
grub
Then edit menu.lst. Due to the limited capacity of the floppy disk, it is generally difficult to directly call the img file on the floppy disk in the menu. Therefore, it can mainly be used to start the img file on the hard disk, and can also be used to manage the boot of each system. The files specified in the menu file (such as font, img file, etc.) should be prepared in advance, otherwise the option cannot run. (There are also examples on the Internet of including many maintenance tools in the limited capacity of the floppy disk. Those who are interested can search by themselves.)
An example of the menu.lst file:
timeout 10
default 0
splashimage (fd0)/boot/grub/xp2008.gz
fontfile (fd0)/boot/grub/fonts
title GreenGhost (MAP-HOOK)
map --mem (hd0,4)/boot/grub/gghost.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
title Find menu.lst on the hard disk
find --set-root /menu.lst
configfile /menu.lst
title Start the operating system on the first primary partition (hd0,0) of the first hard disk
rootnoverify (hd0,0)
makeactive
chainloader +1
title Start the operating system on the second primary partition (hd0,1) of the first hard disk
rootnoverify (hd0,1)
makeactive
chainloader +1
title Reboot
reboot
title Shutdown
halt
2.3.2 Floppy disk application with GRLDR boot record installed in the boot sector
After the GRLDR boot record is installed, only grldr, menu.lst and the files referenced in menu.lst need to be retained on the floppy disk. The menu.lst file is the same as that used in "2.3