Skip to contentSkip to conversation

Search command.

DISCUSSION Centurion Computer Technology (2005) Ltd 3 participants 8 messages Mar 11, 2009 – Mar 12, 2009

lore
Share & tools
lore
#0 lore raw

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?

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
#1 lore raw
Quoted 8 lines · On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005) Ltd…

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.

Quoted 8 lines

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.

Quoted 3 lines

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

Quoted 2 lines

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

You understand it correctly. But the implementation is limited.

Signature · 2 lines
Regards,
Pavel Roskin
#2 lore raw
Quoted 23 lines · Pavel Roskin
Quoted 8 lines · On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005) Ltd…

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.

Quoted 8 lines

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.

Quoted 3 lines

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

Quoted 11 lines

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

Quoted 3 lines

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.

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
#3 lore raw
Quoted 40 lines · On Thu, 2009-03-12 at 12:52 +1300, Centurion Computer Technology (2005) Ltd…
Quoted 23 lines · Pavel Roskin
Quoted 8 lines · On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005) Ltd…

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.

Quoted 8 lines

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.

Quoted 3 lines

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

Quoted 8 lines

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

Quoted 3 lines

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

Quoted 6 lines
Quoted 3 lines

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

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
#4 lore raw
Quoted 44 lines · Centurion Computer Technology (2005) Ltd wrote:
Quoted 35 lines · On Thu, 2009-03-12 at 12:52 +1300, Centurion Computer Technology (2005) Ltd…
Quoted 16 lines · Pavel Roskin
Quoted 8 lines · On Wed, 2009-03-11 at 13:34 +1300, Centurion Computer Technology (2005) Ltd…

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.

Quoted 3 lines

For Example I'd like to be able to
do this:

Quoted 7 lines
Quoted 4 lines

# 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

Quoted 6 lines

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

Quoted 3 lines

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

Quoted 6 lines
Quoted 3 lines

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.

Quoted 7 lines

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

Signature · 2 lines
Regards
Vladimir 'phcoder' Serbinenko
#5 lore raw
Quoted 11 lines
Quoted 8 lines

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

Signature · 4 lines
Daniel Reurich

Centurion Computer Technology (2005) Limited.
Ph: 021 797 722
#6 lore raw
In reply to Centurion Computer Technology (2005) Ltd

Quoting "Centurion Computer Technology (2005) Ltd" <[email protected]>:

Quoted 3 lines

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.

Signature · 2 lines
Regards,
Pavel Roskin
#7 lore raw
Quoted 10 lines · Pavel Roskin

Quoting "Centurion Computer Technology (2005) Ltd" <[email protected]>:

Quoted 3 lines

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.

Signature · 4 lines
Daniel Reurich

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