On Tue, 28 Oct 2008, Robert Millan wrote:
> > Sorry but I don't understand how you concile the two sentences that you
> > gave:
> > - on one side you say that "-t drive" only fails when device.map is wrong
> >   and you accept that we invite the user to regenerate it
> 
> s/regenerate/check/g.  When device.map is wrong, it doesn't necessarily mean
> we have to regenerate it.  This could be our own fault, e.g. if
> grub-mkdevicemap doesn't recognise a new device type.
What do you expect the user to do when he "checks" the device.map ?

He will likely try to re-generate it or hand-edit it if he knows what this
is all about. But most users will be left in the cold… I believe that an
advanced user will sort it out even if the file has been regenerated, in
particular if he has been informed of it. We could also keep a copy of
the file if we regenerate it to ease debugging.

> > - on the other side you tell me that trying to regenerate it only when "-t
> >   drive" fails has been tried and was worse than the problem
> > 
> > What do I miss ?
> 
> The behaviour is inconsistent with what users tend to reasonably expect, and
> very confusing to those who aren't aware of it.

That's why I added an echo statement that explicitely informs the user
that the file got regenerated.

> See for example #479056. Also, it makes debugging a PITA.

>From what I see, the device.map regeneration was included in grub-probe
itself and the user was only informed through a "info:" that is only
displayed in verbose mode.

Of course this made debugging difficult.


Ok, if you really don't want to replace the device.map on the fly,
let me propose yet another solution: in case of grub-probe failure, we
regenerate a device.map in a temporary file and we try grub-probe again
but with --device-map pointing to this temporary file. That way the
default device.map doesn't get modified and we still have a chance to make
it work by default. We would display a message saying that the device.map
has to be verified if we succeed through the fallback solution.

Please find the corresponding patch attached.

Cheers,
-- 
Raphaël Hertzog

Le best-seller français mis à jour pour Debian Etch :
http://www.ouaza.com/livre/admin-debian/
Index: update-grub
===================================================================
--- update-grub (révision 1095)
+++ update-grub (copie de travail)
@@ -152,7 +152,17 @@
        if ! test -e ${device_map} ; then
                echo quit | grub --batch --no-floppy --device-map=${device_map} 
> /dev/null
        fi
-       GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} 
-t drive -d "$1" 2> /dev/null
+       GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe --device-map=${device_map} 
-t drive -d "$1" 2> /dev/null || { 
+               echo "warning: grub-probe can't find drive for $1." >&2
+               tmp_map=$(mktemp -t device.map.XXXXXXXX)
+               grub-mkdevicemap --device-map=${tmp_map} --no-floppy >/dev/null 
2>&1 || true
+               GRUB_LEGACY_0_BASED_PARTITIONS=1 grub-probe 
--device-map=${tmp_map} -t drive -d "$1" || {
+                       rm -f ${tmp_map}
+                       return 1
+               }
+               echo "Please check ${device_map}, you might have to update it 
with grub-mkdevicemap." >&2
+               rm -f ${tmp_map}
+       }
 }
 
 # Usage: convert_default os_device

Reply via email to