苏州园区明日之星:Grubinst使用介绍 - Grub4Dos Wiki

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 22:36:56

Grubinst使用介绍

From Grub4Dos Wiki

Jump to: navigation, search

Contents

[hide]
  • 1 1. Introdution
  • 2 1. 介绍
  • 3 2. Difference between grubinst and bootlace.com
  • 4 2. grubinst跟bootlace.com的区别
  • 5 3. Usage
  • 6 3. 用法及示例
  • 7 4. Compilation
  • 8 4. 编译方法
  • 9 5. 相关网站
[edit]

1. Introdution

This utility is used to install GRUB4DOS to the MBR of hard disk or image file.

grubinst.exe is a console mode program. It mimics the behavior of the DOS/Linux utility bootlace.com from TinyBit's GRUB4DOS package. But unlike bootlace.com, grubinst is writen completely in C and can be compiled to run in OSs like Windows NT/2K/XP, Linux and FreeBSD.

grubinst_gui.exe is a GUI frontend to grubinst.exe. It provides a friendly interface to users who are not familiar whith the command line environment. Currently, grubinst_gui.exe only runs in Windows OSs.

Please note that these utilities only install MBR, it DOES NOT copy GRLDR to your partition or configure menu.lst, neither does it modify boot.ini to enable booting from the NT boot manager. To know more about such things, please refers to README_GRUB4DOS.txt which contains information about the GRUB4DOS package.

Also note that the current version of grubinst doesn't support modify the MBR of hard disk in Windows 95/98/ME. For those OSs, bootlace.com should be used instead.

[edit]

1. 介绍

grubinst是一个用来将GRUB4DOS安装到硬盘的MBR(或者分区的引导扇区)以及映像文件中的工具。

grubinst.exe是一个命令行方式的程序,它的功能基本上与不点的GRUB4DOS发行包中的bootlace.com(可以运行在纯DOS或者Linux环境)相同,但是跟bootlace.com不同,grubinst完全是用C语言开发的,能够在Windows NT/2K/XP、Linux和FreeBSD等操作系统下编译并运行。

grubinst_gui.exe是grubinst.exe的图形界面shell程序,对于那些不熟悉命令行操作的用户来说,它提供了更友好的图形操作界面,目前,grubinst_gui.exe只能运行在Windows操作系统(事实上是只能运行在NT/2K/XP环境)下。

另外请注意,当前版本的grubinst不支持在Windows 95/98/ME下修改硬盘的MBR,对于这些操作系统,请使用bootlace.com。

[edit]

2. Difference between grubinst and bootlace.com

In bootlace.com, hard disk device is represented by numbers, 0x80 is the first hard disk, 0x81 is the second, etc. In grubinst, hard disk device is represented using special filename, (hd0), (hd1), etc. Floppy device is not supported yet.

grubinst doesn't support install GRUB4DOS to a partition, this would be fixed in furture releases.

grubinst has a few new options which are used mainly to restore the old MBR.

--save-mbr=FILENAME

This option is used to save the original MBR to FILENAME

--restore-mbr=FILENAME

This option is used to restore MBR from previous saved FILENAME

--restore-prevmbr

This option is used to restore the old MBR saved in the second sector of the hard disk or image file.

Normally, the original MBR is only one sector long, it's stored in the second sector of the new GRLDR MBR. You can restore it using --restore-prevmbr option. However, if the original MBR is longer than one sector, for instance, you have other boot manager installed, then GRLDR MBR dones't have room to hold it. In this case, you should use --save-mbr=FILENAME to save the original MBR to an external file, and use --restore-mbr=FILENAME to restore it.

[edit]

2. grubinst跟bootlace.com的区别

在bootlace.com里,硬盘盘等设备只能用设备的BIOS识别号来表示,如0x80表示第一块硬盘,0x81表示第二块硬盘等等。而在grubinst中,硬盘则可以用特定的设备文件名来表示(跟grub的传统类似),如(hd0), (hd1)...。软驱暂时还不支持这种表示方式。

grubinst支持几个新的选项,主要用于恢复原来的MBR。

--save-mbr=FILENAME

This option is used to save the original MBR to FILENAME 这个选项用于保存原来的MBR到文件中。

--restore-mbr=FILENAME

这个选项用来从前面保存的文件中恢复原来的MBR。

--restore-prevmbr

这个选项用来恢复保存在硬盘或者映像文件中第二个扇区的原来的MBR。

正常情况下,原来的MBR只有一个扇区,它被保存在新的GRLDR MBR中的第二个扇区中。你可以用--restore-prevmbr选项来恢复它。然而,如果原来的MBR的长度超过一个扇区,例如,你安装了别的引导管理软件,那么GRLDR MBR就没有足够的空间保存原来的MBR。在这种情况下,你应该使用--save-mbr=FILENAME将原来的MBR保存到一个外部文件中,需要时再使用--restore-mbr=FILENAME选项从保存的文件中恢复它。

[edit]

3. Usage

from grubinst version: 1.1

grubinst [OPTIONS] DEVICE_OR_FILE

OPTIONS:

       --help,-h               Show usage information
       --pause                 Pause before exiting
       --version               Show version information
       --verbose,-v            Verbose output
       --list-part,-l          List all logical partitions in DEVICE_OR_FILE
       --save=FN,-s=FN         Save the orginal MBR/BS to FN
       --restore=FN,-r=FN      Restore MBR/BS from previously saved FN
       --restore-prevmbr,-r    Restore previous MBR saved in the second sectorof DEVICE_OR_FILE
       --read-only,-t          do everything except the actual write to thespecified DEVICE_OR_FILE. (test mode)
       --no-backup-mbr         do not copy the old MBR to the second sector ofDEVICE_OR_FILE.
       --force-backup-mbr      force the copy of old MBR to the second sectorof DEVICE_OR_FILE.(default)
       --mbr-enable-floppy     enable the search for GRLDR on floppy.(default)
       --mbr-disable-floppy    disable the search for GRLDR on floppy.
       --mbr-enable-osbr       enable the boot of PREVIOUS MBR with invalidpartition table (usually an OS boot sector).(default)
       --mbr-disable-osbr      disable the boot of PREVIOUS MBR with invalidpartition table (usually an OS boot sector).
       --duce                  disable the feature of unconditional entranceto the command-line.
       --boot-prevmbr-first    try to boot PREVIOUS MBR before the search forGRLDR.
       --boot-prevmbr-last     try to boot PREVIOUS MBR after the search forGRLDR.(default)
       --preferred-drive=D     preferred boot drive number, 0 <= D < 255.
       --preferred-partition=P preferred partition number, 0 <= P < 255.
       --time-out=T,-t=T       wait T seconds before booting PREVIOUS MBR. ifT is 0xff, wait forever. The default is 5.
       --hot-key=K,-k=K        if the desired key K is pressed, start GRUBbefore booting PREVIOUS MBR. K is a wordvalue, just as the value in AX registerreturned from int16/AH=1. The high byte is thescan code and the low byte is ASCII code. Thedefault is 0x3920 for space bar.
       --key-name=S            Specify the name of the hot key.
       --floppy,-f             if DEVICE_OR_FILE is floppy, use this option.
       --floppy=N              if DEVICE_OR_FILE is a partition on a harddrive, use this option. N is used to specifythe partition number: 0,1,2 and 3 for theprimary partitions, and 4,5,6,... for thelogical partitions.
       --sectors-per-track=S   specifies sectors per track for --floppy.1 <= S <= 63, default is 63.
       --heads=H               specifies number of heads for --floppy.1 <= H <= 256, default is 255.
       --start-sector=B        specifies hidden sectors for --floppy=N.
       --total-sectors=C       specifies total sectors for --floppy.default is 0.
       --lba                   use lba mode for --floppy. If the floppy BIOShas LBA support, you can specify --lba here.It is assumed that all floppy BIOSes have CHSsupport. So you would rather specify --chs.If neither --chs nor --lba is specified, thenthe LBA indicator(i.e., the third byte of theboot sector) will not be touched.
       --chs                   use chs mode for --floppy. You should specify--chs if the floppy BIOS does not support LBA.We assume all floppy BIOSes have CHS support.So it is likely you want to specify --chs.If neither --chs nor --lba is specified, thenthe LBA indicator(i.e., the third byte of theboot sector) will not be touched.
       --install-partition=I   Install the boot record onto the boot area of-p=I                    partition number I of the specified hard driveor harddrive image DEVICE_OR_FILE.
       --boot-file=F,-b=F      Change the name of boot file.
       --load-seg=S            Change load segment for boot file.
       --grub2,-2              Load grub2 kernel g2ldr instead of grldr.
       --output,-o             Save embeded grldr.mbr to DEVICE_OR_FILE.

Example 1: Install GRLDR MBR to the first hard disk

grubinst (hd0)

Example 2: Install GRLDR MBR to the disk image disk.dsk

grubinst disk.dsk

Example 3: Restore the old one sector MBR of the first hard disk

grubinst --restore-prevmbr (hd0)

Example 4: Install GRLDR MBR to the first hard disk, and save the old MBR as MBR.sav

grubinst --save-mbr=MBR.sav (hd0)

Example 5: Restore MBR from previous save file MBR.sav

grubinst --restore-mbr=MBR.sav (hd0)

Example 6: Load GRUB only if you press space in the first 10 second of booting.

grubinst --boot-prevmbr-first --time-out=10 (hd0)

[edit]

3. 用法及示例

取自grubinst 1.1的--help。(by Climbing)

 grubinst  [选项]  设备或文件

选项:

      --help,-h               显示本帮助
       --pause                 退出前暂停
       --version               显示grubinst版本信息
       --verbose,-v            输出详细信息
       --list-part,-l          列出设备或者文件中的所有分区信息
       --save=FN,-s=FN         保存原来的MBR/引导扇区到文件FN中。
       --restore=FN,-r=FN      从前面备份的FN中恢复原来的MBR/引导扇区
       --restore-prevmbr,-r    恢复保存在设备或者文件第二扇区中的原来的MBR
      --read-only,-t          只是模拟操作,没有真正的写操作(测试模式)
       --no-backup-mbr         不在第二扇区中备份原来的MBR。
       --force-backup-mbr      强制备份原来的MBR到第二扇区(默认选项)
      --mbr-enable-floppy     在软驱上搜索grldr(默认选项)
      --mbr-disable-floppy    禁止搜索软驱上的grldr
      --mbr-enable-osbr       当分区表非法时(通常是某操作系统的引导扇区),仍然启动原来的MBR(默认选项)
      --mbr-disable-osbr      当分区表非法时(通常是某操作系统的引导扇区),禁止启动原来的MBR。
      --duce                  (不明白,无法翻译)disable the feature of unconditional entranceto the command-line.
      --boot-prevmbr-first    在搜索GRLDR之前尝试首先启动原来的MBR
      --boot-prevmbr-last     在启动原来的MBR之前先搜索GRLDR(默认选项)
      --preferred-drive=D     优先启动磁盘编号, 0 <= D < 255.
      --preferred-partition=P 优先启动分区编号, 0 <= P < 255.
      --time-out=T,-t=T       在启动原来的MBR之前等待T秒,如果T是0xff,无限等待,默认等待5秒
      --hot-key=K,-k=K        如果在启动原来的MBR之前按下了指定键,则启动GRUB。K的长度为一个字(word),也就是int16/AH=1中断的AX寄存器值。高位字节是对应按键的扫描码,低位字节是ASCII码。默认按键是0x3920,也就是空格键。
      --key-name=S            指定热键的显示名
      --floppy,-f             如果安装目标是软驱,则指定这个选项。
      --floppy=N              如果安装目标是硬盘的某个分区,则指定这个选项。N用来指定分区编号:0,1,2和3对应主分区,4,5,6,...对应逻辑分区。
      --sectors-per-track=S   对--floppy选项指定每磁道扇区数,1 <= S <= 63, 默认是63.
      --heads=H               对--floppy选项指定磁头数,1 <= H <= 256, 默认是255.
      --start-sector=B        对--floppy=N选项指定隐藏扇区数。
      --total-sectors=C       对--floppy选项指定总扇区数,默认是0。
      --lba                   对--floppy选项使用LBA方式。如果软驱的BIOS支持LBA,你可以指定这个选项。按规定所有的软驱BIOS都支持CHS方式,所以最好指定--chs选项。如果既没指定--lba也没指定--chs,则LBA指示字节(一般是启动扇区第3字节)的值不会被改变。
      --chs                   对--floppy选项使用chs方式。如果你的软驱BIOS不支持LBA方式,你应该指定--chs选项。我们假定所有的软驱BIOS都支持CHS方式,所以推荐使用--chs选项。如果既没指定--lba也没指定--chs,则LBA指示字节(一般是启动扇区第3字节)的值不会被改变。
      --install-partition=I   安装引导扇区到指定硬盘(或硬盘映像)的分区I。-p=I
      --boot-file=F,-b=F      改变默认启动文件名(默认是grldr)。
      --load-seg=S            改变启动文件的默认内存加载段(默认是0x2000:0)。
      --grub2,-2              装载grub2的内核g2ldr而不是grldr。
      --output,-o             输出内置的grldr.mbr(受-b参数的影响)。

示例 1: 安装GRLDR MBR到第一个硬盘

grubinst (hd0)

示例 2: 安装GRLDR MBR 到磁盘映像文件disk.dsk

grubinst disk.dsk

示例 3: 恢复第一块硬盘的单扇区MBR

grubinst --restore-prevmbr (hd0)

示例 4: 安装GRLDR MBR到第一块硬盘并保存原来的MBR到MBR.sav文件中。

grubinst --save-mbr=MBR.sav (hd0)

示例 5: 从保存的MBR.sav中恢复原来的MBR。

grubinst --restore-mbr=MBR.sav (hd0)

示例 6: 在启动时10秒内按下空格才加载GRUB

grubinst --boot-prevmbr-first --time-out=10 (hd0)


[edit]

4. Compilation

To compile the program, you need the GCC toolkit in Linux/FreeBSD, and mingw or Visual C++ 6.0 in Windows NT/2K/XP.

Compile using mingw:

make -f Makefile.mgw

Compile using Visual C++ 6.0:

nmake -f Makefile.vc6

Compile using GCC toolkit in Linux:

make -f Makefile.lnx

Compile using GCC toolkit in FreeBSD:

make -f Makefile.bsd

The binary pacakge is built using mingw.

[edit]

4. 编译方法

要编译grubinst,在Linux/FreeBSD下你需要GCC,在Windows NT/2K/XP下你需要mingw或者Visual C++ 6.0。

mingw:

make -f Makefile.mgw

Visual C++ 6.0:

nmake -f Makefile.vc6

Linux GCC:

make -f Makefile.lnx

FreeBSD GCC:

make -f Makefile.bsd

这里提供的二进制代码使用mingw编译。

[edit]

5. 相关网站

[http://grub4dos.sourceforge.net/ grubinst和WINGRUB主页] [http://grub4dos.jot.com/ 由不点维护的最新版GRUB4DOS项目包] [http://bbs.znpc.net/ 时空论坛有GRUB4DOS专区(中文)] [http://grub.linuxeden.com/ 由不点提供的与GRUB4DOS相关的各种信息(中文)]

Retrieved from "http://grub4dos.sourceforge.net/wiki/index.php/Grubinst%E4%BD%BF%E7%94%A8%E4%BB%8B%E7%BB%8D"
Views
  • Article
  • Discussion
  • Edit
  • History
Personal tools
  • Log in / create account
Navigation
  • Main Page
  • Community portal
  • Current events
  • Recent changes
  • Random page
  • Help
  • Donations
 
Toolbox
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • This page was last modified 10:30, 28 January 2011.
  • This page has been accessed 27,480 times.
  • Privacy policy
  • About Grub4Dos Wiki
  • Disclaimers