Skip to contentSkip to conversation

Windows,grub and grub2

DISCUSSION Viswesh S 3 participants 5 messages Aug 29, 2008 – Aug 30, 2008

lore
Share & tools
lore

Viswesh S

author
#0 lore raw

Hi,

I am back with my Windows boot up question using grub and grub2.Sorry for making the question a bit long.

Some experiments and results which I did.

Scenario: One hard disk,different partitions.

Case 1:

Partition 1 -> Windows Server 2003 Partition 2 -> Swap
Partition 3 -> Linux

Boot loader : Grub2.

Windows boots up successfully from grub2 using chainloading (hd0,1) +1

Case 2:

Installed server 2008 in the free space in between Server 2003 and swap.

Partition 1 : Windows server 2003 Partition 2: Windows server 2008 Partition 3 :Swap
Partition 4:Linux

Grub2 doesnt boot up windows with the command chainloader (hd0,1) +1, with error

A disk read error occurred Ctrl+Alt +del to restart.

But Grub legacy boots up with no issues , with the same command, prefixed with rootnoverify hd0

Case 3:

Partition 1 :Boot
Partition 2:Windows
Partition 3: Linux

Same behaviour : Grub2 doesnt boot Windows with chainloader command (hd0,2) +1

Same error as before.

Not surprisingly grub boots with the same command.

I had a look at the boot sector code of Windows, which gets copied, by dumping the partition using dd.

For me, it looked the same.

Also another hunch is that,as the error ( A disk read error occurred ),, happened in Windows boot sector, find the areas in boot sector code of Windows where it calls this error and goes into an infinite loop.

So in the different cases, I could see that it is something to do with the INT 13 call, with functions 41 and 42.

Can anyone let me know the differences here, with respect to grub2 and grub.

Also,on more thing is the way chainloader command is written in grub and grub2.I was finding it difficult to decode the assembly parts in both and find out the differences.

Can anyone pour some advice and directions on these.

Thanks in advance,

Viswesh

Unlimited freedom, unlimited storage. Get it now, on http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html/

#1 lore raw
Quoted 62 lines · Viswesh S

Hi,

I am back with my Windows boot up question using grub and grub2.Sorry for making the question a bit long.

Some experiments and results which I did.

Scenario: One hard disk,different partitions.

Case 1:

Partition 1 -> Windows Server 2003
Partition 2 -> Swap
Partition 3 -> Linux

Boot loader : Grub2.

Windows boots up successfully from grub2 using chainloading (hd0,1) +1

Case 2:

Installed server 2008 in the free space in between Server 2003 and swap.

Partition 1 : Windows server 2003
Partition 2: Windows server 2008
Partition 3 :Swap
Partition 4:Linux

Grub2 doesnt boot up windows with the command chainloader (hd0,1) +1, with error

A disk read error occurred
Ctrl+Alt +del to restart.

But Grub legacy boots up with no issues , with the same command, prefixed with rootnoverify hd0

Case 3:

Partition 1 :Boot
Partition 2:Windows
Partition 3: Linux

Same behaviour : Grub2 doesnt boot Windows with chainloader command (hd0,2) +1

Same error as before.

Not surprisingly grub boots with the same command.

I had a look at the boot sector code of Windows, which gets copied, by dumping the partition using dd.

For me, it looked the same.

Also another hunch is that,as the error ( A disk read error occurred ),, happened in Windows boot sector, find the areas in boot sector code of Windows where it calls this error and goes into an infinite loop.

So in the different cases, I could see that it is something to do with the INT 13 call, with functions 41 and 42.

Quoted 7 lines

Can anyone let me know the differences here, with respect to grub2 and grub.

Also,on more thing is the way chainloader command is written in grub and grub2.I was finding it difficult to decode the assembly parts in both and find out the differences.

Can anyone pour some advice and directions on these.

Hi,

I thinks it's caused by partition entry pointer %esi which isn't correct in grub2, please see if this patch fixes the problem.

Signature · 1 line
Bean
loader/i386/pc/chainloader.c +15 -3
index 825dbb3..ab3b203 100644
@@ -101,12 +101,24 @@ grub_chainloader_cmd (const char *filename, grub_chainloader_flags_t flags)
 	  /* In i386-pc, the id is equal to the BIOS drive number.  */
 	  drive = (int) disk->id;
 
-	  if (p)
+	  if ((p) && (p->index < 4))
 	    {
-	      grub_disk_read (disk, p->offset, 446, 64,
-			      (char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
+              int i;
+
+	      disk->dev->read (disk, 0, 1,
+                               (char *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR);
+
+              grub_memcpy ((char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR,
+                           (char *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR + 0x1be,
+                           64);
+
 	      part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
 				    + (p->index << 4));
+
+              for (i = 0; i < 4; i++)
+                *((char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR + i * 16) = 0;
+
+              *((char *) part_addr) = 0x80;
 	    }
 	}
 
#2 lore raw
Quoted 8 lines

Hi,

I thinks it's caused by partition entry pointer %esi which isn't correct in grub2, please see if this patch fixes the problem.

--
Bean

Hi,

BTW, you should use the following command:

set root=(hd0,1)
chainloader +1

It's not the same as chainloader (hd0,1)+1, as chainloader command would use the value of root to decide the boot partition index.

Signature · 1 line
Bean
#3 lore raw
In reply to Bean
Quoted 2 lines · Bean

I thinks it's caused by partition entry pointer %esi which isn't correct in grub2, please see if this patch fixes the problem.

Shouldn't chainloader be a bit generic and not to expect partition table to be DOS style?

At least your patch seems to assume that.

#4 lore raw
Quoted 8 lines · Vesa Jääskeläinen
Quoted 2 lines · Bean

I thinks it's caused by partition entry pointer %esi which isn't correct in grub2, please see if this patch fixes the problem.

Shouldn't chainloader be a bit generic and not to expect partition table to be DOS style?

At least your patch seems to assume that.

Hi,

This patch is a quick fix to see if this is indeed the cause of problem, we can make it more generic later. Besides, I believe this information is only used by MS$, which assumes pc partition table anyway.

Signature · 1 line
Bean