Jump to content











Photo
- - - - -

Chainload grldr or ntldr from Grub2


  • Please log in to reply
20 replies to this topic

#1 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 06:28 PM

I need to chainload ntldr and grldr from Grub2. Can someone please help. I found this, by one call Bean, but I can't get it to work, it hangs after 'linux loadbin':

Instead of combining the header and
the image, we can make the header separate, and load the image as
initrd. This method can be used to load system images like ntldr and
grldr. For example, to chainload ntldr from grub2:

linux loadbin.bin
initrd ntldr
This method is not limited to grub2, it can also be used in boot
loaders which support the linux kernel format, such as
syslinux/lilo/grub.

To compile loadbin.bin, use the following commands:

gcc -nostdlib -DLOADBIN -Wl,-N -o lnxhdr lnxhdr.S
objcopy -O binary lnxhdr lnxhdr.bin

loadbin can be downloaded here .

I know grub4dos can be chainloaded using 'linux grub.exe', but I'm interested in specifically chainloading grldr or ntldr.

Thanks.

#2 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 13 June 2010 - 06:32 PM

...I know grub4dos can be chainloaded using 'linux grub.exe', but I'm interested in specifically chainloading grldr or ntldr.

Why?

#3 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 06:53 PM

Why?


More specifically Shao, I'm interested in chainloading ntldr, but I know once it works for ntldr it will also work for grldr. It is because, I am trying to boot a VHD with grub2 and so far I've have good success - I can mount the image, and access it's contents but I cannot directly chainload the MBR(chainloader +1) or BPR, I can only chainload kernel,ntldr, files etc off the hard disk image even if it contains an MBR. Its a proof-of-concept exercise and it already works with Linux(I tried it with CloneZilla). Now I need to boot Windows XP.

#4 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 13 June 2010 - 06:57 PM

I know grub4dos can be chainloaded using 'linux grub.exe', but I'm interested in specifically chainloading grldr or ntldr.

It can not.
You need to use:
linux16 grub.exe


#5 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 13 June 2010 - 07:09 PM

linux16 grub.exe --config-file="root (hd0,0);chainloader /ntldr"
append --config-file="root (hd0,0);chainloader /ntldr"


I still don't quite follow. You can't load the MBR of the .VHD or don't want to?

EDIT: Thanks for the APPEND correction, Icecube. I don't use GRUB2. :)

#6 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 07:11 PM

It can not.
You need to use:

linux16 grub.exe

It is reported as having worked on this Chinese website.

#7 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 07:14 PM

linux16 grub.exe

append --config-file="root (hd0,0);chainloader /ntldr"

I still don't quite follow. You can't load the MBR of the .VHD or don't want to?

I can't. I've tried but for some reason it does not work.

#8 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 07:35 PM

linux16 grub.exe

append --config-file="root (hd0,0);chainloader /ntldr"

I still don't quite follow. You can't load the MBR of the .VHD or don't want to?

The problem with your suggestion is that the vhd disk is loaded as block device vhd0 and grub4dos will not accept this as a root device - hence I can't access ntldr on the VHD from G4D. That's why I need to chainload NTLDR directly from Grub2. Thanks Shao.

#9 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 13 June 2010 - 07:39 PM

You can't map a loop device to an INT 13h HDD number in GRUB2, for later use by GRUB4DOS?

#10 maanu

maanu

    Gold Member

  • Advanced user
  • 1134 posts
  •  
    Pakistan

Posted 13 June 2010 - 08:08 PM

It can not.
You need to use:

linux16 grub.exe


is it because grub2 by default loaded as 32bit , but the grub.exe is 16bit so it downgrades itself ?

#11 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 13 June 2010 - 08:38 PM

It is reported as having worked on this Chinese website.

I don't see grub.exe anywhere on that page :) .

I can't. I've tried but for some reason it does not work.

grub2 doesn't use an append line (is Syslinux syntax). Try:
linux16 grub.exe --config-file="root (hd0,0);chainloader /ntldr"

is it because grub2 by default loaded as 32bit , but the grub.exe is 16bit so it downgrades itself ?

grub2 is runs 32 protected mode code (at least I think).
They had the 'great' idea to skip the 16 bit part of the linux kernel and just jump directly to the 32 bit part (to avoid switching from 32 bit protected mode, to 16 real mode, to go back to 32 protected mode). I recently heard, that they told the kernel developers, that they had to fix the kernel, because there hack didn't work anymore.

linux16 will use the old way of booting linux kernels (back to 16 bit real mode), like all sane boot loaders do. You need linux16 for every tool that looks like a linux kernel (some magic bytes), but that isn't a real linux kernel: like MEMDISK, plpbt.bin (PLoP bootloader), memtest64+.bin, grub.exe, ...

#12 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 13 June 2010 - 09:01 PM

You can't map a loop device to an INT 13h HDD number in GRUB2, for later use by GRUB4DOS?

AFAIK, grub2 doesn't use INT 13h mappings (probably because they support multiple architectures).
You have a loop device to which you can mount an image to read files from this image (read kernel and initrd from ISO)

I think supaJ is using this:
http://www.vmlite.co...the-xp-vhd-file?

They wrote a module for grub2 which can read and boot a vhd file.

#13 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 13 June 2010 - 09:02 PM

You can't map a loop device to an INT 13h HDD number in GRUB2, for later use by GRUB4DOS?

AFAIK, grub2 doesn't use INT 13h mappings (probably because they support multiple architectures).
You have a loop device to which you can mount an image to read files from this image (read kernel and initrd from ISO)

I think supaJ is using this:
http://www.vmlite.co...the-xp-vhd-file?

They wrote a module for grub2 which can read and boot a vhd file.

#14 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 09:02 PM

I don't see grub.exe anywhere on that page :) .

Sorry I wasn't talking about the grub.exe. I was talking about:

linux loadbin.bin
initrd ntldr

Can anybody here recreate loadbin.bin as per the Chinese website to work with grub2?

#15 Icecube

Icecube

    Gold Member

  • Team Reboot
  • 1062 posts
  •  
    Belgium

Posted 13 June 2010 - 09:04 PM

You can't map a loop device to an INT 13h HDD number in GRUB2, for later use by GRUB4DOS?

AFAIK, grub2 doesn't use INT 13h mappings (probably because they support multiple architectures).
You have a loop device to which you can mount an image to read files from this image (read kernel and initrd from ISO)

I think supaJ is using this:
http://www.vmlite.co...the-xp-vhd-file?

They wrote a module for grub2 which can read and boot a vhd file.

#16 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 09:06 PM

I think supaJ is using this:
http://www.vmlite.co...the-xp-vhd-file?

They wrote a module for grub2 which can read and boot a vhd file.

You are so right. How did you know that?

#17 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 13 June 2010 - 09:11 PM

I'm trying to do a VHD+Firadisk+Grub2 fix. Then I wouldn't have to worry about dis-contiguous files.

#18 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 14 June 2010 - 12:44 AM

If GRUB2 does not provide an INTerrupt 0x13 hook and a drive number, then it's not going to work. NTLDR itself requires INT 13h to read at least BOOT.INI and possibly NTBOOTDD.SYS, but quite commonly all of the other files, as well. If only you knew the range of sectors for the .VHD, you could simply tell GRUB4DOS to map a drive number to them.

You might be struggling with the block versus filesystem realm. GRUB2 might allow this loop-back insofar as layering the filesystem driver on top, but might not provide a raw block device service, which is what NTLDR and other boot-loaders (who don't use GRUB2's filesystem drivers) would require.

#19 supaJ

supaJ

    Member

  • Members
  • 51 posts
  •  
    Canada

Posted 14 June 2010 - 01:32 AM

If GRUB2 does not provide an INTerrupt 0x13 hook and a drive number, then it's not going to work. NTLDR itself requires INT 13h to read at least BOOT.INI and possibly NTBOOTDD.SYS, but quite commonly all of the other files, as well. If only you knew the range of sectors for the .VHD, you could simply tell GRUB4DOS to map a drive number to them.

You might be struggling with the block versus filesystem realm. GRUB2 might allow this loop-back insofar as layering the filesystem driver on top, but might not provide a raw block device service, which is what NTLDR and other boot-loaders (who don't use GRUB2's filesystem drivers) would require.

Wow! Now that's a mouthful. Thanks for the explanation. I guest it's back to the drawing board - to get G4D to boot a firadisk/winvblock based XP from a non-contiguous disk image.

At least I found a way to use grub2 to boot Linux based VHD's - contiguous or not.

#20 Sha0

Sha0

    WinVBlock Dev

  • Developer
  • 1682 posts
  • Location:reboot.pro Forums
  • Interests:Booting
  •  
    Canada

Posted 14 June 2010 - 02:12 AM

I've since confirmed with Jordan_U (whoever they may be, but seemed "with-it") in the #grub channel on Freenode's IRC network.

A huge advantage that Linux has over Windows is the whole rootfs, initramfs combination. Linux can be handed just what it needs by a boot-loader, then live in a tiny space for a while, then finally connect devices and populate files from other sources. With Windows, it's much harder to do something like:
  • Run in a tiny environment with just a handful of drivers
  • Mount other filesystems (such as inside a .VHD, in some filesystem, on some disk)
  • "Over-mount"/re-direct the tiny system volume with another, larger, intended-final volume
It's that third point that's sorely lacking. targetpractice's filesystem redirector could potentially help out there.

#21 memoarfaa

memoarfaa

    Member

  • Members
  • 81 posts
  •  
    Egypt

Posted 08 April 2015 - 12:52 AM

you can use ntldr.mod 

menuentry "boot grldr or ntldr " {
    insmod ntldr
    ntldr /grldr

}


or

 example boot Hiren's BootCD iso with grub2 loopback
menuentry "Hiren's BootCD iso withowt memdisk" {
    insmod iso9660
    insmod ntldr
    set iso_path="/Hiren's.BootCD.15.iso"
    loopback loop $iso_path
    ntldr (loop)/HBCD/grldr
    
}

but not work in uefi mode





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users