Skip to contentSkip to conversation

does disk geometry depend on partition table?

DISCUSSION Zhixu Liu 2 participants 4 messages Nov 6, 2006 – Nov 14, 2006

lore
Share & tools
lore

Zhixu Liu

author
#0 lore raw

Hi, all,

We encounter a strange problem recently. In short, following is the output of geometry of
hd0 in situation with correct partition in disk and without partition in disk.

When with correct partition table in disk hd0:
grub> geometry (hd0)
drive 0x80: C/H/S = 500/16/32, The number of sectors = 256000, LBA

When without partition table in disk hd0:
grub> geometry (hd0)
drive 0x80: C/H/S = 126/32/63, The number of sectors = 256000, LBA

The former is correct! However, it's strange that the disk geometry depend on the partition table?!
Maybe this is due to a buggy BIOS implementation. We also check the code in disk/i386/pc/biosdisk.c
or (stage2/bios.c) for grub-0.97, and for code in function grub_biosdisk_open (or get_diskinfo in grub-0.97),
there is a standard int13 check of disk after check with ext int13,

 if(drive & 0x80) {
    ...
   version = grub_biosdisk_check_int13_extension();
     if(version) {
        grub_biosdisk_get_diskinfo_int13_extensions();
     }

}

grub_biosdisk_get_diskinfo_standard()

We're wondering does it really need to call grub_biosdisk_get_diskinfo_standard() again if we have get the necessary information
from ext int13? I think we call the later only if ext int13 failed for some reason. Especially in our case the code should be .

 if(drive & 0x80) {
    ...
   version = grub_biosdisk_check_int13_extension();
     if(version) {
        grub_biosdisk_get_diskinfo_int13_extensions();
     } else {
        grub_biosdisk_get_diskinfo_standard()
     }

}

and it do works!

Of course, maybe there are some details I'm not clear. Does anyone encounter this problem before?

Best regards!

Signature · 1 line
Zhixu Liu
#1 lore raw
Quoted 49 lines · Zhixu Liu

Hi, all,

We encounter a strange problem recently. In short, following is the output of geometry of
hd0 in situation with correct partition in disk and without partition in disk.
When with correct partition table in disk hd0:

grub> geometry (hd0)
drive 0x80: C/H/S = 500/16/32, The number of sectors = 256000, LBA

When without partition table in disk hd0:
grub> geometry (hd0)
drive 0x80: C/H/S = 126/32/63, The number of sectors = 256000, LBA

The former is correct! However, it's strange that the disk geometry depend on the partition table?!
Maybe this is due to a buggy BIOS implementation. We also check the code in disk/i386/pc/biosdisk.c
or (stage2/bios.c) for grub-0.97, and for code in function grub_biosdisk_open (or get_diskinfo in grub-0.97),
there is a standard int13 check of disk after check with ext int13,

  if(drive & 0x80) {
     ...
    version = grub_biosdisk_check_int13_extension(); 
      if(version) {
         grub_biosdisk_get_diskinfo_int13_extensions();
      }
   }

grub_biosdisk_get_diskinfo_standard()

We're wondering does it really need to call grub_biosdisk_get_diskinfo_standard() again if we have get the necessary information
from ext int13? I think we call the later only if ext int13 failed for some reason. Especially in our case the code should be .

  if(drive & 0x80) {
     ...
    version = grub_biosdisk_check_int13_extension();
      if(version) {
         grub_biosdisk_get_diskinfo_int13_extensions();
      } else {
         grub_biosdisk_get_diskinfo_standard()
      }
   }
Quoted 1 line

and it do works!

Thanks for your report, Zhixu. Does this patch work?

Index: disk/i386/pc/biosdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/i386/pc/biosdisk.c,v retrieving revision 1.9

i386/pc/biosdisk.c 14 Nov 2006 03:39:47 -0000 renamed from i386/pc/biosdisk.c 29 Jul 2006 10:11:01 -0000 1.9 +13 -10
diff -u -p -r1.9 biosdisk.c
@@ -133,21 +133,24 @@ grub_biosdisk_open (const char *name, gr
        }
     }
 
-  if (grub_biosdisk_get_diskinfo_standard (drive,
-                                          &data->cylinders,
-                                          &data->heads,
-                                          &data->sectors) != 0)
+  if (! total_sectors)
     {
-      grub_free (data);
-      return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
-    }
+      /* FDD, or HDD without int13 extensions.  */
+      if (grub_biosdisk_get_diskinfo_standard (drive,
+                                              &data->cylinders,
+                                              &data->heads,
+                                              &data->sectors) != 0)
+       {
+         grub_free (data);
+         return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
+       }
 
-  if (! total_sectors)
-    total_sectors = data->cylinders * data->heads * data->sectors;
+      total_sectors = data->cylinders * data->heads * data->sectors;
+    }
 
   disk->total_sectors = total_sectors;
   disk->data = data;
-
+
   return GRUB_ERR_NONE;
 }
 

-Hollis

author
#2 lore raw

Hi, Hollis,

We've tried something like this, and found it works for some platform, but still failed for one platform.
Indeed, in this weird platform, we get both wrong CHS value with and without partition table. But the OS always
get the correct value. The problem is due to either BIOS or Disk for this particular platform, we think. But we're not clear.

Anyway, the patch works for some cases, and should for most cases.

Best regards!

Zhixu

Quoted 108 lines · Hollis Blanchard
Quoted 49 lines · Zhixu Liu

Hi, all,

We encounter a strange problem recently. In short, following is the output of geometry of
hd0 in situation with correct partition in disk and without partition in disk.
When with correct partition table in disk hd0:

grub> geometry (hd0)
drive 0x80: C/H/S = 500/16/32, The number of sectors = 256000, LBA

When without partition table in disk hd0:
grub> geometry (hd0)
drive 0x80: C/H/S = 126/32/63, The number of sectors = 256000, LBA

The former is correct! However, it's strange that the disk geometry depend on the partition table?!
Maybe this is due to a buggy BIOS implementation. We also check the code in disk/i386/pc/biosdisk.c
or (stage2/bios.c) for grub-0.97, and for code in function grub_biosdisk_open (or get_diskinfo in grub-0.97),
there is a standard int13 check of disk after check with ext int13,

  if(drive & 0x80) {
     ...
    version = grub_biosdisk_check_int13_extension();
      if(version) {
         grub_biosdisk_get_diskinfo_int13_extensions();
      }
   }

grub_biosdisk_get_diskinfo_standard()

We're wondering does it really need to call grub_biosdisk_get_diskinfo_standard() again if we have get the necessary information
from ext int13? I think we call the later only if ext int13 failed for some reason. Especially in our case the code should be .

  if(drive & 0x80) {
     ...
    version = grub_biosdisk_check_int13_extension();
      if(version) {
         grub_biosdisk_get_diskinfo_int13_extensions();
      } else {
         grub_biosdisk_get_diskinfo_standard()
      }
   }
Quoted 1 line

and it do works!

Thanks for your report, Zhixu. Does this patch work?

Index: disk/i386/pc/biosdisk.c
===================================================================
RCS file: /cvsroot/grub/grub2/disk/i386/pc/biosdisk.c,v retrieving revision 1.9
diff -u -p -r1.9 biosdisk.c

i386/pc/biosdisk.c 14 Nov 2006 03:39:47 -0000 renamed from i386/pc/biosdisk.c 29 Jul 2006 10:11:01 -0000 1.9 +13 -11
@@ -133,21 +133,24 @@ grub_biosdisk_open (const char *name, gr
        }
     }
 
-  if (grub_biosdisk_get_diskinfo_standard (drive,
-                                          &data->cylinders,
-                                          &data->heads,
-                                          &data->sectors) != 0)
+  if (! total_sectors)
     {
-      grub_free (data);
-      return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S values");
-    }
+      /* FDD, or HDD without int13 extensions.  */
+      if (grub_biosdisk_get_diskinfo_standard (drive,
+                                              &data->cylinders,
+                                              &data->heads,
+                                              &data->sectors) != 0)
+       {
+         grub_free (data);
+         return grub_error (GRUB_ERR_BAD_DEVICE, "cannot get C/H/S
 values");
+       }
 
-  if (! total_sectors)
-    total_sectors = data->cylinders * data->heads * data->sectors;
+      total_sectors = data->cylinders * data->heads * data->sectors;
+    }
 
   disk->total_sectors = total_sectors;
   disk->data = data;
-
+
   return GRUB_ERR_NONE;
 }
 
 
-Hollis

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

Signature · 1 line
Zhixu Liu
#3 lore raw
Quoted 8 lines · Zhixu Liu

Hi, Hollis,

We've tried something like this, and found it works for some platform, but still failed for one platform.
Indeed, in this weird platform, we get both wrong CHS value with and without partition table. But the OS always
get the correct value. The problem is due to either BIOS or Disk for this particular platform, we think. But we're not clear.

That platform must have a BIOS bug and we have no known workaround. :/

Quoted 1 line

Anyway, the patch works for some cases, and should for most cases.

OK. I will commit this soon unless I hear an objection.

-Hollis