Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ktest setup: GRUB submenu fixes #486

Merged
merged 1 commit into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions getting_started/setup_linux/setup_ktest_environment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,24 @@ Set up a target
sudo emacs /etc/default/grub

b) Change ``GRUB_DEFAULT=[n]`` to ``GRUB_DEFAULT=saved``.

c) Add ``GRUB_DISABLE_SUBMENU=y`` to the end of the file and save it.

This step is necessary because submenus confuse ktest.
c) You must disable GRUB submenus because they confuse ktest:

.. code-block:: console

echo 'GRUB_DISABLE_SUBMENU=y' | sudo tee -a /etc/default/grub.d/disable-submenu.cfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the commit is saying that GRUB_DISABLE_SUBMENU=true is the documented setting and not with y?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The documentation changed from y (unusual) to true (common)
  • The _implementation changed from: "y only" to: "y OR true".

=> To be compatible with ALL grub versions, stick to y.


d) Update the grub configuration.

.. code-block:: console

sudo update-grub

# Better safe than _very_ sorry
sudo cp /boot/grub/grub.cfg /boot/grub/saved_grub.cfg

sudo update-grub
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: this sometimes can cause un-bootable system which can be only recovered by booting to a live env, chrooting to the existing linux install and grub-install --target=x86_64-efi ....

Copy link
Collaborator Author

@marc-hb marc-hb Feb 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to chroot and run update-grub inside the chroot but that did not work, it failed with: can't find device for /, is /dev mounted?
GRUB was still installed fine on my system in that instance, that wasn't my problem.

What worked for me was to find and manually enter grub commands and parameters at boot time. This let me boot. Then I disabled the submenus and ran update-grub from the "real" system.

Different OS and different situations will require different solutions. Rescuing unbootable systems is a very complex topic; we can't provide bullet proof advice in such a limited space here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to chroot and run update-grub inside the chroot but that did not work, it failed with: can't find device for /, is /dev mounted? GRUB was still installed fine on my system in that instance, that wasn't my problem.

Few things should be done to be able to update grub in chroot, something like:
https://wiki.gentoo.org/wiki/Chroot#Configuration

What worked for me was to find and manually enter grub commands and parameters at boot time.

Wow

This let me boot. Then I disabled the submenus and ran update-grub from the "real" system.

Different OS and different situations will require different solutions. Rescuing unbootable systems is a very complex topic; we can't provide bullet proof advice in such a limited space here.

Sure!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb Are you ready for this PR to be merged? Thanks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please merge.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marc-hb Thanks!


# Make sure submenus are actually disabled
grep submenu /boot/grub/grub.cfg

#. Set the default kernel.

Expand All @@ -84,7 +92,7 @@ Set up a target
# Print your currently booted (and known-safe) option
cat /proc/cmdline
# List the grub entries
awk '/^menuentry/ { print i++, '\t', $0 }' /boot/grub/grub.cfg
awk '/^menuentry|submenu/ { print i++, '\t', $0 }' /boot/grub/grub.cfg
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should not be any submenu at this point?

But sudo might be needed to actually read the grub.cfg

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should not be any submenu at this point?

Not in theory.

In practice this "magic" command is typically re-used across devices - including devices that still have submenus for whatever reason. And the consequences can be deadly.

But sudo might be needed to actually read the grub.cfg

In my experience it's not; I use this command all the time.

# Find the entry that matches the output of the
# first command you ran, and take note of its number
sudo grub-set-default [n] # Where [n] is that number
Expand Down Expand Up @@ -135,7 +143,7 @@ Set up a target
#=> saved_entry=6

# Show all, numbered kernel choices without (re)booting
awk '/^menuentry/ { print i++, '\t', $0 }' /boot/grub/grub.cfg
awk '/^menuentry|submenu/ { print i++, '\t', $0 }' /boot/grub/grub.cfg
#=> 5 menuentry ...
#=> 6 menuentry 'Ubuntu, with Linux 5.4.0-53-generic' --class ubuntu ...
#=> 7 menuentry ...
Expand Down
Loading