grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

boot.img Fix


From: Yves BLUSSEAU
Subject: boot.img Fix
Date: Tue, 07 Jul 2009 10:08:27 +0200
User-agent: Thunderbird 2.0.0.22 (Windows/20090605)

Hi,

there is a "bug" in boot.img: if you install the boot.img into the volume boot sector of a FAT32 partition instead of MBR (i know it's a bad idea), you "destroyed" the partition (even grub will not recognize it). The problem is that the FAT32 FileSystem need a 87 bytes long BPB instead of the 59 bytes long for FAT16 (http://en.wikipedia.org/wiki/File_Allocation_Table#Boot_Sector). So the boot.img need to preverse the first 90 bytes of the first sectors of a FAT32 partition.
I made this patch to fix it and it work perfectly.

What i have done is:
   * change the offset of the end of BPB
   * change the offsets of the data inside the region of Extended BPB
   * remove 2 constants that are never used
   * change the minor version of the GRUB_BOOT_VERSION 4.0 => 4.1
   * change the string of hd_probe_error_string from "Hard Drive" to "HD"
      because i needed 2 extras bytes and do not want to change the working
      code of the boot.

Now the bootloader (boot.img) can be install on any FAT volume partitions.

Best Regards,
Yves Blusseau
commit 1890e0781d4e210c6076568a81899ed598319249
Author: Yves Blusseau <address@hidden>
Date:   Tue Jul 7 10:04:33 2009 +0200

    Extend the BPB for compatibility with FAT32 volume boot partition

diff --git a/ChangeLog b/ChangeLog
index ed6b637..d52de45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2009-07-07  Yves BLUSSEAU  <address@hidden>
+
+       * include/grub/boot.h (GRUB_BOOT_VERSION_MINOR):
+       change the GRUB_BOOT_VERSION from 4.0 to 4.1
+
+       * boot/i386/pc/boot.S: Change hd_probe_error_string from
+       "Hard Drive" to "HD" to gain 2 extra bytes
+
+       * include/grub/i386/pc/boot.h: Change the offsets to extend
+       the BPB for compatibility with FAT32 volume boot partitions
+
 2009-07-06  Pavel Roskin  <address@hidden>
 
        * commands/search.c (search_fs): Fix potential NULL pointer
diff --git a/boot/i386/pc/boot.S b/boot/i386/pc/boot.S
index 8d8c27c..d43aec6 100644
--- a/boot/i386/pc/boot.S
+++ b/boot/i386/pc/boot.S
@@ -434,11 +434,11 @@ general_error:
         int    $0x18
 stop:  jmp     stop
 
-notification_string:   .asciz "GRUB "
-geometry_error_string: .asciz "Geom"
-hd_probe_error_string: .asciz "Hard Disk"
-read_error_string:     .asciz "Read"
-general_error_string:  .asciz " Error"
+notification_string:   .asciz "GRUB "
+geometry_error_string: .asciz "Geom"
+hd_probe_error_string: .asciz "HD"
+read_error_string:     .asciz "Read"
+general_error_string:  .asciz " Error"
 
 /*
  * message: write the string pointed to by %si
diff --git a/include/grub/boot.h b/include/grub/boot.h
index 2357748..43cd3a5 100644
--- a/include/grub/boot.h
+++ b/include/grub/boot.h
@@ -20,7 +20,7 @@
 #define GRUB_BOOT_HEADER       1
 
 #define GRUB_BOOT_VERSION_MAJOR        4
-#define GRUB_BOOT_VERSION_MINOR        0
+#define GRUB_BOOT_VERSION_MINOR        1
 #define GRUB_BOOT_VERSION      ((GRUB_BOOT_VERSION_MINOR << 8) \
                                        | GRUB_BOOT_VERSION_MAJOR)
 
diff --git a/include/grub/i386/pc/boot.h b/include/grub/i386/pc/boot.h
index f35cb3a..57f53ca 100644
--- a/include/grub/i386/pc/boot.h
+++ b/include/grub/i386/pc/boot.h
@@ -26,25 +26,19 @@
 #define GRUB_BOOT_MACHINE_BPB_START    0x3
 
 /* The offset of the end of BPB (BIOS Parameter Block).  */
-#define GRUB_BOOT_MACHINE_BPB_END      0x3e
+#define GRUB_BOOT_MACHINE_BPB_END      0x5a
 
 /* The offset of the major version.  */
-#define GRUB_BOOT_MACHINE_VER_MAJ      0x3e
+#define GRUB_BOOT_MACHINE_VER_MAJ      0x5a
 
 /* The offset of BOOT_DRIVE.  */
-#define GRUB_BOOT_MACHINE_BOOT_DRIVE   0x4c
-
-/* The offset of KERNEL_ADDRESS.  */
-#define GRUB_BOOT_MACHINE_KERNEL_ADDRESS       0x40
+#define GRUB_BOOT_MACHINE_BOOT_DRIVE   0x68
 
 /* The offset of KERNEL_SECTOR.  */
-#define GRUB_BOOT_MACHINE_KERNEL_SECTOR        0x44
-
-/* The offset of KERNEL_SEGMENT.  */
-#define GRUB_BOOT_MACHINE_KERNEL_SEGMENT       0x42
+#define GRUB_BOOT_MACHINE_KERNEL_SECTOR        0x60
 
 /* The offset of BOOT_DRIVE_CHECK.  */
-#define GRUB_BOOT_MACHINE_DRIVE_CHECK  0x4e
+#define GRUB_BOOT_MACHINE_DRIVE_CHECK  0x6a
 
 /* The offset of a magic number used by Windows NT.  */
 #define GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC     0x1b8

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]