Jump to content











Photo
- - - - -

Making room for G4D MBR in a GPT setup?


  • Please log in to reply
7 replies to this topic

#1 nitro2k01

nitro2k01

    Newbie

  • Members
  • 10 posts
  •  
    Sweden

Posted 20 April 2014 - 02:47 PM

I'm currently trying to use a hybrid MBR setup and GRUB4DOS in a computer whose BIOS isn't GPT aware. The problem is that GPT want to put its first partition table in LBA 1, whereas G4D's MBR stage is 8 kiB big. So far I've tried converting a MBR type partition table to a hybrid partition table setup using gdisk. This produces a missing MBR helper upon boot, as expected since LBA 1+ is overwritten by the GPT partition table. Likewise, running bootlace on the drive complains about too few sectors being free.

 

Is there any way to coerce gdisk (or a different tool) into moving the GPT partition table forward, alternatively moving the G4D bootstrap somehow. The solution should in the end work reliably (ie partition table or bootstrap not destructively overwritten in normal use, and OS is able to detect the partitions) under OSX (Hackintosh), Windows 7 32-bit and Linux (Debian).

 

The general task of booting these operating systems (beyond initially getting into G4D) is not a problem and not part of the question.


Edited by nitro2k01, 20 April 2014 - 02:56 PM.


#2 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15108 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 20 April 2014 - 02:56 PM

NOT what you asked :ph34r:, but:

Wouldn't it be (much) easier to use a "normal" 1 sector only MBR and put the grub4dos loading code in a PBR/VBR?

 

:duff:

Wonko



#3 nitro2k01

nitro2k01

    Newbie

  • Members
  • 10 posts
  •  
    Sweden

Posted 20 April 2014 - 03:04 PM

It would. But despite having played around with boot stuff for as long as I remember, I don't know of a good way of getting such a bootstrap into the MBR. The closest I can think of is maybe using DOS/Windows and hoping that fixmbr or similar will do the trick and not mess up anything else.



#4 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15108 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 20 April 2014 - 03:20 PM

It would. But despite having played around with boot stuff for as long as I remember, I don't know of a good way of getting such a bootstrap into the MBR. The closest I can think of is maybe using DOS/Windows and hoping that fixmbr or similar will do the trick and not mess up anything else.

I don't understand, maybe we are talking of different things. :unsure:

 

A "normal" booting sequence (take aside for one moment the GPT and Hybrid) is:

  • BIOS reads first sector of the hard disk (the MBR)
  • the MBR code reads the (embedded in the same MBR) partition table and chainloads the PBR/VBR of the partition marked as active
  • the code in the PBR/VBR loads the *whatever* System file/bootmanager/OS loader

Grub4dos is very often installed (and I personally always "objected" to it BTW) in the MBR+hidden sectors, thus the booting sequence is:

 

  • BIOS reads first sector of the hard disk (the MBR) <- this is grldr.mbr, using the MBR+hidden sectors
  • the MBR grub4dos code reads the rest of the code in the MBR+hidden sectors and looks for grldr in any of the available partitions
  • once the first instance of grldr is found, it is chainloaded

But what I commonly use (and historically recommend, personally, exactly to avoid having *any* of the hidden sectors used to avoid possible conflicts) is to have:

  • BIOS reads first sector of the hard disk (the MBR) <- this is *any* "normal" MBR
  • the MBR code reads the (embedded in the same MBR) partition table and chainloads the PBR/VBR of the partition marked as active
  • the code in the PBR/VBR loads the grldr in the active partition

Just as an example, I have a few systems where the BIOS won't boot form a USB stick using grub4dos grldr.mbr, and I use the "plain" MBR code coming with Syslinux to chainload the active partition, and the code in the bootsector of that partition loads grldr.

 

:duff:

Wonko



#5 nitro2k01

nitro2k01

    Newbie

  • Members
  • 10 posts
  •  
    Sweden

Posted 20 April 2014 - 03:25 PM

Indeed. My task now become putting a chainloader of some kind in the MBR, which loads code from the VBR of a partition, and runs it. This is where I'm lost atm. My MBR now contains (the first piece of) grub4dos's first stage in the MBR, which is no good. How do I get a suitable VBR chainloader into the MBR?



#6 steve6375

steve6375

    Platinum Member

  • Developer
  • 7107 posts
  • Location:UK
  • Interests:computers, programming (masm,vb6,C,vbs), photography,TV,films,guitars, www.easy2boot.com
  •  
    United Kingdom

Posted 20 April 2014 - 04:34 PM

Could you explain what you are trying to do and why.

 

If a computer is not GPT aware then why do you want to use GPT?

Presumably it is not UEFI aware either?

Doesn't Windows have to boot via UEFI in order to recognise GPT disks (?unsure?) or are you booting to linux?

 

The problem is that the space in the MBR is not enough for code to go searching partitions for the 2nd stage loader.

It would help a lot of you could explain some more about what and why you need this.



#7 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 15108 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 20 April 2014 - 05:28 PM

Indeed. My task now become putting a chainloader of some kind in the MBR, which loads code from the VBR of a partition, and runs it. This is where I'm lost atm. My MBR now contains (the first piece of) grub4dos's first stage in the MBR, which is no good. How do I get a suitable VBR chainloader into the MBR?

You can use the "default" Windows MBR, or, as said the one that comes as an example/support file with Syslinux, or the good ol' MBLDR:

http://reboot.pro/to...is-named-mbldr/

http://sourceforge.n...ts/mbldr/files/

which has (still in the "original" 512 bytes) the ability to switch the active partition.

 

:duff:

Wonko



#8 milindsmart

milindsmart

    Frequent Member

  • Advanced user
  • 201 posts
  • Location:Bangalore
  •  
    India

Posted 06 August 2014 - 03:41 PM

I'm currently trying to use a hybrid MBR setup and GRUB4DOS in a computer whose BIOS isn't GPT aware.


If a computer is not GPT aware then why do you want to use GPT?
Presumably it is not UEFI aware either?


(PC/AT,PC98) BIOSes aren't actually ANY disk partitioning system aware. Some overzealous BIOSes try to ensure that one partition is marked active, but this is usually the exception rather than the norm. For the most part, they just run the MBR. That's where it's responsibility ends.

A computer has either BIOS-style firmware interface or UEFI.
 

Doesn't Windows have to boot via UEFI in order to recognise GPT disks (?unsure?) or are you booting to linux?

While Microsoft does say that Windows has to boot via UEFI to boot from GPT disks, this thread on this very forum shows otherwise.
 

Is there any way to coerce gdisk (or a different tool) into moving the GPT partition table forward, alternatively moving the G4D bootstrap somehow.

While I think Wonko the Sane's method is far better, it is interesting to note that the flexibility of the GPT partitioning system, and the detail stored in the GPT header makes this possibility not exactly impossible. You could move the GPT header to some sectors ahead, and update the field that indicate the header position. You would (mostly) also have to push forward the GPT partition table itself. And update the checksum.

But the point might be moot, because I think testing for "EFI PART" in LBA 1 is the definitive test for determining if a disk is GPT-partitioned. Maybe I'll try it and find out.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users