lubuntu grub-install puts efi in the wrong directory - could create an unbootable state

Bug #1833490 reported by Cory Petkovsek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calamares-settings-ubuntu (Ubuntu)
Fix Released
Undecided
Unassigned
grub2 (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

Lubuntu 19.04
grub-install from grub2-common 2.02+dfsg1-12ubuntu2

Summary:

The lubuntu installer puts the EFI in EFI/ubuntu. The firmware appears to be hard coded to this path. Lubuntu grub-install puts the EFI in EFI/lubuntu only, and NOT in EFI/ubuntu, which can result in an unbootable state (grub prompt).

Detail:

Long time debian, new lubuntu user. After a fresh install of lubuntu from usb:

$ efibootmgr
BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0003,0002,0000,0001,2001,2002,2003
Boot0000* Windows Boot Manager
Boot0001* Linpus lite
Boot0002* debian
Boot0003* ubuntu
Boot2001* EFI USB Device
Boot2002* EFI DVD/CDROM
Boot2003* EFI Network

$ sudo update-grub
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.0.0-17-generic
Found initrd image: /boot/initrd.img-5.0.0-17-generic
Found linux image: /boot/vmlinuz-5.0.0-13-generic
Found initrd image: /boot/initrd.img-5.0.0-13-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Found Debian GNU/Linux 9 (stretch) on /dev/nvme0n1p5
Adding boot menu entry for EFI firmware configuration
done

$ ls /boot/efi/EFI/
Boot debian Microsoft ubuntu

$ sudo grub-install
Installing for x86_64-efi platform.
Installation finished. No error reported.

$ ls /boot/efi/EFI/
Boot debian lubuntu Microsoft ubuntu

#### It installs only to lubuntu and NOT also to ubuntu. See comments below.

$ efibootmgr
BootCurrent: 0003
Timeout: 0 seconds
BootOrder: 0004,0003,0002,0000,0001,2001,2002,2003
Boot0000* Windows Boot Manager
Boot0001* Linpus lite
Boot0002* debian
Boot0003* ubuntu
Boot0004* lubuntu
Boot2001* EFI USB Device
Boot2002* EFI DVD/CDROM
Boot2003* EFI Network

$ strings /boot/efi/EFI/ubuntu/* |egrep EFI/l?ubuntu
/EFI/ubuntu

$ strings /boot/efi/EFI/lubuntu/* |egrep EFI/l?ubuntu
/EFI/ubuntu

I discovered this when I moved my lubuntu partition to another drive and tried to get grub to reinstall. I also deleted unnecessary EFIs (ubuntu and later both). I only figured out the problem after reinstalling Lubuntu from scratch and observing the state of the EFI partition after install.

If the ubuntu folder is removed (and possibly requiring a partion id change but not likely), attempting to boot lubuntu will go to a grub prompt.

`set` revealed:
`root=(hd1,gpt1)` (my EFI partition)
`prefix=(hd1,gpt1)/EFI/ubuntu` (had been deleted, and grub-install did not put it back)

Lubuntu could be booted with the following commands, where hd1, partition 7 is the new root:

```
set root=(hd1,gpt7)
set prefix=(hd1,gpt7)/boot/grub
insmod normal
normal
```

No amount of running `update-grub`, and `grub-install`, creating custom grub entries, or running grub from debian or a rescue disk mattered. The only thing that fixed it was reinstalling as that's the only thing that put the EFI/ubuntu folder back. I probably could have just manually renamed the directory in EFI from lubuntu to ubuntu.

Revision history for this message
Cory Petkovsek (tinmanjuggernaut) wrote :

$ diff -r /boot/efi/EFI/lubuntu/ /boot/efi/EFI/ubuntu/
$

summary: - lubuntu grub-install puts efi in the wrong directory
+ lubuntu grub-install puts efi in the wrong directory - could make an
+ unbootable state
summary: - lubuntu grub-install puts efi in the wrong directory - could make an
+ lubuntu grub-install puts efi in the wrong directory - could create an
unbootable state
apt-ghetto (apt-ghetto)
Changed in calamares-settings-ubuntu (Ubuntu):
status: New → Confirmed
Revision history for this message
apt-ghetto (apt-ghetto) wrote :

Thank you for filing this bug report.

In my opinion, this bug is not caused by grub2, but by a configuration file in calamares-settings-ubuntu.

During installation the variable GRUB_DISTRIBUTOR in /etc/default/grub is set to 'Lubuntu 19.04' instead of `lsb_release -i -s 2> /dev/null || echo Debian`.

####################################################

[Test Case]
1. Install Lubuntu 19.04 in EFI mode
2. Check that there is a boot entry named "ubuntu" with: sudo efibootmgr -v
3. Install Grub: sudo grub-install
4. Check that there are now two boot entries for Lubuntu: One named "ubuntu" with "File(\EFI\ubuntu\shimx64.efi)" and another named "lubuntu" with "File(\EFI\lubuntu\shimx64.efi)"
5. Edit /etc/default/grub and replace "GRUB_DISTRIBUTOR='Lubuntu 19.04'" with "GRUB_DISTRIBUTOR='bug'"
6. Reinstall Grub
7. Check that there are now three boot entries for Lubuntu: "ubuntu", "lubuntu", and "bug"

Revision history for this message
Raman Sarda (theloudspeaker) wrote :

@apt-ghetto I don't think the issue is due to calamares-settings-ubuntu. I have followed your instructions about renaming GRUB_DISTRIBUTOR to "bug" and reproduced the issue. But I checked the config file of calamares-settings-ubuntu on phab. and as far as I understand it, the installer might be setting the distributor to "Lubuntu 19.04" but it creates the directory under ESP and also the nvram entry according to this file : https://phab.lubuntu.me/source/calamares-settings-ubuntu/browse/master/lubuntu/modules/bootloader.conf
which has efiBootloaderId: "Ubuntu"

I cannot find a config file anywhere in the calamares-settings-ubuntu which sets GRUB_DISTRIBUTOR to "Lubuntu 19.04"

So the question is "what sets GRUB_DISTRIBUTOR like that?"

Revision history for this message
ԜаӀtеr Ⅼарсһуnѕkі (wxl) wrote :

This was fixed in:

=====

calamares-settings-ubuntu (1:19.10.4) eoan; urgency=medium

  [ Dan Simmons ]
  * Bump Standards-Version to 4.4.0, no changes needed.
  * Bump debhelper to 12, no changes needed.
  * Adjust automirror config to new style. Change automirror module
    to allow for new config style.
  * Add setting for donate button in welcome.
  * Add geoip for welcome.
  * Adjust locale.conf to new geoip style.
  * Set userSwapChoices to none in partition.conf.
  * Set defaultFileSystemType to "ext4" in partition.conf.
  * Set default dont-chroot, oem-setup, disable-cancel, to
    eliminate warnings from settings.conf.
  * Add efiMountOptions: umask=0077 to fstab.conf.
  * Set restart mode to new style in finished.conf.
  * Set bootloader entry name to Ubuntu.
  * Set slide show API to 1 to eliminate warnings.
  * Fix lintian errors and warnings.
    - Add depends for python3 in calamares-settings-ubuntu-common.
    - Adjust depends for calamares-settings-lubuntu.
    - Add further description to extended description for
      calamares-settings-lubuntu and calamares-settings-ubuntu.
    - Add lintian override for bash in .desktop file.
    - Remove unusual-interpreter in .desktop file.
    - Adjust Makefile so .desktop file so it is not executable.
    - Add keywords to .desktop file.
    - Remove executable flag from automirror.conf and module.desc.
    - Adjust debian/rules dpkg-architecture-variable.

  [ apt-ghetto ]
  * Fix small issues in automirror module
    - Remove whitespace before index bracket.
    - Remove undefined variable.
    - Fix over-indented block.

 -- Dan Simmons <email address hidden> Tue, 20 Aug 2019 19:59:12 -0400

=====

The full diff is here:
https://phab.lubuntu.me/rCALASETTINGScd7fa92d15410c58e80490028a508114d5ca9aec

The crucial change being reverting the bootloaderEntryName in the Calamares branding.desc to "Ubuntu." Though it would be nice to be flavor specific, a lot in the Ubuntu system depends upon the value of GRUB_DISTRIBUTOR being as such.

Beyond how Calamares affects GRUB settings, GRUB should otherwise be uninvolved.

Changed in grub2 (Ubuntu):
status: New → Invalid
Changed in calamares-settings-ubuntu (Ubuntu):
status: Confirmed → Fix Released
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.