forked from chenall/grub4dos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README_GRUB4DOS.txt
4192 lines (3029 loc) · 151 KB
/
README_GRUB4DOS.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Main project page: https://github.com/chenall/grub4dos
Get the latest source code
git clone git://github.com/chenall/grub4dos.git
or
svn co https://github.com/chenall/grub4dos grub4dos-src
View the source code online with your web browser at:
https://github.com/chenall/grub4dos
Discussion forum(Official technical support site):
Chinese:
http://bbs.wuyou.com/forumdisplay.php?fid=60
http://bbs.znpc.net/forumdisplay.php?fid=4
English:
http://reboot.pro/forum/66/
Download: http://grub4dos.chenall.net
Docs: http://grub4dos.chenall.net http://chenall.net
******************************************************************************
*** GCC Blacklist ***
******************************************************************************
It is known that gcc-4.6.x creates binaries which fails to work on certain machines.
Source: http://bbs.wuyou.net/viewthread.php?tid=274070 [Chinese GBK]
It is known that gcc-4.7.x creates binaries which fails to start memtest86.
Source: http://bbs.wuyou.net/redirect.php?tid=180142&pid=2669810&goto=findpost#pid2669810 [Chinese GBK]
------------------------------------------------------------------------------
Usage:
GRUB [--bypass] [--time-out=T] [--hot-key=K] [--config-file=FILE]
The FILE, for example, can be (hd0,0)/menu.lst
In CONFIG.SYS, the line looks like:
install=c:\some\where\grub.exe --config-file=FILE
If no options present, GRUB.EXE simply uses
(hd0,0)/menu.lst
as the configure file, if it exists. (Notice! We finally
changed the default file from (hd0,0)/boot/grub/menu.lst to
(hd0,0)/menu.lst) (Changed 2006-12-23. See Update 3 below.)
The partition (hd0,0) can be of a Windows partition or a Linux
partition, or any other partition type supported by GRUB.
Only GRUB-style filename is acceptable here for FILE. A DOS
filename won't work(it is certain we should use GRUB-style
filenames because DOS-filenames won't access a file in a
Linux ext2 partition for example).(See Update 2 below)
Update: FILE can be the contents of a menu. Use semi-colon
to delimitate the embedded commands here in FILE. The FILE
can be enclosed with a pair of double-quotes. For example:
GRUB --config-file="root (hd0,0);chainloader +1"
This command will boot the system in (hd0,0).
Another example:
GRUB --config-file="reboot"
This command will reboot the machine.
One more example:
GRUB --config-file="halt"
This command will halt the machine.
if --bypass is specified, GRUB will exit to DOS when
timeout reached.
The option `--time-out=T' specifies the timeout value in
seconds. T defaults to 5 if --bypass is specified and defaults
to 0 if --bypass is not specified.
The default hot key value is 0x3920(for space bar). If this
key is pressed, GRUB will boot normally. If another key is
pressed, GRUB will terminate immediately and return back to
DOS. See "int 16 keyboard scan codes" below.
Each option can be specified only once at most.
Update 2: DOS filenames have been supported(patched by John
Cobb). If the beginning two characters of FILE are "#@", then
the rest of FILE is taken as a DOS filename. Example:
GRUB --config-file="#@c:\menu.lst"
Only the beginning 4KB of the DOS file will be used. The file
should be an uncompressed text file.
Note: You may also use the `direct DOS file access' with the
SHELL or INSTALL line in CONFIG.SYS, but should not use it
with the DEVICE line. The DOS document said that a DOS device
driver should not call the `open file' DOS call.
Update 3(2006-12-23): By default, GRUB.EXE will locate its
config file in the following order:
(DOS file) .\menu.lst, the MENU.LST in the current dir.
(DOS file) \menu.lst, the MENU.LST in the root dir of
the current drive.
(GRUB file) /menu.lst, the MENU.LST in the root dir of
the boot device.
The default boot device is still (hd0,0).
--------------------------------------------------------
Update 1: Version 0.2.0 also brings out a new thing, GRUB for NTLDR,
which could be used to boot into GRUB from the boot menu
of Windows NT/2000/XP. Copy GRLDR to the root directory of
drive C: of Windows NT/2000/XP and append to C:\BOOT.INI
this line:
C:\GRLDR="Start GRUB"
That will be done. The GRLDR should be in the same directory
as BOOT.INI and NTLDR. Note that BOOT.INI is usually hidden
and you must unhide it before you can see it. The filename
GRLDR shouldn't be changed. If GRLDR is in a NTFS partition,
it should be copied to the root directory of another non-NTFS
partition(and likewise should the menu.lst file be). If GRLDR
is compressed, e.g., in a NTFS partition, it will not work.
Even if the drive letter of this disk has been changed to
other than C by the Windows device manager, it seems you still
have to use the letter C here in BOOT.INI, otherwise, NTLDR
will fail to locate the GRLDR file.
And what's more, if you are booting NTLDR from a floppy, you
will have to write the GRLDR line in A:\BOOT.INI like this:
C:\GRLDR="Start GRUB"
and shouldn't use the letter A like this:
A:\GRLDR="Start GRUB"
(Note that in the case when BOOT.INI is on floppy A, the
notation "C:\GRLDR" actually refer to the file A:\GRLDR).
Update 2: GRUB for Linux is also introduced along with 0.2.0. You can
boot grub using a linux loader KEXEC, LILO, SYSLINUX or another
GRUB. (GRUB4LIN has merged into GRUB.EXE)
To boot GRUB off Linux, use this pair of commands:
kexec -l grub.exe
kexec -e
To boot GRUB via GRUB, use commands like the following:
kernel (hd0,0)/grub.exe
boot
To boot GRUB via LILO, use these lines in lilo.conf:
image=/boot/grub.exe
label=grub.exe
To boot GRUB via SYSLINUX, use these lines in syslinux.cfg:
label grub.exe
kernel grub.exe
LOADLIN may encounter problems when loading grub.exe, because
grub.exe requires some unchanged original BIOS interrupt
vectors, but DOS has destroyed them, and loadlin does not
recover them before it transfers control to grub.exe.
Update 3: Beginning at version 0.4.0, GRUB for DOS supports memdrives.
Example:
# boot into a floppy image
map --mem (hd0,0)/floppy.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
boot
Because the image will be copied to a memory area, the image
itself can be non-contiguous and even gzipped.
Another Example:
map --mem=-2880 (hd0,0)/floppy.img (fd0)
This memdrive (fd0) will occupy at least 1440 KB of memory.
This is useful when the size of a 1.44M-floppy image is less
than 1440 KB.
One more example:
map --mem --read-only (hd0,0)/hd.img (hd1)
This memdrive is a hard drive, and read-only. That means you
will not be able to write data to the memdrive (hd1).
You can use many memdrives and many ordinary virtual emulated
disk-based drives at the same time.
If the BIOS does not support int15/EAX=e820h, you will not be
able to use any memdrives.
Update 4: For memdrive emulation, a single-partition image can be used
instead of a whole-harddrive image. Example:
map --mem (hd0,7)/win98.img (hd0)
map --hook
chainloader (hd0)+1
rootnoverify (hd0)
map --harddrives=1
boot
Here win98.img is a partition image without the leading MBR
and partition table in it. Surely GRUB for DOS will build an
MBR and partition table for the memdrive (hd0).
Update 5: Now GRLDR can be used as a no-emulation-mode bootable CD-ROM
boot image. Example for Linux users:
mkdir iso_root
cp grldr iso_root
mkisofs -R -b grldr -no-emul-boot -boot-load-seg 0x1000 -o bootable.iso iso_root
As an alternative, grldr can also be used the same way as
stage2_eltorito. The -boot-info-table option is allowed but you
can omit it:
mkdir iso_root
cp grldr iso_root
mkisofs -R -b grldr -no-emul-boot -boot-load-size 4 -o grldr.iso iso_root
Also note that the bootable.iso above must be created with the
-boot-load-seg 0xHHHH option where HHHH is greater than or
equal to 1000(hex). If HHHH < 1000(hex), QEMU will hang. This
is a bug in QEMU. The grldr.iso can be created with or without
-boot-load-seg 0xHHHH option.
The menu.lst file should be placed in the root dir of the CD.
Update 6: The Chinese special build is in the "chinese" subdirectory.
(patched by Gandalf, 2005-06-27)
The Chinese special build also has scdrom builtin.
(update: scdrom has been dropped since 2006-07-20)
Update 7: Added memory drive (md). Like (nd) for network drive and (cd)
for CD-ROM drive, a new drive (md) is implemented for accessing
the whole memory as a disk drive. (md) only works for systems
with BIOS int15/EAX=E820h support.
The cat command now has a few new options: --hex for hexdump,
and --locate=STRING for string search in file.
Typical examples:
cat --hex (hd0)+1
It will display the MBR sector in hex form.
cat --hex (md)+2
It will display 1KB of your memory(in fact, it is the real-mode
IDT table), also in hexdump form.
cat --hex (md)0x800+1
It will display 1 sector of your extended memory.
cat --hex (hd0,0)+1
It will display the first sector of partition (hd0,0). Usually
this sector contains the boot record of an operating system.
Update 8: Added ram drive (rd). The (md) device accesses the memory
starting at physical address 0. But (rd) accesses memory
starting at any base address. The base and length of the ram
drive can be specified through the map command. "help map" for
details. You can even specify the BIOS drive number used for
the (rd) drive, e.g., map --ram-drive=0xf0. The default drive
number for (rd) is 0x7F which is a floppy. If (rd) is a hard
drive image, you should change the drive number to a value
greater than or equal to 0x80(but should avoid using 0xffff,
because 0xffff is for the (md) device).
The notation (rd)+1 always represents the file which contains
all the bytes stored in (rd).
Update 9: Directly boot NTLDR of WinNT/2K/XP and IO.SYS of Win9x/ME and
KERNEL.SYS of FreeDOS. Examples:
chainloader --edx=0xPPYY (hd0,0)/ntldr
boot
chainloader --edx=0xYY (hd0,0)/io.sys
boot
chainloader --ebx=0xYY (hd0,0)/kernel.sys
boot
Hex YY specifies the boot drive number, and hex PP specifies
the boot partition number of NTLDR. If the boot drive is
floppy, PP should be the hex value ff, i.e., decimal 255.
For KERNEL.SYS of FreeDOS, the --edx won't work,
use --ebx please.
The option --edx ( --ebx ) can be omitted if the file is in
its normal place. But in some cases, those options are needed.
If, e.g., the ntldr file is in an ext2 partition called
(hd2,8) while you want it to think of the Windows partition
(hd0,7) as the boot partition, then --edx is required:
chainloader --edx=0x0780 (hd2,8)/ntldr
For DOS kernels(i.e., IO.SYS and KERNEL.SYS), the boot
partition number is meaningless, so you only need to specify
the correct boot drive number YY(but specifying the boot
partition number is harmless).
The above PPYY can also be specified by using a root or
rootnoverify command after the chainloader command. Examples:
chainloader (hd2,6)/kernel.sys
rootnoverify (hd0) <-------- YY=80
boot
chainloader (hd0,0)/ntldr
rootnoverify (hd0,5) <-------- YY=80, PP=05
boot
Tip: CMLDR (the ComMand LoaDeR, which is used to load the
Windows Fault Recovery Console) can be chainloaded as well
as NTLDR.
Bean has successfully decompressed and booted IO.SYS of WinME.
Thanks for the great job!
Update 10: isolinux.bin (version 3.73) can be chainloaded as with build
2009-02-09.
chainloader (cd)/isolinux.bin
isolinux.bin must reside in a real or virtual cdrom.
Update 11: stage2 of Grub Legacy can be chainloaded in this way:
chainloader --force --load-segment=0 --load-offset=0x8000 --boot-cs=0 --boot-ip=0x8200 (...)/.../stage2
--------------------------------------------------------
There is no full documentation in English at present. Here are some
examples showing the usage of disk emulation commands:
1. Emulates HD partition C: as floppy drive A: and boot win98 from C:
map --read-only (hd0,0)+1 (fd0)
chainloader (hd0,0)+1
rootnoverify (hd0)
boot
In the above example, (hd0,0) is drive C: with win98 on it. After win98
boot complete, you will find that A: contains all files of C:, and if
you delete files in A:, the files in C: will also disappear.
At the map command line, the notation (hdm,n)+1 is interpreted to
represent the whole partition (hdm,n), not just the first sector of the
partition.
2. Emulates HD partition C: as floppy drive A: and boot win98 from A:
map --read-only (hd0,0)+1 (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
map --floppies=1
boot
After the "map --hook" command, the emulation takes effect instantly
even in the GRUB command line.
Note that the (fd0) in "chainloader (fd0)+1" is the emulated virtual
floppy A:, not the real floppy diskette(because map is hooked now).
3. Emulates an image file as floppy drive A: and boot win98 from C:
map --read-only (hd0,0)/floppy.img (fd0)
chainloader (hd0,0)+1
rootnoverify (hd0)
map --floppies=1
map --harddrives=1
boot
4. Emulates an HD partition as the first hard disk and boot DOS from it:
map --read-only (hd2,6)+1 (hd0)
map --hook
chainloader (hd0,0)+1
rootnoverify (hd0)
map --harddrives=1
boot
In this example, (hd2,6)+1 represents an extended logical DOS partition
of the third BIOS hard disk (hd2).
If a DOS partition is used to emulate a hard disk, GRUB for DOS will
first try to locate the partition table, usually 63 sectors ahead of
the DOS partition. GRUB for DOS will refuse the emulation if the
partition table is not there.
5. Emulates an image file as the first hard disk and boot DOS from it:
map --read-only (hd0,0)/harddisk.img (hd0)
chainloader --load-length=512 (hd0,0)/harddisk.img
rootnoverify (hd0)
map --harddrives=1
boot
If an image file is used to emulate a hard disk, the image file must
contain an MBR. In other word, the first sector of HARDDISK.IMG must
contain the partition table of the emulated virtual hard disk.
Note: Counters for floppies and harddrives in the BIOS Data Area remain
unchanged during the mapping. You should manually set them to proper
values with `map --floppies=' and/or `map --harddrives=', especially,
e.g., when there is no real floppy drive attached to the mother board.
If not doing so, DOS might fail to start.
`map --status' can report the values. Note also that `map --floppies='
and `map --harddrives=' can be used independently without the
appearance of mappings.
0.4.2 has introduced a new variable, memdisk_raw, to simulate the
memdisk-like raw mode. If the BIOS has no int15/87h, or if it has
buggy int15/87h support, you should set this variable before any
memdrives are used. Here is an example:
map --memdisk-raw=1
map --mem (hd0,0)/floppy.img (fd0)
map --hook
chainloader (fd0)+1
rootnoverify (fd0)
boot
If you encountered a memdrive failure without using
map --memdisk-raw=1, you should have a try with `map --memdisk-raw=1'.
If you `map --memdisk-raw=0' later, you should afterwards do a
`map --unhook'(and followed by a `map --hook' if needed).
Update: memdisk_raw now defaults to 1. You should `map --memdisk-raw=0'
if you want to use int15/87h to access memdrives.
--------------------------------------------------------
Floppies/harddisks of any size can be emulated with GRUB for DOS 0.2.0.
Image file must be contiguous, or else GRUB for DOS will refuse it.
The `blocklist' command can list fragments or pieces of a file.
Type "help map" at the GRUB prompt to get a brief description of the
command.
The form
map ... (fd?)
is a floppy emulation, and the form
map ... (hd?)
is a hard disk emulation.
When a HARD DISK emulation is used, better not start Windows for
security reasons. Windows may even destroy all data and all information
on all your real hard disks!!!!!!!!
Update for --mem: when --mem is used, it seems rather safe even after
entering Windows. Win98 can operate the memdrive normally.
Windows NT/2000/XP does not recognize the emulated drives no matter
whether the --mem option is present.
******************************************************************************
*** Explanation of the grldr-bootable floppies or harddisk partitions ***
******************************************************************************
1. Ext2 Boot Sector/Boot Record Layout (for loading grldr)
------------------------------------------------------------------------------
An EXT2/EXT3 volume can be GRUB-bootable. Copy grldr and an optional menu.lst
to the root dir of the EXT2/EXT3 volume, and build the boot sector based on the
fifth sector of grldr(some fields need to be changed as detailed in the
following table). And then the EXT2/EXT3 volume is GRUB-bootable.
Update: bootlace.com is a DOS/Linux utility that can install the GRLDR boot
record onto the first sector of an EXT2/EXT3 volume.
Offset Length Description
====== ====== ==============================================================
00h 2 Machine code for short jump over the data.
02h 1 LBA indicator. Valid values are 0x02 for CHS mode, or 0x42 for
LBA mode.
If the BIOS int13 supports LBA, this byte can be safely set to
0x42.
Some USB BIOSes might have bugs when using CHS mode, so the
format program should set this byte to 0x42. It seems that
(generally) all USB BIOSes have LBA support.
If the format program does not know whether the BIOS has LBA
support, it may operate this way:
if (partition_start + total_sectors_in_partition) exceeds the
CHS addressing ability(especially when it is greater than
1024*256*63), the caller should set this byte to 0x42,
otherwise, set to 0x02.
Note that Windows98 uses the value 0x0e as the LBA indicator.
Update: this byte of LBA indicator is ignored. The boot
record can probe the LBA support of BIOS.
03h 10 OEM name string (of OS which formatted the disk).
Update: this field is now used for error message of "I/O error"
0Dh 1 Sectors per block. Valid values are 2, 4, 8, 16 and 32.
0Eh 2 Bytes per block. Valid values are 0x400, 0x800, 0x1000, 0x2000
and 0x4000.
10h 4 Pointers in pointers-per-block blocks, that is, number of
blocks covered by a double-indirect block.
Valid values are 0x10000, 0x40000, 0x100000, 0x400000 and
0x1000000.
14h 4 Pointers per block, that is, number of blocks covered by an
indirect block.
Valid values are 0x100, 0x200, 0x400, 0x800, 0x1000.
18h 2 Sectors per track.
1Ah 2 Number of heads/sides.
1Ch 4 Number of hidden sectors (those preceding the boot sector).
Also referred to as the starting sector of the partition.
For floppies, it should be 0.
20h 4 Total number of sectors in the filesystem(or in the partition).
24h 1 BIOS drive number of the boot device.
Actually this byte is ignored for read. The boot code will
write DL onto this byte. The BIOS or the caller should set
drive number in DL.
We assume all BIOSes pass correct drive number in DL.
Buggy BIOSes are not supported!!
25h 1 Partition number of this partition on the boot drive.
0, 1, 2, 3 are primary partitions.
4, 5, 6, ... are logical partitions in the extended partition.
0xff is for whole drive. So for floppies, it should be 0xff.
26h 2 inode size in bytes. (Notice! We use the formerly reserved
word here for inode size!)
28h 4 Number of inodes per group.
Normally a 1.44M floppy has only one group, and the total
number of inodes is 184. So the value should be 184 or
greater.
2Ch 4 The block number for group descriptors.
Valid values are 2 for 1024-byte blocks, and 1 otherwise.
The value here is equal to (s_first_data_block + 1).
30h 1 code for "cld"(0xFC).
31h 2 code for "xor ax,ax"(0x31, 0xC0).
33h 1 code for "nop"(0x90) or "cwd"(0x99)
34h 458 The rest of the machine code.
1FEh 2 Boot Signature AA55h.
2. FAT12/FAT16 Boot Sector/Boot Record Layout (for loading grldr)
------------------------------------------------------------------------------
A FAT12/16 volume can be GRUB-bootable. Copy grldr and an optional menu.lst to
the root dir of the FAT12/16 volume, and build the boot sector based on the
fourth sector of grldr(some fields need to be changed as detailed in the
following table). And then the FAT12/16 volume is GRUB-bootable.
Update: bootlace.com is a DOS/Linux utility that can install the GRLDR boot
record onto the boot sector of an FAT12/16 volume.
Offset Length Description
====== ====== ==============================================================
00h 2 Machine code for short jump over the data.
02h 1 LBA indicator. Valid values are 0x90 for CHS mode, or 0x0e for
LBA mode.
If the BIOS int13 supports LBA, this byte can be safely set to
0x0e.
Some USB BIOSes might have bugs when using CHS mode, so the
format program should set this byte to 0x0e. It seems that
(generally) all USB BIOSes have LBA support.
If the format program does not know whether the BIOS has LBA
support, it may operate this way:
if (partition_start + total_sectors_in_partition) exceeds the
CHS addressing ability(especially when it is greater than
1024*256*63), the caller should set this byte to 0x0e,
otherwise, set to 0x90.
Update: this byte of LBA indicator is ignored. The boot
record can probe the LBA support of BIOS.
Update(2006-07-31): Though GRLDR won't use this LBA-indicator
byte, Windows 98 uses it. Usually this byte should be 0x90 for
CHS mode(especially for floppies). If this byte is not set
properly, Windows 98 will not recognize the floppy or
partition. This problem was reported by neiljoy. Many thanks!
03h 8 OEM name string (of OS which formatted the disk).
0Bh 2 Bytes per sector. Must be 512.
0Dh 1 Sectors per cluster. Valid values are 1, 2, 4, 8, 16, 32, 64
and 128. But a cluster size larger than 32K should not occur.
0Eh 2 Reserved sectors(number of sectors before the first FAT,
including the boot sector), usually 1.
10h 1 Number of FATs(nearly always 2).
11h 2 Maximum number of root directory entries.
13h 2 Total number of sectors (for small disks only, if the disk is
too big this is set to 0 and offset 20h is used instead).
15h 1 Media descriptor byte, pretty meaningless now (see below).
16h 2 Sectors per FAT.
18h 2 Sectors per track.
1Ah 2 Total number of heads/sides.
1Ch 4 Number of hidden sectors (those preceding the boot sector).
Also referred to as the starting sector of the partition.
For floppies, it should be 0.
20h 4 Total number of sectors for large disks.
24h 1 BIOS drive number of the boot device.
Actually this byte is ignored for read. The boot code will
write DL onto this byte. The BIOS or the caller should set
drive number in DL.
We assume all BIOSes pass correct drive number in DL.
Buggy BIOSes are not supported!!
25h 1 Partition number of this filesystem in the boot drive.
This byte is ignored for read. The boot code will write
partition number onto this byte. See offset 41h below.
26h 1 Signature (must be 28h or 29h to be recognised by NT).
27h 4 Volume serial number.
2Bh 11 Volume label.
36h 8 File system ID. "FAT12 ", "FAT16 " or "FAT ".
3Eh 1 code for "cli".
3Fh 1 code for "cld".
40h 1 code for "mov dh, imm8".
41h 1 Partition number of this partition on the boot drive.
0, 1, 2, 3 are primary partitions.
4, 5, 6, ... are logical partitions in the extended partition.
0xff is for whole drive. So for floppies, it should be 0xff.
42h 442 The rest of the machine code.
1FCh 4 Boot Signature AA550000h. (Win9x uses 4 bytes as magic value)
3. FAT32 Boot Sector/Boot Record Layout (for loading grldr)
------------------------------------------------------------------------------
A FAT32 volume can be GRUB-bootable. Copy grldr and an optional menu.lst to
the root dir of the FAT32 volume, and build the boot sector based on the
third sector of grldr(some fields need to be changed as detailed in the
following table). And then the FAT32 volume is GRUB-bootable.
Update: bootlace.com is a DOS/Linux utility that can install the GRLDR boot
record onto the boot sector of an FAT32 volume.
Offset Length Description
====== ====== ==============================================================
00h 2 Machine code for short jump over the data.
02h 1 LBA indicator. Valid values are 0x90 for CHS mode, or 0x0e for
LBA mode.
If the BIOS int13 supports LBA, this byte can be safely set to
0x0e.
Some USB BIOSes might have bugs when using CHS mode, so the
format program should set this byte to 0x0e. It seems that
(generally) all USB BIOSes have LBA support.
If the format program does not know whether the BIOS has LBA
support, it may operate this way:
if (partition_start + total_sectors_in_partition) exceeds the
CHS addressing ability(especially when it is greater than
1024*256*63), the caller should set this byte to 0x0e,
otherwise, set to 0x90.
Update: this byte of LBA indicator is ignored. The boot
record can probe the LBA support of BIOS.
Update(2006-07-31): Though GRLDR won't use this LBA-indicator
byte, Windows 98 uses it. Usually this byte should be 0x90 for
CHS mode(especially for floppies). If this byte is not set
properly, Windows 98 will not recognize the floppy or
partition. This problem was reported by neiljoy. Many thanks!
03h 8 OEM name string (of OS which formatted the disk).
0Bh 2 Bytes per sector. Must be 512.
0Dh 1 Sectors per cluster. Valid values are 1, 2, 4, 8, 16, 32, 64
and 128. But a cluster size larger than 32K should not occur.
0Eh 2 Reserved sectors(number of sectors before the first FAT,
including the boot sector), usually 1.
10h 1 Number of FATs(nearly always 2).
11h 2 (Maximum number of root directory entries)Must be 0.
13h 2 (Total number of sectors for small disks only)Must be 0.
15h 1 Media descriptor byte, pretty meaningless now (see below).
16h 2 (Sectors per FAT)Must be 0.
18h 2 Sectors per track.
1Ah 2 Total number of heads/sides.
1Ch 4 Number of hidden sectors (those preceding the boot sector).
Also referred to as the starting sector of the partition.
For floppies, it should be 0.
20h 4 Total number of sectors for large disks.
24h 4 FAT32 sectors per FAT.
28h 2 If bit 7 is clear then all FATs are updated, otherwise bits
0-3 give the current active FAT, all other bits are reserved.
2Ah 2 High byte is major revision number, low byte is minor revision
number, currently both are 0.
2Ch 4 Root directory starting cluster.
30h 2 File system information sector.
32h 2 If non-zero this gives the sector which holds a copy of the
boot record, usually 6.
34h 12 Reserved, set to 0.
40h 1 BIOS drive number of the boot device.
80h is first HDD, 00h is first FDD.
Actually this byte is ignored for read. The boot code will
write DL onto this byte. The BIOS or the caller should set
drive number in DL.
We assume all BIOSes pass correct drive number in DL.
Buggy BIOSes are not supported!!
41h 1 Partition number of this filesystem in the boot drive.
This byte is ignored for read. The boot code will write
partition number onto this byte. See offset 5Dh below.
42h 1 Signature (must be 28h or 29h to be recognised by NT).
43h 4 Volume serial number.
47h 11 Volume label.
52h 8 File system ID. "FAT32 ".
5Ah 1 opcode for "cli".
5Bh 1 opcode for "cld".
5Ch 1 opcode for "mov dh, imm8".
5Dh 1 Partition number of this partition on the boot drive.
0, 1, 2, 3 are primary partitions.
4, 5, 6, ... are logical partitions in the extended partition.
0xff is for whole drive. So for floppies, it should be 0xff.
5Eh 414 The rest of the machine code.
1FCh 4 Boot Signature AA550000h. (Win9x uses 4 bytes as magic value)
4. NTFS Boot Sector/Boot Record Layout (for loading grldr)
------------------------------------------------------------------------------
An NTFS volume can be GRUB-bootable. Copy grldr and an optional menu.lst to
the root dir of the NTFS volume, and build the boot sector based on the
6th-9th sectors of grldr(some fields need to be changed as detailed in the
following table). And then the NTFS volume is GRUB-bootable.
Update: bootlace.com is a DOS/Linux utility that can install the GRLDR boot
record onto the leading 4 sectors of an NTFS volume.
Offset Length Description
====== ====== ==============================================================
00h 2 Machine code for short jump over the data.
02h 1 LBA indicator. Valid values are 0x90 for CHS mode, or 0x0e for
LBA mode.
If the BIOS int13 supports LBA, this byte can be safely set to
0x0e.
Some USB BIOSes might have bugs when using CHS mode, so the
format program should set this byte to 0x0e. It seems that
(generally) all USB BIOSes have LBA support.
If the format program does not know whether the BIOS has LBA
support, it may operate this way:
if (partition_start + total_sectors_in_partition) exceeds the
CHS addressing ability(especially when it is greater than
1024*256*63), the caller should set this byte to 0x0e,
otherwise, set to 0x90.
Update: this byte of LBA indicator is ignored. The boot
record can probe the LBA support of BIOS.
Update(2006-07-31): Though GRLDR won't use this LBA-indicator
byte, Windows 98 uses it. Usually this byte should be 0x90 for
CHS mode(especially for floppies). If this byte is not set
properly, Windows 98 will not recognize the floppy or
partition. This problem was reported by neiljoy. Many thanks!
03h 8 OEM name string (of OS which formatted the disk).
0Bh 2 Bytes per sector. Must be 512.
0Dh 1 Sectors per cluster. Valid values are 1, 2, 4, 8, 16, 32, 64
and 128. But a cluster size larger than 32K should not occur.
0Eh 2 (Reserved sectors)Unused.
10h 1 (Number of FATs)Must be 0.
11h 2 (Maximum number of root directory entries)Must be 0.
13h 2 (Total number of sectors for small disks only)Must be 0.
15h 1 Media descriptor byte, pretty meaningless now (see below).
16h 2 (Sectors per FAT)Must be 0.
18h 2 Sectors per track.
1Ah 2 Total number of heads/sides.
1Ch 4 Number of hidden sectors (those preceding the boot sector).
Also referred to as the starting sector of the partition.
For floppies, it should be 0.
20h 4 (Total number of sectors for large disks)Must be 0.
24h 4 (FAT32 sectors per FAT) - Usually 80 00 80 00, A value of
80 00 00 00 has been seen on a USB thumb drive which is
formatted with NTFS under Windows XP. Note this is removable
media and is not partitioned, the drive as a whole is NTFS
formatted.
28h 8 Number of sectors in the volume.
30h 8 LCN of VCN 0 of the $MFT.
38h 8 LCN of VCN 0 of the $MFTMirr.
40h 4 Clusters per MFT Record.
44h 4 Clusters per Index Record.
48h 8 Volume serial number.
50h 4 Checksum, usually 0.
54h 1 opcode for "cli".
55h 1 opcode for "cld".
56h 1 opcode for "mov dh, imm8".
57h 1 Partition number of this partition on the boot drive.
0, 1, 2, 3 are primary partitions.
4, 5, 6, ... are logical partitions in the extended partition.
0xff is for whole drive. So for floppies, it should be 0xff.
58h 420 The rest of the machine code in the first sector.
1FCh 4 Boot Signature AA550000h. (Win9x uses 4 bytes as magic value)
200h 1536 The rest of the machine code in the last 3 sectors.
------------------------------------------------------------------------------
Appendix A: File System Information Sector of FAT32(not used by grldr)
Offset Length Description
====== ====== ==============================================================
0h 4 Leading Signature 41615252h.
4h 480 Reserved, set to 0.
1E4h 4 FSI structure signature 61417272h.
1E8h 4 Contains the last known count of free clusters, if this is
equal to FFFFFFFFh, then the count is unknown.
1ECh 4 Cluster number at which you should begin a search for a free
cluster, if this is equal to FFFFFFFFh then the field has not
been set.
1F0h 12 Reserved, set to 0.
1FCh 4 Trailing Signature AA550000h.