On Sep 21, R Sen wrote:
> 
> So, I've written a utility in DOS (because our image download system is
> DOS based, over a remote boot system, and there's no chance of changing
> all that), that finds the grub stage2 in the linux partition and patches
> the sector number in the stage1, in the MBR.
> 
> So far so good, that works fine, it finds the second stage.  But then it
> hangs, because I also need to change the stage2 slightly, I realise, to
> point to the stage2 sector 2, and possibly the menu?  I've found that the
> following bits of stage 2 change - parts of the last 16 bytes of sector 1,
> and the 16 bytes of sector 2.
> 
> 000001f0 49 38 F8 00 2A 00 00 14 E2 37 F8 00 5F 00 20 08 
> 00000200 EA 70 82 00 00 00 03 01 FF FF 02 00 00 00 30 2E
> 
> I've found the bit in the source code ('install_func' in builtins.c) where
> this happens, but unfortunately I was unable to easily follow what is
> going on.
> 
> Can anyone explain what I need to point where in this region of stage2?

The first sector of stage2 (until address 0x1ff) is start.S.  Its
task is to load all remaining sectors of stage2.  In your case, the
data is from back to front:

to segment 0x0820 load 0x005f sectors from address 0x00f837e2
to segment 0x1400 load 0x002a sectors from address 0x00f83849
Your stage2 is fragmented in two parts.

At address 0x200 follows asm.S.  At 0x208 is the partition encoded in
4 bytes, I think it's (hd0,2) in your case.  At address 0x20f is a
version string directly followed by the path to menu.lst.

> In a future version of Grub it might be nice (for us poor imaging people
> with hundreds/thousands of machines, some with different sized disks) if
> it was possible to take the offset from the start of the partition, or
> something like that, which would allow the partition to move?

This would mean we had to put partition decoding code into the first
sector, which is only 512 bytes.  Also stage2 (resp. stage1_5) may not
be in any partition if it is embedded before the first partition.

  Jochen
_______________________________________________
Bug-grub mailing list
[EMAIL PROTECTED]
http://mail.gnu.org/mailman/listinfo/bug-grub

Reply via email to