help-grub
[Top][All Lists]
Advanced

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

Re: creating bootable image with a script


From: Michael Evans
Subject: Re: creating bootable image with a script
Date: Thu, 28 Jan 2010 20:39:24 -0800

On Wed, Jan 27, 2010 at 3:16 AM, Kevin Hunter <address@hidden> wrote:
> At 11:43pm -0500 Tue, 26 Jan 2010, Michael Evans wrote:
>> On Tue, Jan 26, 2010 at 2:36 PM, Kevin Hunter wrote:
>>> Goal 1: create a bootable disk image with a GPT partition label.
>>>
>>> Goal 1 is what is giving me trouble.
>
>>> http://cs.earlham.edu/~kevin/tmp/make_bootable_img.sh
>
>> This is how I'd do it, without looking at your script.
>>
>> 1) Identify the block device that backs the storage media. (Drop
>> any partition info, you need the base device to describe the map
>> file)
>> 2) Generate a device.map file that describes the external
>> media as hd0 (which is what it will be when you boot off it).
>> 3) Setup grub as normal on that device, using the device.map file
>> to inform it where things will be during startup.
>
> I think I understand that.  Those are the exact steps that I've
> identified for myself as well and have been trying to do off and on over
> the past month (spare time is hard to come by!).  It's the mechanics of
> such with which I need help.  I've spent a good deal of time with
> apparently the wrong the magic incantations.
>
> If someone wouldn't mind taking a look at the script, I think it'd make
> it clear where my trouble is.  It takes about 5 seconds to run on my
> machine, and I've tried to help it highlight exactly what I'm missing.
>
> Thank you,
>
> Kevin
>

1) I suspect you already know this, but only the first line of the
file, if it has #! will be interpreted as the script parser; the other
#! will be ignored as a comment.

2) Instead of   dd if=/dev/zero of="$IMG_FILE" bs=1M count="$SIZE"
look up 'truncate'; it should be part of coreutils.
sys-apps/coreutils-8.4 (/usr/bin/truncate) on any /linux/ system.  I
don't know if BSD or other *nix variants have it.

3) I don't think grub (or even most operators trying to guess) can
deduce the relationship between your drive image and your loopback
mounts.  Loopback the entire device, tell grub what that device
relates to with a device.map file.

4) ext4; I am not sure if grub knows how to parse this for data yet
(it doesn't really matter what the file system is for the initial
stage files as those are resolved to block-references at install time;
but your initrd/initramfs and kernel must be on a filesystem grub can
parse).

You can do 3 with this (
http://www.gnu.org/software/grub/manual/html_node/Device-map.html )
and a line like:

(hd0) /dev/loopX

Don't forget to provide that information to grub via whatever means it
expects when you invoke it.




reply via email to

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