~smartboyhw/wubi/bug-1080090-new

« back to all changes in this revision

Viewing changes to src/grubutil/grubinst/.svn/text-base/README_grubinst.txt.svn-base

  • Committer: Howard Chan
  • Date: 2012-11-20 10:16:05 UTC
  • Revision ID: smartboyhw@gmail.com-20121120101605-qfmjfsdynpzg9an9
Added images

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
1. Introdution
2
 
 
3
 
This utility is used to install GRUB4DOS to the MBR of hard disk or image file.
4
 
 
5
 
grubinst.exe is a console mode program. It mimics the behavior of the DOS/Linux
6
 
utility bootlace.com from TinyBit's GRUB4DOS package. But unlike bootlace.com,
7
 
grubinst is writen completely in C and can be compiled to run in OSs like
8
 
Windows NT/2K/XP, Linux and FreeBSD.
9
 
 
10
 
grubinst_gui.exe is a GUI frontend to grubinst.exe. It provides a friendly
11
 
interface to users who are not familiar whith the command line environment.
12
 
Currently, grubinst_gui.exe only runs in Windows OSs.
13
 
 
14
 
Please note that these utilities only install MBR, it DOES NOT copy GRLDR to
15
 
your partition or configure menu.lst, neither does it modify boot.ini to enable
16
 
booting from the NT boot manager. To know more about such things, please refers
17
 
to README_GRUB4DOS.txt which contains information about the GRUB4DOS package.
18
 
 
19
 
Also note that the current version of grubinst doesn't support modify the MBR
20
 
of hard disk in Windows 95/98/ME. For those OSs, bootlace.com should be used
21
 
instead.
22
 
 
23
 
2. Features of grubinst
24
 
 
25
 
2.1 Use special name to represent devices
26
 
 
27
 
In grubinst, you can use special filename to represent hard disks and floppies.
28
 
 
29
 
(hdN)
30
 
Hard disk device N. In Linux, (hd0) - (hd3) equals to /dev/hda - /dev/hdd. In
31
 
FreeBSD, (hd0) - (hd3) equals to /dev/ad0 - /dev/ad3. In Windows, (hdN) equals
32
 
to \\.\PHYSICALDRIVEN
33
 
 
34
 
(hdN,P)
35
 
Partition P on hard disk N. Primary partition is 0-3, extended partition starts
36
 
at 4.
37
 
 
38
 
(fdN)
39
 
Floppy device N. In Linux/FreeBSD, (fdN) equals to /dev/fdN. In Windows, (fd0)
40
 
and (fd1) equals to drive A: and B:.
41
 
 
42
 
(fdN,P)
43
 
Partition P on floppy N.
44
 
 
45
 
Note 1. bootlace.com use numbers to represent devices. Floppies starts with 0,
46
 
and hard disks starts with 0x80.
47
 
 
48
 
Note 2. In bash/csh shell, () have special meaning. So you need to wrap the
49
 
device name with "" or ''.
50
 
 
51
 
Note 3. The 6-series of FreeBSD doesn't allow you to access a hard disk device
52
 
which has been open. This means you can't modify the MBR of your currently used
53
 
hard disk. Older series of FreeBSD don't have this problem.
54
 
 
55
 
2.2 Save/Restore function
56
 
 
57
 
Normally, the original MBR is only one sector long, it's stored in the second
58
 
sector of the new GRLDR MBR. You can restore it using --restore-prevmbr option.
59
 
However, if the original MBR is longer than one sector, for instance, you have
60
 
other boot manager installed, then GRLDR MBR dones't have room to hold it. In
61
 
this case, you should use --save=FILENAME to save the original MBR to an
62
 
external file, and use --restore=FILENAME to restore it.
63
 
 
64
 
Starts from version 1.1, --save=FILENAME and --restore=FILENAME also works for
65
 
partition boot sector. --restore-prevmbr doesn't work with partitions.
66
 
 
67
 
Note 1. In version 1.0.1, --save=FN and --restore=FN are called --save-mbr=FN
68
 
and --restore-mbr=FN, I remove the mbr part becase it now works for mbr and
69
 
boot sector.
70
 
 
71
 
Example 1. Install GRLDR to MBR/BS, and save the original MBR/BS to an external
72
 
file.
73
 
 
74
 
        grubinst --save=FILENAME DEVICE_OR_FILE
75
 
 
76
 
Example 2. Restore MBR from previous one sector MBR
77
 
 
78
 
        grubinst --restore_prevmbr DEVICE_OR_FILE
79
 
 
80
 
Example 3. Restore MBR/BS from external file
81
 
 
82
 
        grubinst --restore=FILENAME DEVICE_OR_FILE
83
 
 
84
 
2.3 Partition and floppy support (New in version 1.1)
85
 
 
86
 
You can use --list-part to list all partitions in device or file.
87
 
 
88
 
        grubinst --list-part DEVICE_OR_FILE
89
 
 
90
 
This option is diagnostic, it won't actually install GRLDR.
91
 
 
92
 
To install GRLDR to partition, just use the proper partition name, or use
93
 
--install-partition=I option to set the partition number. You don't need to
94
 
worry about file system type, as they are probed automatically. Support file
95
 
system are FAT12, FAT16, FAT32, NTFS and Ext2.
96
 
 
97
 
To install GRLDR to floppy image, you need to use the --floppy option.
98
 
 
99
 
Note 1. If you install GRLDR Boot Record to a floppy or a partition, the floppy
100
 
or partition will boot solely grldr, and your original IO.SYS(DOS/Win9x/Me) and
101
 
NTLDR(WinNT/2K/XP) will become unbootable. This is because the original boot
102
 
record of the floppy or partition was overwritten. There is no such problem
103
 
when installing GRLDR Boot Record onto the MBR. Update: Some NTLDR/IO.SYS/
104
 
KERNEL.SYS files can be directly chainloaded in the latest GRUB4DOS.
105
 
 
106
 
Note 2. You can use --start-sector=B option to specific the absolute address of
107
 
the start sector of partition, but we don't recommend it, as grubinst can
108
 
extract the information from the partition table in MBR.
109
 
 
110
 
Note 3. You can use --verbose option to see more information about the
111
 
partition on which you install GRLDR. It is good pratice to first use
112
 
--read-only and --verbose to verify the partition before actually installing
113
 
GRLDR.
114
 
 
115
 
        grubinst --read-only --verbose (hd0,0)
116
 
 
117
 
Output:
118
 
 
119
 
        Part Fs: 0B (FAT32)
120
 
        Part Leng: 1542240
121
 
        Start sector: 1028160
122
 
        Image type: FAT32
123
 
        Read only mode
124
 
 
125
 
Note 4. Option --floppy=N do exactly the same thing as --install-partition=I.
126
 
It's here just to improve the compatibility with bootlace.com.
127
 
 
128
 
2.4 Short options (New in version 1.1)
129
 
 
130
 
Some options have short counterparts.
131
 
 
132
 
-h              --help
133
 
-v              --verbose
134
 
-l              --list-part
135
 
-s=FN           --save=FN
136
 
-r=FN           --restore=FN
137
 
-r              --restore-prevmbr
138
 
-t              --read-only
139
 
-t=T            --timeout=T
140
 
-k=K            --hot-key=K
141
 
-f              --floppy
142
 
-p=I            --install-partition=I
143
 
-o              --output
144
 
-b=FN           --boot-file=FN
145
 
-2              --grub2
146
 
 
147
 
Note 1. In order to achive compatiblility between gcc and vc6, I don't use the
148
 
getopt function to parse options. Therefore, combining short options doesn't
149
 
work. For example, -vl is not equal to -v -l.
150
 
 
151
 
2.5 Key code translation (New in version 1.1)
152
 
 
153
 
In option --hot-key=K, you can use symbol names instead of raw codes. Raw code
154
 
is still accepted, but they need to start with the hexadecimal prefix 0x.
155
 
 
156
 
Support key names are: A-Z, 0-9, F1-F12, - = [ ] ; ' . \ , / , BACKSPACE, DEL,
157
 
DOWN, END, ENTER, ESC, HOME, INS, KEY-5, KEY-*, KEY--, KEY-+, KEY-/, LEFT,
158
 
PGDN, PGUP, PRRTSC, RIGHT, SPACE, TAB and UP.
159
 
 
160
 
Support prefix are: shift-, ctrl- and alt-.
161
 
 
162
 
Note 1. You can't use more that one prefix. For example ctrl-alt-A is not
163
 
valid.
164
 
 
165
 
Note 2. Some character have special meaning to shell, so you need to wrap them
166
 
with "" or '' ('' can't be used in cmd.exe) . For example,
167
 
 
168
 
        grubinst "--hot-key=;"  DEVICE_OR_FILE
169
 
 
170
 
or
171
 
 
172
 
        grubinst "--hot-key=ctrl-\\" DEVICE_OR_DEVICE
173
 
 
174
 
Note 3. Key name is case insensitive. Therefore, ctrl-a, CTRL-A and Ctrl-A are
175
 
all the same.
176
 
 
177
 
Note 4. To see the raw code of a key name, you can use --verbose option. For
178
 
example:
179
 
 
180
 
        grubinst --verbose --hot-key=ctrl-a
181
 
 
182
 
Output:
183
 
        Key CTRL-A : 0x1E01
184
 
        grubinst: No filename specified
185
 
 
186
 
You can ignore the error message as we are not actually installing GRLDR.
187
 
 
188
 
2.6 Change boot file name and load segment (New in 1.1 beta6)
189
 
 
190
 
You can 
191
 
 
192
 
2.7 Grub2 support (New in 1.1 beta6)
193
 
 
194
 
2.8 Loading via NT boot manager
195
 
 
196
 
2.9 Usage
197
 
 
198
 
Usage:
199
 
        grubinst  [OPTIONS]  DEVICE_OR_FILE
200
 
 
201
 
OPTIONS:
202
 
 
203
 
        --help,-h               Show usage information
204
 
 
205
 
        --pause                 Pause before exiting (used by GUI)
206
 
 
207
 
        --version               Show version information
208
 
 
209
 
        --verbose,-v            Verbose output
210
 
 
211
 
        --list-part,-l          List all logical partitions in DEVICE_OR_FILE
212
 
 
213
 
        --save=FN,-s=FN         Save the orginal MBR/BS to FN
214
 
 
215
 
        --restore=FN,-r=FN      Restore MBR/BS from previously saved FN
216
 
 
217
 
        --restore-prevmbr,-r    Restore previous MBR saved in the second sector
218
 
                                of DEVICE_OR_FILE
219
 
 
220
 
        --read-only,-t          do everything except the actual write to the
221
 
                                specified DEVICE_OR_FILE. (test mode)
222
 
 
223
 
        --no-backup-mbr         do not copy the old MBR to the second sector of
224
 
                                DEVICE_OR_FILE.
225
 
 
226
 
        --force-backup-mbr      force the copy of old MBR to the second sector
227
 
                                of DEVICE_OR_FILE.(default)
228
 
 
229
 
        --mbr-enable-floppy     enable the search for GRLDR on floppy.(default)
230
 
 
231
 
        --mbr-disable-floppy    disable the search for GRLDR on floppy.
232
 
 
233
 
        --mbr-enable-osbr       enable the boot of PREVIOUS MBR with invalid
234
 
                                partition table (usually an OS boot sector).
235
 
                                (default)
236
 
 
237
 
        --mbr-disable-osbr      disable the boot of PREVIOUS MBR with invalid
238
 
                                partition table (usually an OS boot sector).
239
 
 
240
 
        --duce                  disable the feature of unconditional entrance
241
 
                                to the command-line.
242
 
 
243
 
        --boot-prevmbr-first    try to boot PREVIOUS MBR before the search for
244
 
                                GRLDR.
245
 
 
246
 
        --boot-prevmbr-last     try to boot PREVIOUS MBR after the search for
247
 
                                GRLDR.(default)
248
 
 
249
 
        --preferred-drive=D     preferred boot drive number, 0 <= D < 255.
250
 
 
251
 
        --preferred-partition=P preferred partition number, 0 <= P < 255.
252
 
 
253
 
        --time-out=T,-t=T       wait T seconds before booting PREVIOUS MBR. if
254
 
                                T is 0xff, wait forever. The default is 5.
255
 
 
256
 
        --hot-key=K,-k=K        if the desired key K is pressed, start GRUB
257
 
                                before booting PREVIOUS MBR. K is a word
258
 
                                value, just as the value in AX register
259
 
                                returned from int16/AH=1. The high byte is the
260
 
                                scan code and the low byte is ASCII code. The
261
 
                                default is 0x3920 for space bar.
262
 
 
263
 
        --floppy,-f             if DEVICE_OR_FILE is floppy, use this option.
264
 
 
265
 
        --floppy=N              if DEVICE_OR_FILE is a partition on a hard
266
 
                                drive, use this option. N is used to specify
267
 
                                the partition number: 0,1,2 and 3 for the
268
 
                                primary partitions, and 4,5,6,... for the
269
 
                                logical partitions.
270
 
 
271
 
        --sectors-per-track=S   specifies sectors per track for --floppy.
272
 
                                1 <= S <= 63, default is 63.
273
 
 
274
 
        --heads=H               specifies number of heads for --floppy.
275
 
                                1 <= H <= 256, default is 255.
276
 
 
277
 
        --start-sector=B        specifies hidden sectors for --floppy=N.
278
 
 
279
 
        --total-sectors=C       specifies total sectors for --floppy.
280
 
                                default is 0.
281
 
 
282
 
        --lba                   use lba mode for --floppy. If the floppy BIOS
283
 
                                has LBA support, you can specify --lba here.
284
 
                                It is assumed that all floppy BIOSes have CHS
285
 
                                support. So you would rather specify --chs.
286
 
                                If neither --chs nor --lba is specified, then
287
 
                                the LBA indicator(i.e., the third byte of the
288
 
                                boot sector) will not be touched.
289
 
 
290
 
        --chs                   use chs mode for --floppy. You should specify
291
 
                                --chs if the floppy BIOS does not support LBA.
292
 
                                We assume all floppy BIOSes have CHS support.
293
 
                                So it is likely you want to specify --chs.
294
 
                                If neither --chs nor --lba is specified, then
295
 
                                the LBA indicator(i.e., the third byte of the
296
 
                                boot sector) will not be touched.
297
 
 
298
 
        --install-partition=I   Install the boot record onto the boot area of
299
 
        -p=I                    partition number I of the specified hard drive
300
 
                                or harddrive image DEVICE_OR_FILE.
301
 
 
302
 
        --boot-file=F,-b=F      Change the name of boot file.
303
 
 
304
 
        --load-seg=S            Change load segment for boot file.
305
 
 
306
 
        --grub2,-2              Load grub2 kernel g2ldr instead of grldr.
307
 
 
308
 
        --output,-o             Save embeded grldr.mbr to DEVICE_OR_FILE.
309
 
 
310
 
Example 1: Install GRLDR MBR to the first hard disk
311
 
 
312
 
        grubinst (hd0)
313
 
 
314
 
Example 2: Install GRLDR MBR to the disk image disk.dsk
315
 
 
316
 
        grubinst disk.dsk
317
 
 
318
 
Example 3: Install GRLDR to the first primary partition
319
 
 
320
 
        grubinst (hd0,0)
321
 
 
322
 
or
323
 
 
324
 
        grubinst --install-partition=0 (hd0)
325
 
 
326
 
or
327
 
 
328
 
        grubinst --start-sector=63 --install-partition=0 (hd0)
329
 
 
330
 
If the first partition starts from sector 63. This kind of usage is not
331
 
recommended, as the value specified in --start-sector will overwrite the one
332
 
extracted from the partition table.
333
 
 
334
 
Example 4. Install GRLDR to a floppy device or image
335
 
 
336
 
        grubinst (fd0)
337
 
 
338
 
        grubinst --floppy floppy.img
339
 
 
340
 
If you use floppy device, you can omit the --floppy option.
341
 
 
342
 
Example 5: Load GRUB only if you press CRTL-F1 in the first 10 second of
343
 
booting.
344
 
 
345
 
        grubinst --boot-prevmbr-first --hot-key=ctrl-f1 --time-out=10 (hd0)
346
 
 
347
 
Example 6: Same as above, but use short options.
348
 
 
349
 
        grubinst --boot-prevmbr-first -k=ctrl-f1 -t=10 (hd0)
350
 
 
351
 
3. Features of grubinst_gui
352
 
 
353
 
a) Save/Restore operation
354
 
 
355
 
The operation of save/restore boxes is described as follows:
356
 
 
357
 
If neither "Restore from file" nor "Restore from PrevMBR" is cheked, the
358
 
program would backup the original MBR/BS to FILENAME if it's set in the
359
 
"Save File".
360
 
 
361
 
If "Restore from file" is checked, the program would restore the MBR/BS from
362
 
FILENAME which is set in "Save File". FILENAME must not be empty, otherwise an
363
 
error message is printed. In this case, the setting of "Restore from PrevMBR"
364
 
is ignored.
365
 
 
366
 
If "Restore from file" is not checked, but "Restore from PrevMBR" is, the
367
 
program would restore from previous MBR which is saved in the second sector
368
 
of GRLDR MBR. If "Save File" box is not empty, it would be the name of file
369
 
to store the currently used MBR, which in the case is the GRLDR MBR.
370
 
 
371
 
b) Partition list (New in version 1.1)
372
 
 
373
 
After you select a image file or disk/floppy device, you can press the
374
 
"Refresh" button alongside the "Part List" dropdown list to get the partition
375
 
information. For example, for disk image aa.dsk, the list will be something
376
 
like this:
377
 
 
378
 
        Whole disk (MBR)
379
 
        0: 0E(FAT16X) [15M]
380
 
 
381
 
For FAT12 floppy image aa.img, the list will be something like this:
382
 
 
383
 
        Whole disk (FAT12/FAT16)
384
 
 
385
 
You can choose the partition by selecting the corresponding item from the list.
386
 
 
387
 
After you change the image/device name, the list will be reset. You need to
388
 
press the button again if you want to get the partition list of the new
389
 
image/device.
390
 
 
391
 
c) Test run (New in version 1.1)
392
 
 
393
 
You can use "Test" button to see the command line options that will be passed
394
 
to grubinst.exe, without actually making the call. This can be handy if you
395
 
want to know about the correspondence between grubinst options and the various
396
 
checkboxes in the GUI.
397
 
 
398
 
d) Chinese support (new in version 1.1)
399
 
 
400
 
The GUI will display Chinese interface if your user locale is set to simplified
401
 
Chinese. But you can alter its behaviour by using a option:
402
 
 
403
 
        grubinsi_gui --lang=eng
404
 
 
405
 
Display English interface, regardless your user locale setting.
406
 
 
407
 
        grubinst_gui --lang=chs
408
 
 
409
 
Display simplified Chinese interface, regardless your user locale setting.
410
 
 
411
 
In order to display Chinese characters properly, your system locale must also
412
 
be set to simplified Chinese.
413
 
 
414
 
4. Compilation
415
 
 
416
 
To compile the program, you need the GCC toolkit in Linux, FreeBSD or other
417
 
unix platform, and mingw or Visual C++ 6.0 in Windows NT/2K/XP.
418
 
 
419
 
To compile using GCC toolkit:
420
 
 
421
 
        make
422
 
 
423
 
To compile using Visual C++ 6.0:
424
 
 
425
 
        nmake -f Makefile.vc6
426
 
 
427
 
Here are some notes when you are using the GCC toolkit.
428
 
 
429
 
Note 1. If mingw is detected, make will build the GUI program grubinst_gui.
430
 
Otherwise, it will only build the console mode program grubinst.
431
 
 
432
 
Note 2. In Windows, Linux and FreeBSD, partition whose start address go beyond
433
 
the 4G limit is supported (However, some BIOSes may not boot from such
434
 
partitions). In other systems, the 4G limit issue depends on the size of
435
 
off_t.
436
 
 
437
 
Note 3. Two internal utility, bin2h and ver2h, has two forms. This first is
438
 
a perl script, which can be used directly, but it requires the perl
439
 
interpreter. The other is a C program, which works in all circumstance, but it
440
 
needs compilation. Makefile can detect whether or not perl exists, and use it
441
 
if found. If you want to use the C program even if you have perl, you can set
442
 
USE_PERL to n:
443
 
 
444
 
        make USE_PERL=n
445
 
 
446
 
Note 4. You can compile the resource script grubinst_gui.rc in two way. One
447
 
is to use windres from mingw, the other is to use rc from vc6. By default, rc
448
 
is used if it's detected. However, if you want to use windres no matter what,
449
 
set USE_RC to n:
450
 
 
451
 
        make USE_RC=n
452
 
 
453
 
Also note that rc expects your INCLUDE environment variable being set to the
454
 
paths of vc6 include files.
455
 
 
456
 
Note 5. To compile the Chinese resource properly, you must use rc from vc6, and
457
 
your system locale must be set to simplified Chinese at the time of the
458
 
compilation.
459
 
 
460
 
5. Website
461
 
 
462
 
http://grub4dos.sourceforge.net/
463
 
grubinst and WINGRUB homepage
464
 
 
465
 
http://grub4dos.jot.com/
466
 
Latest GRUB4DOS package by TinyBit
467
 
 
468
 
http://www.znpc.net/bbs
469
 
Nice forum on GRUB4DOS, but it's in chinese
470
 
 
471
 
http://grub.linuxeden.com/
472
 
Misc information by TinyBit, also in chinese