All of lore.kernel.org
 help / color / mirror / Atom feed
* Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
@ 2010-01-28  3:37 Wesley Smith
  2010-01-28 11:45 ` Colin Watson
  0 siblings, 1 reply; 11+ messages in thread
From: Wesley Smith @ 2010-01-28  3:37 UTC (permalink / raw)
  To: grub-devel

I am sorry to bother you, but reading the docs has not helped, and Googling has
turned up only other people suffering from the same problem, but not the
solution to it.

I have a multiboot system that I would like to use Grub to manage. The version
of Grub shipping with my Linux distro is Grub2, and it installs its equivalent
of core.img into the remaining sectors on the first track after the MBR but
before the first partition. Unfortunately, those sectors are needed by another
program.

I have a separate primary /boot partition, with the rest of my Linux distro
stored in an LVM. If I could only keep boot.img as my MBR but have it look in
the /boot partition for core.img rather than having it read an embedded one from
the sectors immediately following the MBR, everything would work fine. Is this
possible with Grub2?





^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-28  3:37 Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img? Wesley Smith
@ 2010-01-28 11:45 ` Colin Watson
  2010-01-28 14:11   ` edgar.soldin
  2010-01-29  5:43   ` Wesley Smith
  0 siblings, 2 replies; 11+ messages in thread
From: Colin Watson @ 2010-01-28 11:45 UTC (permalink / raw)
  To: The development of GNU GRUB

On Thu, Jan 28, 2010 at 03:37:44AM +0000, Wesley Smith wrote:
> I am sorry to bother you, but reading the docs has not helped, and Googling has
> turned up only other people suffering from the same problem, but not the
> solution to it.
> 
> I have a multiboot system that I would like to use Grub to manage. The version
> of Grub shipping with my Linux distro is Grub2, and it installs its equivalent
> of core.img into the remaining sectors on the first track after the MBR but
> before the first partition. Unfortunately, those sectors are needed by another
> program.
> 
> I have a separate primary /boot partition, with the rest of my Linux distro
> stored in an LVM. If I could only keep boot.img as my MBR but have it look in
> the /boot partition for core.img rather than having it read an embedded one from
> the sectors immediately following the MBR, everything would work fine. Is this
> possible with Grub2?

Yes, you can do this by using 'grub-install /dev/sda1' (or whatever the
device name for your /boot partition is).

Note that this setup typically requires the use of blocklists, which are
inherently unreliable.  For example, you may find that you need to
re-run grub-install after certain filesystem operations; see the "And
blocklists?" section of http://grub.enbug.org/BIOS_Boot_Partition for a
description of the problem.  This problem was present in GRUB Legacy as
well, although it did not warn about it.

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-28 11:45 ` Colin Watson
@ 2010-01-28 14:11   ` edgar.soldin
  2010-01-28 14:55     ` Colin Watson
  2010-01-29  5:43   ` Wesley Smith
  1 sibling, 1 reply; 11+ messages in thread
From: edgar.soldin @ 2010-01-28 14:11 UTC (permalink / raw)
  To: The development of GNU GRUB

I had also problems to install grub2 to a partition boot record. It 
complained and wouldn't do it. But it was necessary, because the laptop 
bios I wanted to boot the usb stick, did actually ignore the mbr but 
insisted on starting the partition boot record.

I compiled a g2ldr and used the latest grubinst-1.1-bin-w32-2008-01-01 
to install grub into mbr and the partitions boot record using the grub2 
flag. This worked only when g2ldr was present on the root of the 
partitions fat32 fs.

Can anybody explain the difference of this approach and why it works?

thanks ede



On 28.01.2010 12:45, Colin Watson wrote:
> On Thu, Jan 28, 2010 at 03:37:44AM +0000, Wesley Smith wrote:
>> I am sorry to bother you, but reading the docs has not helped, and Googling has
>> turned up only other people suffering from the same problem, but not the
>> solution to it.
>>
>> I have a multiboot system that I would like to use Grub to manage. The version
>> of Grub shipping with my Linux distro is Grub2, and it installs its equivalent
>> of core.img into the remaining sectors on the first track after the MBR but
>> before the first partition. Unfortunately, those sectors are needed by another
>> program.
>>
>> I have a separate primary /boot partition, with the rest of my Linux distro
>> stored in an LVM. If I could only keep boot.img as my MBR but have it look in
>> the /boot partition for core.img rather than having it read an embedded one from
>> the sectors immediately following the MBR, everything would work fine. Is this
>> possible with Grub2?
>
> Yes, you can do this by using 'grub-install /dev/sda1' (or whatever the
> device name for your /boot partition is).
>
> Note that this setup typically requires the use of blocklists, which are
> inherently unreliable.  For example, you may find that you need to
> re-run grub-install after certain filesystem operations; see the "And
> blocklists?" section of http://grub.enbug.org/BIOS_Boot_Partition for a
> description of the problem.  This problem was present in GRUB Legacy as
> well, although it did not warn about it.
>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-28 14:11   ` edgar.soldin
@ 2010-01-28 14:55     ` Colin Watson
  2010-01-28 16:39       ` edgar.soldin
  0 siblings, 1 reply; 11+ messages in thread
From: Colin Watson @ 2010-01-28 14:55 UTC (permalink / raw)
  To: The development of GNU GRUB

On Thu, Jan 28, 2010 at 03:11:35PM +0100, edgar.soldin@web.de wrote:
> I had also problems to install grub2 to a partition boot record. It  
> complained and wouldn't do it.

Did you try using grub-install --force?

-- 
Colin Watson                                       [cjwatson@ubuntu.com]



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-28 14:55     ` Colin Watson
@ 2010-01-28 16:39       ` edgar.soldin
       [not found]         ` <ca0f59981001280857p5f581035n4cd8519efda30e8@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: edgar.soldin @ 2010-01-28 16:39 UTC (permalink / raw)
  To: The development of GNU GRUB

I am pretty sure. If you want I am willing to retry.

Still I wonder what is the deifference to the grubinst/g2ldr approach 
and why the boot code can find g2ldr. Can it read fat fs?

.. ede

On 28.01.2010 15:55, Colin Watson wrote:
> On Thu, Jan 28, 2010 at 03:11:35PM +0100, edgar.soldin@web.de wrote:
>> I had also problems to install grub2 to a partition boot record. It
>> complained and wouldn't do it.
>
> Did you try using grub-install --force?
>



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
       [not found]         ` <ca0f59981001280857p5f581035n4cd8519efda30e8@mail.gmail.com>
@ 2010-01-28 17:15           ` edgar.soldin
       [not found]             ` <ca0f59981001280936o4457ff96wc95dad6f238ff461@mail.gmail.com>
  0 siblings, 1 reply; 11+ messages in thread
From: edgar.soldin @ 2010-01-28 17:15 UTC (permalink / raw)
  To: Bean, The development of GNU GRUB

So grubinst bootcode seems superior over grub2 bootcode regarding 
partitions?

ede

On 28.01.2010 17:57, Bean wrote:
> On Fri, Jan 29, 2010 at 12:39 AM,<edgar.soldin@web.de>  wrote:
>    
>> I am pretty sure. If you want I am willing to retry.
>>
>> Still I wonder what is the deifference to the grubinst/g2ldr approach and
>> why the boot code can find g2ldr. Can it read fat fs?
>>      
> Hi,
>
> Yeah, grubinst contains its own fs reader, it's all written in
> assembly, 1 sector fat + 1 sector ext2 + 4 sector ntfs plus other
> utilities. The whole size is about 8K.
>
>
>    




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
       [not found]             ` <ca0f59981001280936o4457ff96wc95dad6f238ff461@mail.gmail.com>
@ 2010-01-28 17:41               ` edgar.soldin
  0 siblings, 0 replies; 11+ messages in thread
From: edgar.soldin @ 2010-01-28 17:41 UTC (permalink / raw)
  To: Bean, The development of GNU GRUB

Any reason why you keep this of list?

Well, in case of boot code size does matter as boot records are limited 
in size. Or? .. ede

On 28.01.2010 18:36, Bean wrote:
> On Fri, Jan 29, 2010 at 1:15 AM,<edgar.soldin@web.de>  wrote:
>    
>> So grubinst bootcode seems superior over grub2 bootcode regarding
>> partitions?
>>      
> Hi,
>
> Actually they both have advantages. Assembly is hard to write and
> maintain, but much smaller, C is larger but portable. In cases where
> size is not a matter, it's better to use C code.
>
>    




^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-28 11:45 ` Colin Watson
  2010-01-28 14:11   ` edgar.soldin
@ 2010-01-29  5:43   ` Wesley Smith
  2010-01-29  6:19     ` Bruce Dubbs
  2010-01-29  9:48     ` Grégoire Sutre
  1 sibling, 2 replies; 11+ messages in thread
From: Wesley Smith @ 2010-01-29  5:43 UTC (permalink / raw)
  To: grub-devel

Colin Watson <cjwatson <at> ubuntu.com> writes:

> ...
> Yes, you can do this by using 'grub-install /dev/sda1' (or whatever the
> device name for your /boot partition is).

Thanks for your help, but no, it appears you cannot do this by simply using
"grub-install /dev/sdx". I tried this, and yes, it did make the target
partition bootable (it contained a Grub loader in its PBR). However, to ensure
the disk MBR had also been updated and was now getting its core.img file from
the /boot partition and not from the sectors immediately following it, I built
a dummy track containing just the MBR post-"grub-install" and nothing but zeros
after, and then I copied it to /dev/sda:

dd if=/dev/zero of=/track.image bs=512 count=63
dd if=/dev/sda of=/track.image bs=512 count=1 conv=notrunc
dd if=/track.image of=/dev/sda bs=512 count=63

If the MBR no longer needs the embedded core.img, then it being replaced with
empty sectors shouldn't bother Grub the slightest. Unfortunately, upon reboot I
was greeted only with the word "GRUB" and a blinking cursor, which I took to
mean it couldn't find core.img and was unable to proceed.

It would be nice if Grub2 could both make a partition bootable and also install
an MBR that relied on that partition (rather than the embedded core.img). I
know this is "dangerous," but it is necessary sometimes, and it was not at all
difficult to accomplish with legacy Grub.

> Note that this setup typically requires the use of blocklists, which are
> inherently unreliable.  For example, you may find that you need to
> re-run grub-install after certain filesystem operations; see the "And
> blocklists?" section of http://grub.enbug.org/BIOS_Boot_Partition for a
> description of the problem.  This problem was present in GRUB Legacy as
> well, although it did not warn about it.
> 






^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-29  5:43   ` Wesley Smith
@ 2010-01-29  6:19     ` Bruce Dubbs
  2010-01-29  9:54       ` Wesley Smith
  2010-01-29  9:48     ` Grégoire Sutre
  1 sibling, 1 reply; 11+ messages in thread
From: Bruce Dubbs @ 2010-01-29  6:19 UTC (permalink / raw)
  To: The development of GNU GRUB

Wesley Smith wrote:

> It would be nice if Grub2 could both make a partition bootable and also install
> an MBR that relied on that partition (rather than the embedded core.img). I
> know this is "dangerous," but it is necessary sometimes, and it was not at all
> difficult to accomplish with legacy Grub.

I'm not a core GRUB developer, but how would you do it?  Let's see, you 
have 512 bytes minus some space for the partition table.  You want to 
access the file system in the space.  Lets see, is that fat, ext, 
reiser, jfs, xfs, ntfs, lvm, raid, or something else?  Do you want a 
splash screen with that?  Somebody will.  Are you booting over a serial 
line? A network card?  Do you want that for linux, one of the bsd's, 
windows, solaris, or beos?  Is that for intel, sparc, or powerpc?

Remember, you have about 448 bytes...

   -- Bruce



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-29  5:43   ` Wesley Smith
  2010-01-29  6:19     ` Bruce Dubbs
@ 2010-01-29  9:48     ` Grégoire Sutre
  1 sibling, 0 replies; 11+ messages in thread
From: Grégoire Sutre @ 2010-01-29  9:48 UTC (permalink / raw)
  To: The development of GNU GRUB

Wesley Smith wrote:

> Thanks for your help, but no, it appears you cannot do this by simply using
> "grub-install /dev/sdx". I tried this, and yes, it did make the target
> partition bootable (it contained a Grub loader in its PBR). However, to ensure
> the disk MBR had also been updated and was now getting its core.img file from
> the /boot partition and not from the sectors immediately following it, I built
> a dummy track containing just the MBR post-"grub-install" and nothing but zeros
> after, and then I copied it to /dev/sda:
> 
> dd if=/dev/zero of=/track.image bs=512 count=63
> dd if=/dev/sda of=/track.image bs=512 count=1 conv=notrunc
> dd if=/track.image of=/dev/sda bs=512 count=63

I believe that you should replace the GRUB MBR code with an ``MS-DOS 
like'' MBR that looks for the first active partition and boots it.  Here 
you keep the old GRUB MBR code that will try to load core.img from the 
first track.

I guess that you can get such an MBR boot code from many places (I 
personally use the NetBSD boot selector) and then you simply:

dd if=<the mbr boot code> of=/dev/sda bs=446 count=1

Well, I'm no expert, but that always worked for me.

Grégoire



^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img?
  2010-01-29  6:19     ` Bruce Dubbs
@ 2010-01-29  9:54       ` Wesley Smith
  0 siblings, 0 replies; 11+ messages in thread
From: Wesley Smith @ 2010-01-29  9:54 UTC (permalink / raw)
  To: grub-devel

Bruce Dubbs <bruce.dubbs <at> gmail.com> writes:

> ...
> I'm not a core GRUB developer, but how would you do it?  Let's see, you 
> have 512 bytes minus some space for the partition table.  You want to 
> access the file system in the space.  Lets see, is that fat, ext, 
> reiser, jfs, xfs, ntfs, lvm, raid, or something else?  Do you want a 
> splash screen with that?  Somebody will.  Are you booting over a serial 
> line? A network card?  Do you want that for linux, one of the bsd's, 
> windows, solaris, or beos?  Is that for intel, sparc, or powerpc?

Yes, I think I see your point, Bruce, but I am still not convinced that what I
am describing is infeasible. If you can create a bootable partition with a PBR
that knows how to find and assemble its core.img from the same partition, you
could conceivably create an MBR that just loads and hands off control to that
partition's PBR.

Anyway, I have a solution now that is close enough and still indirectly lets me
use Grub2, so I guess I am satisfied.

Thank you to all who replied.


> Remember, you have about 448 bytes...
> 
>    -- Bruce
> 







^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-01-29  9:54 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-28  3:37 Is it possible to have grub2's boot.img as my MBR, but have it look in a separate partition for core.img? Wesley Smith
2010-01-28 11:45 ` Colin Watson
2010-01-28 14:11   ` edgar.soldin
2010-01-28 14:55     ` Colin Watson
2010-01-28 16:39       ` edgar.soldin
     [not found]         ` <ca0f59981001280857p5f581035n4cd8519efda30e8@mail.gmail.com>
2010-01-28 17:15           ` edgar.soldin
     [not found]             ` <ca0f59981001280936o4457ff96wc95dad6f238ff461@mail.gmail.com>
2010-01-28 17:41               ` edgar.soldin
2010-01-29  5:43   ` Wesley Smith
2010-01-29  6:19     ` Bruce Dubbs
2010-01-29  9:54       ` Wesley Smith
2010-01-29  9:48     ` Grégoire Sutre

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.