Public bug reported:

Binary package hint: grub-installer

1) LiveCD Ubuntu 9.04 desktop x64 booted on my system.
2) I used the grub-install script with the version from the above live cd.

3)&4)
My goal was to correct the grub boot-loader installed on the MBR of my HDD on 
which I have a partition with Ubuntu 8.04 LTS, after that partition got another 
number because I modified some partitions.
Since I wanted the version of grub from Ubuntu 9.04 instead of that from Ubuntu 
8.04, I run the grub-install script without chroot-ing first, and such that to 
use the old config files from directory /boot/grub from the Ubuntu8.04 
partition (which became /dev/sda2), namely I run the command:

ubuntu>  sudo grub-install --recheck --root-
directory=/media/Wdc2_Ubuntu-8.04 --debug  /dev/sde2

and here is the lines of errors during the execution of this command:
........
+ sync

+ grub-probe -t fs /media/Wdc2_Ubuntu-8.04/boot/grub
grub-probe: error: Cannot open `/boot/grub/device.map'
+ [ = xfs ]
[: 1: =: unexpected operator

+ count=5
.........

which are cause by the if instruction from lines 489-494 from th script:
    489 # On XFS, sync() is not enough.
    490 if [ `grub-probe -t fs ${grubdir}` = "xfs" ] ; then
    491   xfs_freeze -f ${grubdir} && xfs_freeze -u ${grubdir}
    492   # We don't have set -e.  If xfs_freeze failed, it's worth trying 
anyway,
    493   # maybe we're lucky.
    494 fi

The second error is specific to test command and binary operator = when the 
operands happen to be null string, and can be
easily corrected by the usual trick of adding some character on both sides of 
the test:
replace [  `grub-probe -t fs ${grubdir}` = "xfs" ] by  [ x`grub-probe -t fs 
${grubdir}` = x"xfs" ]
This error manifested because of the first error given by the execution of 
grub-probe, in this case:
grub-probe -t fs ${grubdir}
give the error: Cannot open `/boot/grub/device.map' and as such produces a null 
string in the if test.

This last error occured because it tried to access the file 
/boot/grub/device.map from the live CD, instead that from the 
/media/Wdc2_Ubuntu-8/boot/grub/device.map, i.e. that from the partition where I 
wanted to install grub config files without chroot-ing first into it. So I 
think that maybe the script should use the device.map from under the directory 
specified as  --root-directory= to the call of grub-install script.
This can be achieved by using the option -m or -device-map=FILE for the command 
grub-probe, namely I think that the line 490 from the grub-install script 
should be replace by:
   if [ X`grub-probe -t fs --device-map=$device_map  ${grubdir}` = X"xfs" ] ; 
then

So, as to conclude, I think that the call to grub-probe from the grub-install 
script should take into consideration the file
specified by the variable $device_map and not the default 
/boot/grub/device.map, as is doing through the other grub commands in the 
script.

If it is not corrected, it will affect the outcome of the script in the case 
that the partition to which is installed is XFS (in which case the xfs_freeze 
from line 491 would not be called as it should be),
otherwise (i.e. other types of partitions) the outcome of the script will be 
the one desired, besides the `cryptic` error messages which could be confusing 
for a beginner user.

P.S.
Please bear with my possible mistakes, this is my first bug report, I hope I 
was clear enough in describing the problem and a possible solution to it.

** Affects: grub-installer (Ubuntu)
     Importance: Undecided
         Status: New

-- 
bash error in the grub-install script
https://bugs.launchpad.net/bugs/503604
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to