help-grub
[Top][All Lists]
Advanced

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

Re: Probing for the existence of a device.


From: Andrey Borzenkov
Subject: Re: Probing for the existence of a device.
Date: Sun, 23 Jun 2013 10:22:27 +0400

В 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 ...".

> 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.

> 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.
> 

Attachment: signature.asc
Description: PGP signature


reply via email to

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