[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Probing for the existence of a device.
From: |
João Ricardo Sares Teles de Matos |
Subject: |
Re: Probing for the existence of a device. |
Date: |
Sun, 23 Jun 2013 19:45:29 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 |
Thank you for your reply.
I am using GRUB 1.99 as distributed in Debian GNU/Linux 7.0 "wheezy" amd64.
Distro package version: 1.99-27+deb7u1
Replies to specific parts of the message follow inline.
On 06/23/2013 07:22 AM, Andrey Borzenkov wrote:
> В Sat, 22 Jun 2013 22:44:53 +0100
> João Ricardo Sares Teles de Matos <address@hidden> пишет:
>
>> I couldn't find a reliable way to do something like this:
>>
>> if drive_exists_p (hd1); then
>> menuentry_to_chainload_drive (hd1)
>> fi
>>
>> Where the missing piece is the pseudo-command "drive_exists_p", which has a
>> zero return when the device exists.
>>
>> The "probe --driver" command sort of does the job, but it prints error
>> messages and causes a "Press any key to continue..." prompt when the device
>> doesn't exist.
>>
> I cannot reproduce it, at least using current trunk. probe command
> simply fails without any "Press any key ...".
Upon further testing, I found that the prompt only shows up if the test happens
within a submenu, as such:
submenu "foo" {
if probe --driver (hd1); then
menuentry "Chainload drive (hd1)"{
chainload_drive "(hd1)"
}
fi
# filler entry to ensure the submenu has at least one entry.
menuentry "bar" { true }
}
The prompt happens when that specific submenu is entered and only if probe
fails.
>> The idea is having automatically (dis)appearing menu entries to chainload
>> devices that may be (un)plugged, which is useful in an environment where USB
>> thumb drives are frequently used as boot devices.
>>
> I think in this case search would be more useful. You cannot predict
> device names, but using something like
>
> search --set usb1 --fs-uuid XXXX
> search --set usb2 --fs-uuid XXXX
> ...
> if [ -n "$usb1" ]; then
> ... code to deal with USB media 1
> fi
> ... etc ...
>
> Would allow you to quite reliably detect presence of devices.
That solution requires that the devices contain filesystems with UUIDs known at
the time of the generation of grub.cfg.
The idea was being able to chainload any new arbitrary device that the system
had no prior contact with.
In any case, the search command has the same problem as the probe command: if
one of them fails, a prompt to press any key is presented before the submenu
entries.
>> The test command with -e or -d doesn't work unless the device contains a
>> filesystem that GRUB can read.
>>
>> Am I missing something, or is this something that can't be done without
>> extending GRUB?
>>
>> By the way, is this sort of message appropriate for this mailing list?
>> I'd hate to be spamming the list with offtopic queries.
>>
--
João Ricardo Sares Teles de Matos
address@hidden
Administração de Sistemas da Rede das Novas Licenciaturas
Instituto Superior Técnico
web: https://www.rnl.ist.utl.pt
email: address@hidden
telefone: +351 218 41 77 71
signature.asc
Description: OpenPGP digital signature