help-grub
[Top][All Lists]
Advanced

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

Re: Embedding a file into core.img


From: Andrey Borzenkov
Subject: Re: Embedding a file into core.img
Date: Thu, 21 Mar 2013 19:20:30 +0400

В Thu, 21 Mar 2013 11:17:22 +0100
"Arbiel (gmx)" <address@hidden> пишет:

> Hi
> 
> Thank you Andrey, for your help.
> 
> I'm going to drop the idea, and return to a simplier way of doing : 
> define two partitions, the first one being Windows compatible, and a 
> little second one for the grub and GNU/Linux directories and files. I'll 
> write a regular grub.cfg file to look for the "cielos" partition.
> 

You do not really need second Linux partition, grub should be able to
read both FAT and NTFS. The only thing I'm not sure about is line end -
it may need Unix text file.

> A question remains : will searching for an absent partition lead to a 
> "no such device" message, or, in case the search does not return any 
> value in $root, will I be able to chainload hd0, or better, to return to 
> BIOS (UEFI ?) to have it look for the next bootable device ?
> 

Grub has "exit" command. On BIOS it attempts to tell BIOS that boot
failed, otherwise reboots. On UEFI it unfortunately always returns
GRUB_EFI_SUCCESS which means - go to boot menu. It should return
failure for UEFI bootmanager to try next choice. Patch is likely
possible to extend "exit" command to accept exit code. 

> Arbiel
> 
> Le 21/03/2013 06:38, Andrey Borzenkov a écrit :
> > On Wed, Mar 20, 2013 at 11:36 PM, Arbiel (gmx)
> > <address@hidden> wrote:
> >> In fact, this is a first try. My goal is to look for a partition name, and
> >> not a UUID. And when the partition has been found, I will boot immediately,
> >> without any user action. The USB keys are to be "regular" NTFS or FAT keys,
> >> without any track of Linux
> >>
> >
> > If you intended to implement it using embedded config, much more
> > easier is to make normal grub install on USB stick and implement it in
> > grub.cfg. Do not forget that embedded config runs very early in
> > restricted environment (basically, in rescue mode) when very limited
> > scripting capabilities and only subset of grub features are available.
> > You need to enter normal mode before you can do anything useful here.
> >
> >>
> >> Where can I find reliable information ?
> >>
> >
> > Supported way to install grub is to use grub-install. grub-mkimage,
> > embedded config, modules available etc are internal implementation
> > details that can change from version to version and platform to
> > platform. If you want to use them directly you probably need to follow
> > grub development or read sources. But in your case you simply do not
> > need it. grub-install + suitable grub.cfg is enough and makes changing
> > configuration also easier.
> >
> >>
> >> Le 20/03/2013 18:40, Andrey Borzenkov a écrit :
> >>
> >>> В Wed, 20 Mar 2013 10:34:46 +0100
> >>> "Arbiel (gmx)" <address@hidden> пишет:
> >>>
> >>>> Hi
> >>>>
> >>>> I try to record in the MBR of USB keys an autonomous MBR (no support of
> >>>> any other directory or file) to boot a PC with the system located on a
> >>>> partition whose name is predefined "cielos", and in case this fails, to
> >>>> chainload to the hd0's MBR.
> >>>>
> >>>> I've understood from Grub's Manual that to achieve such a goal, I have
> >>>> to embed the file using option -c of grub-mkimage.
> >>>>
> >>>> I have now modified the --grub-mkimage option to point to the shell
> >>>> script which creates /media/maisonnette/grub/core.img and from there I
> >>>> have been able to imbed the file and launch a boot process. However,
> >>>> this process failed, with a "no such device : the uuid I used in my
> >>>> search.fs_uuid command" whereas such a device exists on my external
> >>>> device
> >>>>
> >>>
> >>> You need to include much more of grub modules than you did. At least
> >>> you need disk driver and filesystem driver to read UUID.
> >>>
> >>> grub-install creates exactly the same embedded config. Why do not you
> >>> simply use it?
> >>>
> >>>> The imbedded file reads
> >>>>
> >>>> search.fs_uuid 0aceef09-a694-4105-bade-2dca95a09a08 root
> >>>> set prefix=(root)/boot/grub
> >>>>
> >>>> and a sudo blkid | grep 0aceef09-a694-4105-bade-2dca95a09a08 responds
> >>>>
> >>>> /dev/sdb5: LABEL="cielos" UUID="0aceef09-a694-4105-bade-2dca95a09a08"
> >>>> TYPE="ext4"
> >>>>
> >>>> I try to understand why the search fails.
> >>>>
> >>>> Le 20/03/2013 04:18, Andrey Borzenkov a écrit :
> >>>>>
> >>>>> В Wed, 20 Mar 2013 00:15:07 +0100
> >>>>> "Arbiel (gmx)" <address@hidden> пишет:
> >>>>>
> >>>>>> Hi
> >>>>>>
> >>>>>> I'm trying to embed a file into core.img. I followed instructions from
> >>>>>> GNU Grub Manual's 5.4 Embedding a configuration file into Grub and
> >>>>>> tried
> >>>>>> to replicate the example given there with a config file figuring two
> >>>>>> lines
> >>>>>>
> >>>>>>          search.fs_uuid the_uuid_of_my_partition root
> >>>>>>          set prefix=($root)/boot/grub
> >>>>>>
> >>>>>>
> >>>>>> I used the following commands
> >>>>>>
> >>>>>> #! /bin/bash
> >>>>>> cd "${1}"
> >>>>>> cat 1> grub/embed.cfg <<EOF
> >>>>>> search.fs_uuid 0aceef09-a694-4105-bade-2dca95a09a08 root
> >>>>>> set prefix=($root)/boot/grub
> >>>>>> EOF
> >>>>>> sudo grub-mkimage -c 'grub/embed.cfg' -o 'grub/grub-image' -O i386-pc
> >>>>>> -d
> >>>>>> '/usr/lib/grub/i386-pc' -C none search_fs_uuid
> >>>>>
> >>>>>
> >>>>> -O and -d together are redundant.
> >>>>>
> >>>>>> sudo chmod +x 'grub/grub-image'
> >>>>>> sudo grub-install --boot-directory=/media/maisonnette
> >>>>>> --grub-mkimage=grub/grub-image /dev/sdb 2>grub/msg.log
> >>>>>>
> >>>>>
> >>>>> --grub-mkimage points to program to create image, not to image itself.
> >>>>>
> >>>>> You do not explain what you attempt to achieve. May be using grub-rescue
> >>>>> to build ISO image that includes full grub and can optionally include
> >>>>> arbitrary files would be easier?
> >>>>>
> >>>>>> I get the following error message
> >>>>>>
> >>>>>> grub/grub-image: 1: grub/grub-image: Syntax error: word unexpected
> >>>>>> (expecting ")")
> >>>>>>
> >>>>>> Can anybody tell me what's wrong, knowing that my partition
> >>>>>> /media/maisonnette has nothing to do with the
> >>>>>> 0aceef09-a694-4105-bade-2dca95a09a08 partition.
> >>>>>>
> >>>>>> Thank you
> >>>>>>
> >>>>>> I used the following command
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> _______________________________________________
> >>>>>> Help-grub mailing list
> >>>>>> address@hidden
> >>>>>> https://lists.gnu.org/mailman/listinfo/help-grub
> >>>>>
> >>>>>
> >>>
> >>




reply via email to

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