grub-pc fails to install on the last of multiple devices
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
grub2 (Debian) |
Fix Released
|
Unknown
|
|||
grub2 (Ubuntu) |
Confirmed
|
Undecided
|
Unassigned |
Bug Description
When installing grub-pc to multiple devices, it fails installing on the last device. For the failing device, all of the errors show a stray comma at the end of the device name.
This is occurring because install_devices is a multiselect, and the results are separated by commas. There is a comma at the end too. This ends up being interpreted as part of the device name. The package has code to remove the commas in the middle, but it does not remove the comma at the end.
To reproduce this after the first failure, I had to do this (where that device is the _last_ device, on which the install is failing):
grub-install /dev/disk/
In the installed package's grub-pc.postinst, or the source package's debian/postinst.in, this is the code in question (indentation reduced 8 spaces):
failed_devices=
for i in `echo $RET | sed -e 's/, / /g'` ; do
real_
if grub-install --target=i386-pc --force --no-floppy $real_device ; then
# We just installed GRUB 2; then also generate grub.cfg.
touch /boot/grub/grub.cfg
else
fi
done
For testing, I added a couple of echo statements:
failed_
+ echo RET: $RET
for i in `echo $RET | sed -e 's/, / /g'` ; do
+ echo REAL: $real_device
if grub-install --target=i386-pc --force --no-floppy $real_device ; then
# We just installed GRUB 2; then also generate grub.cfg.
touch /boot/grub/grub.cfg
else
fi
done
This is the output:
debconf (developer): <-- GET grub-pc/
debconf (developer): --> 0 /dev/disk/
RET: /dev/disk/
REAL: /dev/sdb
Installing for i386-pc platform.
Installation finished. No error reported.
REAL: /dev/sdc
Installing for i386-pc platform.
Installation finished. No error reported.
REAL: /dev/disk/
Installing for i386-pc platform.
grub-install: error: cannot find a GRUB drive for /dev/disk/
debconf (developer): <-- SUBST grub-pc/
The issue is definitely the comma at the end.
To fix the issue, I changed the sed line to be like this:
for i in `echo $RET | sed -e 's/,\( \|$\)/ /g'` ; do
This strips the comma at the end, not just those in the middle (commas followed by spaces).
Alternatively, if you prefer sed -E instead of backslashes for parens, this also works:
for i in `echo $RET | sed -E 's/,( |$)/ /g'` ; do
or if -e is important, this also works:
for i in `echo $RET | sed -Ee 's/,( |$)/ /g'` ; do
Changed in grub2 (Debian): | |
status: | Unknown → New |
Changed in grub2 (Debian): | |
status: | New → Fix Released |
Richard, as you didn't use 'apport' or 'ubuntu-bug' when creating this bug report I'm unsure if what you are reporting applies to me or not as your report doesn't include any version information.
I have Ubuntu 18.04 and Ubuntu 19.04 installed on this laptop which has two disks /dev/sda and /dev/sdb. Using Ubuntu 18.04 I can install grub, update grub and boot to either installation without any problem.
From Ubuntu 18.10 (now upgraded to Ubuntu 19.04) any attempt to update grub seemed to fail as I could only boot to the existing kernel and not to the newly installed kernel. I have seen this on more than one occasion.
If this is an example of what you are reporting and something that has been an issue since the 18.04 release then I can confirm the bug report.
There's a reference to my issue at: https:/ /ubuntuforums. org/showthread. php?t=2403574& p=13808168& viewfull= 1#post13808168