update-grub fails to set submenu item as default by name

Bug #2070250 reported by TomyLobo
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
grub2 (Ubuntu)
New
Undecided
Unassigned

Bug Description

# Motivation
The latest 22.04 HWE kernel (6.5.0-41) doesn't work with my dock (#2070020), so I'm trying to set a previous stable kernel (6.5.0-35) as a default in GRUB.

# What I did
I've added the following to /etc/default/grub.d/pin-6.5.0-35.cfg:
```
GRUB_DEFAULT="Ubuntu, with Linux 6.5.0-35-generic"
```

# What went wrong
update-grub warns:
```
Warning: Please don't use old title `Ubuntu, with Linux 6.5.0-35-generic' for GRUB_DEFAULT, use `Advanced options for Ubuntu>Ubuntu, with Linux 6.5.0-35-generic' (for versions before 2.00) or `gnulinux-advanced-abd4adac-c96a-4e9b-bc6b-17edaad709ee>gnulinux-6.5.0-35-generic-advanced-abd4adac-c96a-4e9b-bc6b-17edaad709ee' (for 2.00 or later)
```
It does add an override to grub.cfg to change the default to "Advanced options for Ubuntu>Ubuntu, with Linux 6.5.0-35-generic", though:
```
if [ "x$default" = 'Ubuntu, with Linux 6.5.0-35-generic' ]; then default='Advanced options for Ubuntu>Ubuntu, with Linux 6.5.0-35-generic'; fi;
```
That's why I initially thought I did everything right and disregarded the warning.

# Workaround
I changed /etc/default/grub.d/pin-6.5.0-35.cfg to the following:
```
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux 6.5.0-35-generic"
```

# Remarks
The workaround is the preferred way to set a default by name.
However, I believe that if there is code that generates a broken override, it should be fixed or removed.

# Relation to other bugs
I believe this is NOT a duplicate of #2049681, since it also occurs without "GRUB_DISABLE_SUBMENU=true", but depending on what the issue was with #2049681, that bug might be covered by a solution for mine, so a "duplicates" pointing in the other direction might be more appropriate, if I understand the meaning of "duplicates" correctly.

# Causes
grub-mkconfig generates broken grub.cfg code to add the submenu part to the default.
It's still present in the current master branch:
https://git.savannah.gnu.org/gitweb/?p=grub.git;a=blob;f=util/grub.d/10_linux.in;h=cc393be7eda9ab79cd0207434924c06fbd27bb6d;hb=HEAD#l104
It's missing an `x` before `$quoted`.
Because of that, the condition always fails and GRUB falls back to booting the first available kernel.

This was introduced when grub-mkconfig was updated to support submenus in 2012:
https://git.savannah.gnu.org/gitweb/?p=grub.git;a=commitdiff;h=0cdc126ca2c7af914ede99253d1546ebbd11e937

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: grub2 (not installed)
ProcVersionSignature: Ubuntu 6.5.0-35.35~22.04.1-generic 6.5.13
Uname: Linux 6.5.0-35-generic x86_64
NonfreeKernelModules: zfs
ApportVersion: 2.20.11-0ubuntu82.5
Architecture: amd64
CasperMD5CheckResult: pass
CurrentDesktop: KDE
Date: Mon Jun 24 11:41:59 2024
InstallationDate: Installed on 2023-07-05 (354 days ago)
InstallationMedia: Kubuntu 22.04.2 LTS "Jammy Jellyfish" - Release amd64 (20230223)
SourcePackage: grub2
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
TomyLobo (tomylobo) wrote :
TomyLobo (tomylobo)
description: updated
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.