Probed linux entries not bootable if original initrd line has more than one file

Bug #1840477 reported by Matt Heller
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
os-prober (Ubuntu)
New
Undecided
Unassigned

Bug Description

I have Manjaro Linux 18.0.4 installed and then recently installed Ubuntu 19.04 on another partition. After the Ubuntu install the Ubuntu created GRUB boot menu includes entries for booting Manjaro but they aren't functional. It is repeatable after install too, If I run update-grub2 from Ubuntu the prober finds Manjaro and adds boot entries but they are flawed in the same way. Namely the entries for booting Manjaro in the original Manjaro created grub.cfg contain:

                linux /vmlinuz-4.19-x86_64 root=UUID=c6b7b62a-66d5-45ef-89dd-4f06ec8e6cbe rw
                initrd /amd-ucode.img /initramfs-4.19-x86_64.img

but the entries in the Ubuntu created grub.cfg contain:

                linux /vmlinuz-4.19-x86_64 root=UUID=c6b7b62a-66d5-45ef-89dd-4f06ec8e6cbe rw
                initrd /amd-ucode.img

The second initrd file goes missing. Thus if I try to boot using the Ubuntu created entry for Manjaro I hit
"Kernel Panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)"
... immediately at the beginning of boot.

I tracked the problem down to /usr/lib/linux-boot-probes/mounted/40grub2 line # 81
      initrd="$(echo "$2" | sed 's/(.*)//')"
From what I can tell the purpose of this is to strip GRUB style partition specifier prefix like "(hd0,1)" however it makes the assumption that the original initrd line it discovered in probing only contains a single file.

I am able to fix this behavior and make the Manjaro entry of the Ubuntu generate GRUB menu bootable if I change the "40grub2" prober and "30_os-prober" code as follows...
(borrows from the Manjaro version)

$ diff /usr/lib/linux-boot-probes/mounted/40grub2.original /usr/lib/linux-boot-probes/mounted/40grub2
81,82d80
< initrd="$(echo "$2" | sed 's/(.*)//')"
< # Initrd same.
84c82,84
< initrd="/boot$initrd"
---
> initrd="$(echo "$line" | sed 's/initrd//;s/\t//;s|/|/boot/|g;s/(.*)//')"
> else
> initrd="$(echo "$line" | sed 's/initrd//;s/\t//;s/(.*)//')"

$ diff /etc/grub.d/30_os-prober.original /etc/grub.d/30_os-prober
246c246
< LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
---
> LINITRD="`echo ${LINUX} | cut -d ':' -f 5 | tr '^' ' '`"

ProblemType: Bug
DistroRelease: Ubuntu 19.04
Package: os-prober 1.74ubuntu1 [modified: usr/bin/linux-boot-prober]
ProcVersionSignature: Ubuntu 5.0.0-25.26-generic 5.0.18
Uname: Linux 5.0.0-25-generic x86_64
ApportVersion: 2.20.10-0ubuntu27.1
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Fri Aug 16 10:03:03 2019
InstallationDate: Installed on 2019-08-15 (1 days ago)
InstallationMedia: Ubuntu 19.04 "Disco Dingo" - Release amd64 (20190416)
ProcEnviron:
 TERM=xterm-256color
 PATH=(custom, no user)
 XDG_RUNTIME_DIR=<set>
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: os-prober
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Matt Heller (matthew-f-heller) wrote :
Revision history for this message
Matt Heller (matthew-f-heller) wrote :

My apologies, I just realized I did have to change one more line to make the generated grub menu work for me, the diff of 30_os-prober should really be:

diff /etc/grub.d/30_os-prober.original /etc/grub.d/30_os-prober
246c246
< LINITRD="`echo ${LINUX} | cut -d ':' -f 5`"
---
> LINITRD="`echo ${LINUX} | cut -d ':' -f 5 | tr '^' ' '`"
255c255
< LINITRD="${LINITRD#/boot}"
---
> LINITRD="$(echo $LINITRD | sed 's|/boot/|/|g')"

--Matt

Revision history for this message
Matt Heller (matthew-f-heller) wrote :

I didn't spot an existing bug report when I first filed this but I later found:

https://bugs.launchpad.net/ubuntu/+source/os-prober/+bug/1635781

...which is pretty closely related. I am using UEFI and Manjaro Linux rather than Legacy BIOS mode and Arch Linux but the cause of the problem seems to be the same.

--Matt

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.