All of lore.kernel.org
 help / color / mirror / Atom feed
* Search command.
@ 2009-03-11  0:34 Centurion Computer Technology (2005) Ltd
  2009-03-11  4:04 ` Pavel Roskin
  0 siblings, 1 reply; 9+ messages in thread
From: Centurion Computer Technology (2005) Ltd @ 2009-03-11  0:34 UTC (permalink / raw)
  To: The development of GRUB 2

Hi,

I am playing with the search command in grub2 from debian experimental
and have noticed some oddness

The search command currently returns the device as hdX,X rather than
(hdX,X).  This means that the variable created using -s can't be used as
a replacement for the device string.  For Example I'd like to be able to
do this:

# Set our root device
search -f /grub/grub.cfg -s root
# Set our prefix 
set prefix=${root}/grub/  # I think broken variable handling means this
doesn't work.

menuentry "My Linux OS" {
search -s LINUX_ROOT -u XXXX-YYYY-ZZZZ-AAAA-BBBB
set root=$LINUX_ROOT
linux=/vmlinuz
initrd=/intrd.img
}

Or do I completely misunderstand the search command and usage of
variables?






 


-- 
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722




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

* Re: Search command.
  2009-03-11  0:34 Search command Centurion Computer Technology (2005) Ltd
@ 2009-03-11  4:04 ` Pavel Roskin
  2009-03-11 23:52   ` Centurion Computer Technology (2005) Ltd
  0 siblings, 1 reply; 9+ messages in thread
From: Pavel Roskin @ 2009-03-11  4:04 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005)
Ltd wrote:
> Hi,
> 
> I am playing with the search command in grub2 from debian experimental
> and have noticed some oddness
> 
> The search command currently returns the device as hdX,X rather than
> (hdX,X).  This means that the variable created using -s can't be used as
> a replacement for the device string.

Actually, you can assign it to the root variable and use relative path.
You don't need parentheses in the root variable.

>   For Example I'd like to be able to
> do this:
> 
> # Set our root device
> search -f /grub/grub.cfg -s root
> # Set our prefix 
> set prefix=${root}/grub/  # I think broken variable handling means this
> doesn't work.

True.  Variable expansion is broken.  But you can use

set prefix=/grub/

That would allow you to load more modules as long as $root is unchanged.

> menuentry "My Linux OS" {
> search -s LINUX_ROOT -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> set root=$LINUX_ROOT

This is broken for the same reason.  But this would work:

search -s root -u XXXX-YYYY-ZZZZ-AAAA-BBBB

> Or do I completely misunderstand the search command and usage of
> variables?

You understand it correctly.  But the implementation is limited.

-- 
Regards,
Pavel Roskin



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

* Re: Search command.
  2009-03-11  4:04 ` Pavel Roskin
@ 2009-03-11 23:52   ` Centurion Computer Technology (2005) Ltd
  2009-03-12  0:12     ` Centurion Computer Technology (2005) Ltd
  2009-03-12  3:16     ` Pavel Roskin
  0 siblings, 2 replies; 9+ messages in thread
From: Centurion Computer Technology (2005) Ltd @ 2009-03-11 23:52 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, 2009-03-11 at 00:04 -0400, Pavel Roskin wrote:
> On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005)
> Ltd wrote:
> > Hi,
> > 
> > I am playing with the search command in grub2 from debian experimental
> > and have noticed some oddness
> > 
> > The search command currently returns the device as hdX,X rather than
> > (hdX,X).  This means that the variable created using -s can't be used as
> > a replacement for the device string.
> 
> Actually, you can assign it to the root variable and use relative path.
> You don't need parentheses in the root variable.
> 
> >   For Example I'd like to be able to
> > do this:
> > 
> > # Set our root device
> > search -f /grub/grub.cfg -s root
> > # Set our prefix 
> > set prefix=${root}/grub/  # I think broken variable handling means this
> > doesn't work.
> 
> True.  Variable expansion is broken.  But you can use
> 
> set prefix=/grub/
but this means as soon as root is set to the new device, that we can't
load anymore modules which breaks chainloader, linux, intrd, boot etc

and it appears preloading boot doesn't work anyway, as it tries to find
it.  This problem doesn't occur if I manually set prefix=(hdX,X)/grub
> 
> That would allow you to load more modules as long as $root is
> unchanged.
> 
> > menuentry "My Linux OS" {
> > search -s LINUX_ROOT -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> > set root=$LINUX_ROOT
> 
> This is broken for the same reason.  But this would work:
> 
> search -s root -u XXXX-YYYY-ZZZZ-AAAA-BBBB
Nope, as above, because we cannot set Prefix to include the device
programmatically, as soon as you've changed your root, you can no longer
load modules or use commands.

-- 
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722




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

* Re: Search command.
  2009-03-11 23:52   ` Centurion Computer Technology (2005) Ltd
@ 2009-03-12  0:12     ` Centurion Computer Technology (2005) Ltd
  2009-03-12  0:51       ` phcoder
  2009-03-12  3:16     ` Pavel Roskin
  1 sibling, 1 reply; 9+ messages in thread
From: Centurion Computer Technology (2005) Ltd @ 2009-03-12  0:12 UTC (permalink / raw)
  To: The development of GRUB 2

On Thu, 2009-03-12 at 12:52 +1300, Centurion Computer Technology (2005)
Ltd wrote:
> On Wed, 2009-03-11 at 00:04 -0400, Pavel Roskin wrote:
> > On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005)
> > Ltd wrote:
> > > Hi,
> > > 
> > > I am playing with the search command in grub2 from debian experimental
> > > and have noticed some oddness
> > > 
> > > The search command currently returns the device as hdX,X rather than
> > > (hdX,X).  This means that the variable created using -s can't be used as
> > > a replacement for the device string.
> > 
> > Actually, you can assign it to the root variable and use relative path.
> > You don't need parentheses in the root variable.
> > 
> > >   For Example I'd like to be able to
> > > do this:
> > > 
> > > # Set our root device
> > > search -f /grub/grub.cfg -s root
> > > # Set our prefix 
> > > set prefix=${root}/grub/  # I think broken variable handling means this
> > > doesn't work.
> > 
> > True.  Variable expansion is broken.  But you can use
> > 
> > set prefix=/grub/
> but this means as soon as root is set to the new device, that we can't
> load anymore modules which breaks chainloader, linux, intrd, boot etc
> 
> and it appears preloading boot doesn't work anyway, as it tries to find
> it.  This problem doesn't occur if I manually set prefix=(hdX,X)/grub
> > 
> > That would allow you to load more modules as long as $root is
> > unchanged.
> > 
> > > menuentry "My Linux OS" {
> > > search -s LINUX_ROOT -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> > > set root=$LINUX_ROOT
> > 
> > This is broken for the same reason.  But this would work:
> > 
> > search -s root -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> Nope, as above, because we cannot set Prefix to include the device
> programmatically, as soon as you've changed your root, you can no longer
> load modules or use commands.

An easy fix would be for search to return the device with parentheses

This would solve most of the problems, and allow for:
search -s OSdevice -u XXXX-YYYY-ZZZZ-AAAA-BBBB
chainloader ${OSdevice}+1


-- 
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722




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

* Re: Search command.
  2009-03-12  0:12     ` Centurion Computer Technology (2005) Ltd
@ 2009-03-12  0:51       ` phcoder
  2009-03-12  2:59         ` Centurion Computer Technology (2005) Ltd
  0 siblings, 1 reply; 9+ messages in thread
From: phcoder @ 2009-03-12  0:51 UTC (permalink / raw)
  To: The development of GRUB 2

Centurion Computer Technology (2005) Ltd wrote:
> On Thu, 2009-03-12 at 12:52 +1300, Centurion Computer Technology (2005)
> Ltd wrote:
>> On Wed, 2009-03-11 at 00:04 -0400, Pavel Roskin wrote:
>>> On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005)
>>> Ltd wrote:
>>>> Hi,
>>>>
>>>> I am playing with the search command in grub2 from debian experimental
>>>> and have noticed some oddness
>>>>
>>>> The search command currently returns the device as hdX,X rather than
>>>> (hdX,X).  This means that the variable created using -s can't be used as
>>>> a replacement for the device string.
>>> Actually, you can assign it to the root variable and use relative path.
>>> You don't need parentheses in the root variable.
>>>
>>>>   For Example I'd like to be able to
>>>> do this:
>>>>
>>>> # Set our root device
>>>> search -f /grub/grub.cfg -s root
>>>> # Set our prefix 
>>>> set prefix=${root}/grub/  # I think broken variable handling means this
>>>> doesn't work.
>>> True.  Variable expansion is broken.  But you can use
>>>
>>> set prefix=/grub/
>> but this means as soon as root is set to the new device, that we can't
>> load anymore modules which breaks chainloader, linux, intrd, boot etc
>>
>> and it appears preloading boot doesn't work anyway, as it tries to find
>> it.  This problem doesn't occur if I manually set prefix=(hdX,X)/grub
>>> That would allow you to load more modules as long as $root is
>>> unchanged.
>>>
>>>> menuentry "My Linux OS" {
>>>> search -s LINUX_ROOT -u XXXX-YYYY-ZZZZ-AAAA-BBBB
>>>> set root=$LINUX_ROOT
>>> This is broken for the same reason.  But this would work:
>>>
>>> search -s root -u XXXX-YYYY-ZZZZ-AAAA-BBBB
>> Nope, as above, because we cannot set Prefix to include the device
>> programmatically, as soon as you've changed your root, you can no longer
>> load modules or use commands.
> 
> An easy fix would be for search to return the device with parentheses
> 
> This would solve most of the problems, and allow for:
> search -s OSdevice -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> chainloader ${OSdevice}+1
> 
> 

search -s OSdevice -u XXXX-YYYY-ZZZZ-AAAA-BBBB
chainloader (${OSdevice})+1
-- 

Regards
Vladimir 'phcoder' Serbinenko



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

* Re: Search command.
  2009-03-12  0:51       ` phcoder
@ 2009-03-12  2:59         ` Centurion Computer Technology (2005) Ltd
  0 siblings, 0 replies; 9+ messages in thread
From: Centurion Computer Technology (2005) Ltd @ 2009-03-12  2:59 UTC (permalink / raw)
  To: The development of GRUB 2


> > An easy fix would be for search to return the device with parentheses
> > 
> > This would solve most of the problems, and allow for:
> > search -s OSdevice -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> > chainloader ${OSdevice}+1
> > 
> > 
> 
> search -s OSdevice -u XXXX-YYYY-ZZZZ-AAAA-BBBB
> chainloader (${OSdevice})+1

It doesn't currently do parameter expansion so it parses as far as the
( and stops

-- 
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722




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

* Re: Search command.
  2009-03-11 23:52   ` Centurion Computer Technology (2005) Ltd
  2009-03-12  0:12     ` Centurion Computer Technology (2005) Ltd
@ 2009-03-12  3:16     ` Pavel Roskin
  2009-03-12 10:22       ` Centurion Computer Technology (2005) Ltd
  1 sibling, 1 reply; 9+ messages in thread
From: Pavel Roskin @ 2009-03-12  3:16 UTC (permalink / raw)
  To: The development of GRUB 2

Quoting "Centurion Computer Technology (2005) Ltd" <daniel@centurion.net.nz>:

> Nope, as above, because we cannot set Prefix to include the device
> programmatically, as soon as you've changed your root, you can no longer
> load modules or use commands.

You can preload all the modules you need with insmod in the common  
section.  Then you don't need to worry about the prefix anymore.  The  
memory will be freed once the OS starts loading.

-- 
Regards,
Pavel Roskin



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

* Re: Search command.
  2009-03-12  3:16     ` Pavel Roskin
@ 2009-03-12 10:22       ` Centurion Computer Technology (2005) Ltd
  0 siblings, 0 replies; 9+ messages in thread
From: Centurion Computer Technology (2005) Ltd @ 2009-03-12 10:22 UTC (permalink / raw)
  To: The development of GRUB 2

On Wed, 2009-03-11 at 23:16 -0400, Pavel Roskin wrote:
> Quoting "Centurion Computer Technology (2005) Ltd" <daniel@centurion.net.nz>:
> 
> > Nope, as above, because we cannot set Prefix to include the device
> > programmatically, as soon as you've changed your root, you can no longer
> > load modules or use commands.
> 
> You can preload all the modules you need with insmod in the common  
> section.  Then you don't need to worry about the prefix anymore.  The  
> memory will be freed once the OS starts loading.
> 
Tried that too.  Fails with command not found.  
-- 
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722




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

* search command
@ 2005-08-20  7:56 Yoshinori K. Okuji
  0 siblings, 0 replies; 9+ messages in thread
From: Yoshinori K. Okuji @ 2005-08-20  7:56 UTC (permalink / raw)
  To: The development of GRUB 2

I've implement a new command "search" right now. This is similar to "find" in 
GRUB Legacy, but has more features. I renamed it to "search", because it is 
significantly different from "find" in GNU.

Some supposed usage:

# Find a partition whose label is "Boot Partition" and set the result in root.
search --label "Boot Partition" --set
linux /vmlinuz

# Find a partition which has a file "grub2.cfg" and store it in a variable.
search --file /boot/grub/grub2.cfg --set=VAR
configfile ($VAR)/boot/grub/grub2.cfg

Okuji



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

end of thread, other threads:[~2009-03-12 10:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-11  0:34 Search command Centurion Computer Technology (2005) Ltd
2009-03-11  4:04 ` Pavel Roskin
2009-03-11 23:52   ` Centurion Computer Technology (2005) Ltd
2009-03-12  0:12     ` Centurion Computer Technology (2005) Ltd
2009-03-12  0:51       ` phcoder
2009-03-12  2:59         ` Centurion Computer Technology (2005) Ltd
2009-03-12  3:16     ` Pavel Roskin
2009-03-12 10:22       ` Centurion Computer Technology (2005) Ltd
  -- strict thread matches above, loose matches on Subject: below --
2005-08-20  7:56 search command Yoshinori K. Okuji

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.