All of lore.kernel.org
 help / color / mirror / Atom feed
* boot.img Fix
@ 2009-07-07  8:08 Yves BLUSSEAU
  2009-07-07 22:17 ` Pavel Roskin
  0 siblings, 1 reply; 8+ messages in thread
From: Yves BLUSSEAU @ 2009-07-07  8:08 UTC (permalink / raw)
  To: grub-devel


[-- Attachment #1.1: Type: text/plain, Size: 1069 bytes --]

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

[-- Attachment #1.2: boot_img_fat32.diff --]
[-- Type: text/plain, Size: 3013 bytes --]

commit 1890e0781d4e210c6076568a81899ed598319249
Author: Yves Blusseau <cl7m42e02@sneakemail.com>
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  <cl7m42e02@sneakemail.com>
+
+	* 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  <proski@gnu.org>
 
 	* 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 #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3313 bytes --]

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-14 17:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-07  8:08 boot.img Fix Yves BLUSSEAU
2009-07-07 22:17 ` Pavel Roskin
2009-07-08  5:06   ` Pavel Roskin
2009-07-08  8:13   ` Yves BLUSSEAU
2009-07-08 23:09   ` Vladimir 'phcoder' Serbinenko
2009-07-10 17:15     ` Robert Millan
2009-07-12 13:30       ` Pavel Roskin
2009-07-14 17:34         ` Robert Millan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.