install grub 2 to a disk image

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
mcheung63
Member
Member
Posts: 175
Joined: Thu Jun 22, 2006 8:33 am
Location: Hong Kong
Contact:

install grub 2 to a disk image

Post by mcheung63 »

Hi All, do you have any tutorial to install grub 2 (not legacy grub) to a disk image?
thanks
from Peter
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: install grub 2 to a disk image

Post by Combuster »

Google has one.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: install grub 2 to a disk image

Post by Brendan »

Hi,
mcheung63 wrote:Hi All, do you have any tutorial to install grub 2 (not legacy grub) to a disk image?
I honestly don't know (and google searches did not help me).

As far as I can tell, if you're not using Linux you're screwed, and if you are using Linux you're still screwed most of the time. The best option might be to use a Linux "Live" CD inside an emulator where the disk image looks like a real disk (and not a loopback device).

The thought of porting GRUB 2's installer to my "not a *nix clone" OS one day is enough to convince me that refusing to use GRUB 2 is the only sane approach in the long run. 8)


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: install grub 2 to a disk image

Post by egos »

It's easy to write a simple GRUB installer. But yeah you are right! Whether it is necessary?
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: install grub 2 to a disk image

Post by Combuster »

and google searches did not help me
Fourth hit on the first try. Complete with commands and background information and reasons not to do it.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Kazinsal
Member
Member
Posts: 559
Joined: Wed Jul 13, 2011 7:38 pm
Libera.chat IRC: Kazinsal
Location: Vancouver
Contact:

Re: install grub 2 to a disk image

Post by Kazinsal »

Use GRUB Legacy. From my experiments, I'm surprised that the FSF actually thinks GRUB2 is a brilliantly amazing bootloader and is the true successor to the good-enough GRUB Legacy. The automated grub.cfg generator creates absolutely massive config files, whereas a legacy menu.lst could boot Ubuntu with five or six lines (instead of a whopping 161!)

And then there's its hatred of installing to things that aren't physical hardware formatted in the way it wants, not the way you want. I'm considering writing an incredibly-cliche-titled short paper: "GRUB2 Considered Harmful".

And for the record, I still haven't found a pre-installed GRUB2 floppy image. Yet I know exactly where I could get GRUB Legacy images with a number of different filesystems...
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: install grub 2 to a disk image

Post by egos »

Search for "GrubOnFloppy-198" on this forum. I prefer Legacy GRUB too because it's compact and because I have no GRUB 2 packed into one file (or two files) that need for installation of GRUB 2 as my second stage boot loader by my setup tool (I can use modified GRUB as one of my second stage boot loaders).
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
mcheung63
Member
Member
Posts: 175
Joined: Thu Jun 22, 2006 8:33 am
Location: Hong Kong
Contact:

Re: install grub 2 to a disk image

Post by mcheung63 »

I can use grub legacy too, but just not grub 2
User avatar
mcheung63
Member
Member
Posts: 175
Joined: Thu Jun 22, 2006 8:33 am
Location: Hong Kong
Contact:

Re: install grub 2 to a disk image

Post by mcheung63 »

we have no way to specify a device for grub2-mkdevicemap command, so grub2 probably can't install to a disk image.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: install grub 2 to a disk image

Post by egos »

It will can be installed if I will find a tool to copy files into floppy image. I have fat_imgen for Windows now but it has no support for nested folders to put /boot/grub/*.* files into image.
If you have seen bad English in my words, tell me what's wrong, please.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: install grub 2 to a disk image

Post by Kevin »

Brendan wrote:As far as I can tell, if you're not using Linux you're screwed, and if you are using Linux you're still screwed most of the time.
I once managed to install a GRUB 2 from a tyndur VM and still keep the system booting. I don't remember the exact steps; it was a bit ugly in comparison to GRUB 1, but not impossible to figure out. Basically I built an image with grub-mkimage first and then used grub-bios-setup to actually install it to the image. I remember that one of the issues I had was convincing GRUB to take the right search path for its modules.

More on topic, this is the shell script we use on Linux to create tyndur hard disk images with GRUB 2.
Developer of tyndur - community OS of Lowlevel (German)
Post Reply