bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about using grub on disk image files (as opposed to discs)


From: Christoph Plattner
Subject: Re: Question about using grub on disk image files (as opposed to discs)
Date: Tue, 18 Dec 2001 12:32:55 +0100

Interesting topic !

I play armound with this, with the further problem to have a cross
build from Sparc (Solaris) to i386.

One quite simple way is, you create a stage1 + stage1_5 on a device of
your choise with an normal (online) install. The dd the MBR+nr_of_blocks
of stage1.5 into a file, let's call it bootldr.img.

Now you must know something about the geometry of the disk. Example:
4 heads, 20 sectors (only to have round values), 300 cylinders and
ofcourse every sector has 512 bytes.

The layout is: The MBR is in the frist sector on the first cylinder
on the first head. The rest of this track is kept empty and used
for the stage1.5. So the first partition starts at lba sector 20,
as 0..19 are reserved (MBR = stage1, stage1_5 13 to 16 sectors,
rest is padding). So you need a padding file, to have fullfill
the structure and you can create a disk image like

fdisk bootldr.img  to create partitions ...
cat bootldr.img padding.img part1.img part2.img ...  > fulldisk.img

Important, the 2nd, 3rd, etc.., partition then starts on 80 sector
boundaries, always on complete cylinders.

With giving the geometry to GRUB, it should also be possible to
use GRUB directly for installing itself on the diskimage, but
I have not tried it.

Another way I used for the cross setup is, writing a small tool
to produce `bootldr.img' offline out of stage1 and XXX_stage1_5
by patching some values (which normally does `install' in GRUB).
But the key here is to use stage1_5 !! The stage2 is not geometry-
dependent any more....

With friendly regards
Christoph P.


"John P. Looney" wrote:
> 
>  I'm trying to use grub to boot a flash image, which I'm making up as a
> normal file under linux, then creating partitions inside that file with
> fdisk, dding mkfs'd partitions into that file with offsets, then
> mounting
> those partitions, and populating them with an OS.
> 
>  It all works. Except for the last bit. Grub. I've tried, and failed to
> get "lilo" working. I was hoping grub would be easier. Only, I'm not
> quite
> sure how to go about it.
> 
>  It should be similar to a floppy - dd in the first & second stage
> loaders. Only it occured to me that where the docs for "making a grub
> floppy" show using dd to put the second stage loader in place with
> something like;
> 
> # dd if=stage2 of=/tmp/myflash.img bs=512 count=1 seek=1
> 
>  wouldn't that over write a partition table ? If so, where should I put
> the second stage loader ? Or, do I have to bite the bullet, and go in
> through the grub shell, and install the second stage loader into (say)
> the
> first partition, and have it tell the first stage loader where to find
> it ?
> 
>  The idea of this is to finish off a shell script that builds an OS from
> source, and generates a complete image, so I'd really like to avoid
> manual
> intervention if possible. Anyone got any ideas ?
> 
> John
> 
> --
> _______________________________________
> John Looney             Chief Scientist
> a n t e f a c t o     t: +353 1 8586004
> www.antefacto.com     f: +353 1 8586014

-- 
  +--------V--------+   address@hidden
  |  A L C A T E L  |   -----------------------------
  +-----------------+   Phone: +43 1 27722 3706 
         T A S          Fax:   +43 1 27722 3955



reply via email to

[Prev in Thread] Current Thread [Next in Thread]