bash error in the grub-install script
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub (Ubuntu) |
Triaged
|
Medium
|
Unassigned |
Bug Description
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-
and here is the lines of errors during the execution of this command:
........
+ sync
+ grub-probe -t fs /media/
grub-probe: error: Cannot open `/boot/
+ [ = xfs ]
[: 1: =: unexpected operator
+ count=5
.........
which are cause by the if instruction from lines 489-494 from the 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/
This last error occured because it tried to access the file /boot/grub/
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-
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/
If it is not corrected, it will affect the outcome of the script in the case that the partition to which is installed is of type XFS (in which case the xfs_freeze from line 491 would not be called as it was desired to 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.
P.S.2
Probably this bug should be checked also in the grub-install script from the other Ubuntu/Debian distributions which uses this kind of script for Grub legacy install.
description: | updated |
affects: | grub-installer (Ubuntu) → grub (Ubuntu) |
Changed in grub (Ubuntu): | |
importance: | Undecided → Medium |
status: | New → Triaged |