hartwork / grub2-theme-preview

:city_sunrise: Preview a full GRUB 2.x theme (or just a background image) using KVM / QEMU
https://pypi.org/project/grub2-theme-preview/
327 stars 11 forks source link

ERROR: Command "grub-mkrescue" of Grub 2.x not found #22

Closed robcollins55 closed 3 years ago

robcollins55 commented 3 years ago

Hi. Looks like a good tool but had difficulty running. Did.... grub2-theme-preview /boot/grub2/themes/Breeze and got..... ERROR: Command "grub-mkrescue" of Grub 2.x not found

grub2-mkrescue is the command on my Fedora 33 setup so I did.... alias grub-mkrescue=grub2-mkrescue That aliaslink is now recognised for issuing grub-mkrescue from terminal but still I get... ERROR: Command "grub-mkrescue" of Grub 2.x not found when I run grub2-theme-preview /boot/grub2/themes/Breeze

hartwork commented 3 years ago

Hi @robcollins55 I think there is a misunderstanding about how shell aliases work: They only affect the shell, not when programs like grub2-theme-preview invoke other programs based on $PATH lookup. I think what you are looking for is argument --grub2-mkrescue, e.g. as in grub2-theme-preview --grub2-mkrescue grub2-mkrescue [..]. You can then leverage a new shell alias like alias grub2-theme-preview='grub2-theme-preview --grub2-mkrescue grub2-mkrescue' and append that to your e.g. ~/.bashrc if you would like to use grub2-theme-preview without specifying the custom grub2-mkrescue every time on the shell (but not in shell scripts).

What do you think?

robcollins55 commented 3 years ago

Thanks for the quick attention you put on this @hartwork :). Yes looks like there is an alias usage gap in my knowlege so thanks for your help above and beyond what you needed to :). I had tried the option flag previously but I didn't understand that one needed to additionally quote grub2-mkrescue after that flag also. So I have now run:

[rob@localhost` ~]$ grub2-theme-preview --grub2-mkrescue grub2-mkrescue /boot/grub2/themes/Breeze
INFO: Could not read external GRUB config file, falling back to internal example config
ERROR: [Errno 2] grub2-mkrescue failed to create the rescue image

Looks like my misunderstanding with alias and your syntax requirements is now sorted, leaving me to only track down why my /boot/grub2/grub.cfg file is not being read. A small matter that I will no doubt track down with more reading of your readme.md. I will message again if I don't get anywhere with that, Thanks again!

hartwork commented 3 years ago

Hi @robcollins55 thanks sharing these updates.

The issue with accessing grub.cfg is probably a permissions thing: When grub2-theme-preview is run without root permissions, the process cannot access files with e.g. 0600/-rw------- like my local /boot/grub/grub.cfg has. So to make that work, you can (a) be okay with the example built-in config as a fallback (whose effects you can see in this screenshot) or (b) making that file world-readable or (c) running grub2-theme-preview as root or ... But that part is the icing on the cake, the grub2-mkrescue failure is more critical.

To figure out why grub2-mkrescue is failing to create a rescue image, please add --verbose --debug to your invocation of grub2-theme-preview. With some luck its new output already gives some idea what's going on. If you can paste the output, that would help.

Here's an example of what a successful run with --verbose --debug looks over here:

# grub2-theme-preview --verbose --debug /usr/share/grub/themes/starfield/
INFO: Appending to fonts to load: dejavu_10.pf2
INFO: Appending to fonts to load: dejavu_12.pf2
INFO: Appending to fonts to load: dejavu_14.pf2
INFO: Appending to fonts to load: dejavu_16.pf2
INFO: Appending to fonts to load: dejavu_bold_14.pf2
INFO: [Errno 13] Permission denied: '/boot/grub/grub.cfg'
INFO: Could not read external GRUB config file, falling back to internal example config

>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
loadfont $prefix/fonts/unicode.pf2
loadfont $prefix/themes/DEMO/dejavu_10.pf2
loadfont $prefix/themes/DEMO/dejavu_12.pf2
loadfont $prefix/themes/DEMO/dejavu_14.pf2
loadfont $prefix/themes/DEMO/dejavu_16.pf2
loadfont $prefix/themes/DEMO/dejavu_bold_14.pf2
insmod all_video
insmod gfxterm
insmod png
insmod tga
menuentry 'Debian' --class debian --class gnu-linux --class linux --class gnu --class os {
    reboot
}

menuentry 'Gentoo' --class gentoo --class gnu-linux --class linux --class gnu --class os {
    reboot
}

menuentry "Memtest86+" {
    reboot
}

submenu 'Reboot / Shutdown' {
    menuentry Reboot { reboot }
    menuentry Shutdown { halt }
}

set timeout=30
terminal_output gfxterm
set theme=$prefix/themes/DEMO/theme.txt
>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

# grub-mkrescue --directory=/usr/lib/grub/i386-pc --xorriso xorriso --output /tmp/tmp1xoi844p/grub2_theme_demo.img boot/grub/grub.cfg=/tmp/tmp1xoi844p/grub.cfg boot/grub/themes/DEMO/=/usr/share/grub/themes/starfield
xorriso 1.5.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/tmp/tmp1xoi844p/grub2_theme_demo.img'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 2039m free
Added to ISO image: directory '/'='/tmp/grub.IP8WTj'
xorriso : UPDATE :     322 files added in 1 seconds
Added to ISO image: file '/boot/grub/grub.cfg'='/tmp/tmp1xoi844p/grub.cfg'
Added to ISO image: directory '/boot/grub/themes/DEMO'='/usr/share/grub/themes/starfield'
xorriso : UPDATE :     354 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/lib/grub/i386-pc/boot_hybrid.img'
ISO image produced: 5277 sectors
Written to medium : 5277 sectors at LBA 0
Writing to 'stdio:/tmp/tmp1xoi844p/grub2_theme_demo.img' completed successfully.

INFO: Please give GRUB a moment to show up in QEMU...
# qemu-system-x86_64 -m 256 -drive file=/tmp/tmp1xoi844p/grub2_theme_demo.img,index=0,media=disk,format=raw -enable-kvm

What do you think?

robcollins55 commented 3 years ago

Thanks for that @hartwork . I sorted the permissions problem with the grub.cfg, indeed it was inaccessible in the /boot/grub2/ dir so I did: chmod u=rwx,g=rwx,o=rx /boot/grub2 (I prefer the lettered abbreviation approach as the numbered codes for permission chmod changing flummox me at times). That worked for the grub.cfg issue.

Then I made a symbolic link (for reasons that will become apparent a bit further on): ln -s /boot/grub2 /boot/grub chmod u=rwx,g=rwx,o=rx /boot/grub

I then ran the verbose version of the grub2-theme-preview command as per your guidance: grub2-theme-preview --verbose --debug --grub2-mkrescue grub2-mkrescue /boot/grub2/themes/Breeze That returned further permissions problems and reference to /boot/grub directory (where Fedora 33 uses grub2 as directory name which is why I set up the symbolic link above):

[rob@localhost grub2-theme-preview-2.0.1]$ grub2-theme-preview --verbose --debug --grub2-mkrescue grub2-mkrescue /boot/grub2/themes/Breeze
INFO: Appending to fonts to load: dejavu_mono_14.pf2
INFO: Appending to fonts to load: NotoSans-Bold-14.pf2
INFO: Appending to fonts to load: NotoSans-Regular-10.pf2
INFO: Appending to fonts to load: NotoSans-Regular-12.pf2
INFO: Appending to fonts to load: NotoSans-Regular-32.pf2

>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
loadfont $prefix/fonts/unicode.pf2
loadfont $prefix/themes/DEMO/dejavu_mono_14.pf2
loadfont $prefix/themes/DEMO/NotoSans-Bold-14.pf2
loadfont $prefix/themes/DEMO/NotoSans-Regular-10.pf2
loadfont $prefix/themes/DEMO/NotoSans-Regular-12.pf2
loadfont $prefix/themes/DEMO/NotoSans-Regular-32.pf2
insmod all_video
insmod gfxterm
insmod png
insmod tga
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod lvm
insmod xfs
set root='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'  5a8b7d89-a857-49c3-9aa5-f55dcf791404
else
  search --no-floppy --fs-uuid --set=root 5a8b7d89-a857-49c3-9aa5-f55dcf791404
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=1920x1080x16
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_NZ
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod gfxmenu
loadfont ($root)/grub2/themes/solarized-dark/ascii.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans10.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans12.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans-Bold14.pf2
insmod png
set theme=($root)/grub2/themes/solarized-dark/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/06_grub-customizer_menu_color_helper ###
### END /etc/grub.d/06_grub-customizer_menu_color_helper ###

### BEGIN /etc/grub.d/08_fallback_counting ###
insmod increment
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
  # if countdown has ended, choose to boot rollback deployment,
  # i.e. default=1 on OSTree-based systems.
  if  [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
    set default=1
    set boot_counter=-1
  # otherwise decrement boot_counter
  else
    decrement boot_counter
  fi
  save_env boot_counter
fi
### END /etc/grub.d/08_fallback_counting ###

### BEGIN /etc/grub.d/10_linux ###
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod part_msdos
insmod xfs
set boot='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=boot --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=boot a4464878-c50f-4c2b-a2db-d5123d269c5d
fi

# This section was generated by a script. Do not modify the generated file - all changes
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
#
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
# populates the boot menu. Please refer to the Boot Loader Specification documentation
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.

# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
# entries populated from BootLoaderSpec files that use this variable work correctly even
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
#
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
if [ -z "${kernelopts}" ]; then
  set kernelopts="root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet "
fi

insmod blscfg
blscfg
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/10_reset_boot_success ###
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
  set menu_hide_ok=1
else
  set menu_hide_ok=0 
fi
# Reset boot_indeterminate after a successful boot
if [ "${boot_success}" = "1" ] ; then
  set boot_indeterminate=0
# Avoid boot_indeterminate causing the menu to be hidden more then once
elif [ "${boot_indeterminate}" = "1" ]; then
  set boot_indeterminate=2
fi
# Reset boot_success for current boot 
set boot_success=0
save_env boot_success boot_indeterminate
### END /etc/grub.d/10_reset_boot_success ###

### BEGIN /etc/grub.d/12_menu_auto_hide ###
if [ x$feature_timeout_style = xy ] ; then
  if [ "${menu_show_once}" ]; then
    unset menu_show_once
    save_env menu_show_once
    set timeout_style=menu
    set timeout=60
  elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
    set orig_timeout_style=${timeout_style}
    set orig_timeout=${timeout}
    if [ "${fastboot}" = "1" ]; then
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout_style=menu
      set timeout=0
    else
      set timeout_style=hidden
      set timeout=1
    fi
  fi
fi
### END /etc/grub.d/12_menu_auto_hide ###

### BEGIN /etc/grub.d/14_menu_show_once ###
if [ x$feature_timeout_style = xy ]; then
  if [ "${menu_show_once_timeout}" ]; then
    set timeout_style=menu
    set timeout="${menu_show_once_timeout}"
    unset menu_show_once_timeout
    save_env menu_show_once_timeout
  fi
fi
### END /etc/grub.d/14_menu_show_once ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

set timeout=30
terminal_output gfxterm
set theme=$prefix/themes/DEMO/theme.txt
>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

# grub2-mkrescue --directory=/usr/lib/grub/i386-pc --xorriso xorriso --output /tmp/tmps6qm_mj6/grub2_theme_demo.img boot/grub/grub.cfg=/tmp/tmps6qm_mj6/grub.cfg boot/grub/themes/DEMO/=/boot/grub2/themes/Breeze
xorriso 1.5.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/tmp/tmps6qm_mj6/grub2_theme_demo.img'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 1824m free
Added to ISO image: directory '/'='/tmp/grub.csB7nt'
xorriso : UPDATE :     287 files added in 1 seconds
Added to ISO image: file '/boot/grub/grub.cfg'='/tmp/tmps6qm_mj6/grub.cfg'
libisofs: FAILURE : Access to file is not allowed
xorriso : FAILURE : Grafting failed:  '/boot/grub/themes/DEMO/icons/.directory' = '/boot/grub2/themes/Breeze/icons/.directory'
xorriso : UPDATE :     312 files added in 1 seconds
xorriso : aborting : -abort_on 'FAILURE' encountered 'FAILURE'
grub2-mkrescue: error: `xorriso` invocation failed
.
Traceback (most recent call last):
  File "/home/rob/.local/lib/python3.9/site-packages/grub2_theme_preview/__main__.py", line 412, in main
    _inner_main(options)
  File "/home/rob/.local/lib/python3.9/site-packages/grub2_theme_preview/__main__.py", line 380, in _inner_main
    raise OSError(errno.ENOENT, '%s failed to create the rescue image' % command)

I think I need further help here @hartwork as I am not knowlegable enough to know what is being said in the verbose output ;) Thanks!

hartwork commented 3 years ago

Hi @robcollins55 by default, both /boot/grub/grub.cfg and /boot/grub2/grub.cfg are tried — see https://github.com/hartwork/grub2-theme-preview/blob/2444726e072b4b51180501a6cefe48cb4957a0e8/grub2_theme_preview/__main__.py#L162-L165 — so the symlink should not be necessary.

With regard to chmod u=rwx,g=rwx,o=rx /boot/grub2 please note that:

I'm saying that also because there are more permission issues, as revealed by the output of xorriso (called by grub2-mkrescue) above:

libisofs: FAILURE : Access to file is not allowed
xorriso : FAILURE : Grafting failed:  '/boot/grub/themes/DEMO/icons/.directory' = '/boot/grub2/themes/Breeze/icons/.directory'

This command may come in handy during analysis of current permissions:

find /boot/grub2/themes/Breeze/ | xargs -r ls -ld /boot/{,grub2/{,themes/}} | less

(The curly bracket plus commas stuff is Brace Expansion in man bash.)

Let me know how things went.

robcollins55 commented 3 years ago

Thanks @hartwork. I should mention that I am running all this testing in a Gnome-Boxes VM of Fedora 33, don't know if that makes a difference to getting this to work. You were absolutely right about permissions - I had to recursively change all the permissions in the end:

[rob@localhost ~]$ sudo chmod -R 755 /boot/grub2/

which worked for for running the grub preview command and gave the following:

rob@localhost ~]$ grub2-theme-preview --grub2-mkrescue grub2-mkrescue /boot/grub2/themes/solarized-dark/
INFO: Appending to fonts to load: ascii.pf2
INFO: Appending to fonts to load: DejaVuSans-Bold14.pf2
INFO: Appending to fonts to load: DejaVuSans10.pf2
INFO: Appending to fonts to load: DejaVuSans12.pf2
INFO: Please give GRUB a moment to show up in QEMU...

Qemu then started with following text splash:

SeaBios (version 1.13.0-3.fc33)
iPXE (http://ipxe.org) 00:03.0 CA00 PC12.10 PnP PMM +0FF8DB30 CA00
Booting from Hard Disk...

Then text spash changes to the following before dropping to grub prompt:

Minimal BASH-like line editing is supported.  For first word, TAB lists possible command completions.  Anywhere else TAB lists possible device or file completions.

grub> _

Typing exit at the grub prompt gives:

grub> exit
Booting from floppy...
Boot failed: could not read the boot disk
Botting from DVD/CD...
Boot failed: Could not read from CDROM (code 0003)
Booting from ROM...
iPXE (PCI 00:03.0) starting execution....

Then grub in Qemu crashes (screen frozen)

Any help for getting the graphical grub preview warmly welcomed :).

For further info I post the following output:

[rob@localhost ~]$ grub2-theme-preview --verbose --debug --grub2-mkrescue grub2-mkrescue /boot/grub2/themes/solarized-dark/
INFO: Appending to fonts to load: ascii.pf2
INFO: Appending to fonts to load: DejaVuSans-Bold14.pf2
INFO: Appending to fonts to load: DejaVuSans10.pf2
INFO: Appending to fonts to load: DejaVuSans12.pf2

>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
loadfont $prefix/fonts/unicode.pf2
loadfont $prefix/themes/DEMO/ascii.pf2
loadfont $prefix/themes/DEMO/DejaVuSans-Bold14.pf2
loadfont $prefix/themes/DEMO/DejaVuSans10.pf2
loadfont $prefix/themes/DEMO/DejaVuSans12.pf2
insmod all_video
insmod gfxterm
insmod png
insmod tga
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod lvm
insmod xfs
set root='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'  5a8b7d89-a857-49c3-9aa5-f55dcf791404
else
  search --no-floppy --fs-uuid --set=root 5a8b7d89-a857-49c3-9aa5-f55dcf791404
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=1920x1080x16
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_NZ
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod gfxmenu
loadfont ($root)/grub2/themes/solarized-dark/ascii.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans10.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans12.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans-Bold14.pf2
insmod png
set theme=($root)/grub2/themes/solarized-dark/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/06_grub-customizer_menu_color_helper ###
### END /etc/grub.d/06_grub-customizer_menu_color_helper ###

### BEGIN /etc/grub.d/08_fallback_counting ###
insmod increment
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
  # if countdown has ended, choose to boot rollback deployment,
  # i.e. default=1 on OSTree-based systems.
  if  [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
    set default=1
    set boot_counter=-1
  # otherwise decrement boot_counter
  else
    decrement boot_counter
  fi
  save_env boot_counter
fi
### END /etc/grub.d/08_fallback_counting ###

### BEGIN /etc/grub.d/10_linux ###
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod part_msdos
insmod xfs
set boot='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=boot --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=boot a4464878-c50f-4c2b-a2db-d5123d269c5d
fi

# This section was generated by a script. Do not modify the generated file - all changes
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
#
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
# populates the boot menu. Please refer to the Boot Loader Specification documentation
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.

# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
# entries populated from BootLoaderSpec files that use this variable work correctly even
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
#
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
if [ -z "${kernelopts}" ]; then
  set kernelopts="root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet "
fi

insmod blscfg
blscfg
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/10_reset_boot_success ###
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
  set menu_hide_ok=1
else
  set menu_hide_ok=0 
fi
# Reset boot_indeterminate after a successful boot
if [ "${boot_success}" = "1" ] ; then
  set boot_indeterminate=0
# Avoid boot_indeterminate causing the menu to be hidden more then once
elif [ "${boot_indeterminate}" = "1" ]; then
  set boot_indeterminate=2
fi
# Reset boot_success for current boot 
set boot_success=0
save_env boot_success boot_indeterminate
### END /etc/grub.d/10_reset_boot_success ###

### BEGIN /etc/grub.d/12_menu_auto_hide ###
if [ x$feature_timeout_style = xy ] ; then
  if [ "${menu_show_once}" ]; then
    unset menu_show_once
    save_env menu_show_once
    set timeout_style=menu
    set timeout=60
  elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
    set orig_timeout_style=${timeout_style}
    set orig_timeout=${timeout}
    if [ "${fastboot}" = "1" ]; then
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout_style=menu
      set timeout=0
    else
      set timeout_style=hidden
      set timeout=1
    fi
  fi
fi
### END /etc/grub.d/12_menu_auto_hide ###

### BEGIN /etc/grub.d/14_menu_show_once ###
if [ x$feature_timeout_style = xy ]; then
  if [ "${menu_show_once_timeout}" ]; then
    set timeout_style=menu
    set timeout="${menu_show_once_timeout}"
    unset menu_show_once_timeout
    save_env menu_show_once_timeout
  fi
fi
### END /etc/grub.d/14_menu_show_once ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

set timeout=30
terminal_output gfxterm
set theme=$prefix/themes/DEMO/theme.txt
>>> grub.cfg <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

# grub2-mkrescue --directory=/usr/lib/grub/i386-pc --xorriso xorriso --output /tmp/tmp0u6joe33/grub2_theme_demo.img boot/grub/grub.cfg=/tmp/tmp0u6joe33/grub.cfg boot/grub/themes/DEMO/=/boot/grub2/themes/solarized-dark
xorriso 1.5.2 : RockRidge filesystem manipulator, libburnia project.

Drive current: -outdev 'stdio:/tmp/tmp0u6joe33/grub2_theme_demo.img'
Media current: stdio file, overwriteable
Media status : is blank
Media summary: 0 sessions, 0 data blocks, 0 data, 1840m free
Added to ISO image: directory '/'='/tmp/grub.fjUpsp'
xorriso : UPDATE :     287 files added in 1 seconds
Added to ISO image: file '/boot/grub/grub.cfg'='/tmp/tmp0u6joe33/grub.cfg'
Added to ISO image: directory '/boot/grub/themes/DEMO'='/boot/grub2/themes/solarized-dark'
xorriso : UPDATE :     338 files added in 1 seconds
xorriso : NOTE : Copying to System Area: 512 bytes from file '/usr/lib/grub/i386-pc/boot_hybrid.img'
ISO image produced: 2989 sectors
Written to medium : 2989 sectors at LBA 0
Writing to 'stdio:/tmp/tmp0u6joe33/grub2_theme_demo.img' completed successfully.

INFO: Please give GRUB a moment to show up in QEMU...
# qemu-system-x86_64 -m 256 -drive file=/tmp/tmp0u6joe33/grub2_theme_demo.img,index=0,media=disk,format=raw -enable-kvm
hartwork commented 3 years ago

This is getting interesting! :smiley:

The fact that you do get a GRUB shell prompt is good. In that shell command normal would be the command to continue instead of exit but in our very case it won't help, I'll explain why I think that is. Here's what I found:

If I make grub2-theme-preview use the grub config extract from the log you provided, things fail for me (on Gentoo) as well, i.e. I get dropped into a GRUB shell. The reason GRUB does that is because there are no menu entries in the grub config. The file that creates menuentries is /etc/grub.d/10_linux on my system but looking at related block

### BEGIN /etc/grub.d/10_linux ###
insmod part_msdos
[..]
blscfg
### END /etc/grub.d/10_linux ###

in your log shows that things work differently on your system or in Fedora 33, in general. So my guess is that one of the source commands is expected to pull menu entries in: Either block

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

or block

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

What can we do now?:

What do you think?

robcollins55 commented 3 years ago

Thanks heaps for the guidance @hartwork. I think working with option (b) would be best for the community going forward with this. I will do what you said in (b) later today and post my findings.

robcollins55 commented 3 years ago

OK @hartwork , I can confirm option (a) as workaround works in Fedora 33 by doing:

[rob@localhost ~]$ sudo chmod -R 755 /boot/grub2/
[rob@localhost ~]$ sudo chmod 700 /boot/grub2/grub.cfg

Then I get qemu booting into the grub preview flawlessly - thanks mate that's terrific :smile: : Qemu-Grub_Solarized.

For option (b) for altering the preview package so always works in Fedora, I paste the contents of the /etc/default/grub file and the /boot/default//boot/grub2/grub.cfg file as follows:

[rob@localhost ~]$ cat /etc/default/grub
GRUB_TIMEOUT="5"
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT="saved"
GRUB_DISABLE_SUBMENU="true"
GRUB_TERMINAL_OUTPUT="gfxterm"
GRUB_CMDLINE_LINUX="resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG="false"
GRUB_THEME="/boot/grub2/themes/solarized-dark/theme.txt"
export GRUB_COLOR_NORMAL="light-gray/black"
export GRUB_COLOR_HIGHLIGHT="magenta/black"
GRUB_GFXMODE="1920x1080x16"
GRUB_ENABLE_BLSCFG=""

....and:

[rob@localhost ~]$ cat /boot/grub2/grub.cfg
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
set pager=1

if [ -f ${config_directory}/grubenv ]; then
  load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if [ x$feature_default_font_path = xy ] ; then
   font=unicode
else
insmod part_msdos
insmod lvm
insmod xfs
set root='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='lvmid/O6gvMU-uwtm-ZRbd-5iHc-cPnU-Ch5U-9wHVdI/WZA5xy-MBnL-ZVR5-fTAg-sYZo-cbCY-xJjG40'  5a8b7d89-a857-49c3-9aa5-f55dcf791404
else
  search --no-floppy --fs-uuid --set=root 5a8b7d89-a857-49c3-9aa5-f55dcf791404
fi
    font="/usr/share/grub/unicode.pf2"
fi

if loadfont $font ; then
  set gfxmode=1920x1080x16
  load_video
  insmod gfxterm
  set locale_dir=$prefix/locale
  set lang=en_NZ
  insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod gfxmenu
loadfont ($root)/grub2/themes/solarized-dark/ascii.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans10.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans12.pf2
loadfont ($root)/grub2/themes/solarized-dark/DejaVuSans-Bold14.pf2
insmod png
set theme=($root)/grub2/themes/solarized-dark/theme.txt
export theme
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=5
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=5
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/01_users ###
if [ -f ${prefix}/user.cfg ]; then
  source ${prefix}/user.cfg
  if [ -n "${GRUB2_PASSWORD}" ]; then
    set superusers="root"
    export superusers
    password_pbkdf2 root ${GRUB2_PASSWORD}
  fi
fi
### END /etc/grub.d/01_users ###

### BEGIN /etc/grub.d/06_grub-customizer_menu_color_helper ###
### END /etc/grub.d/06_grub-customizer_menu_color_helper ###

### BEGIN /etc/grub.d/08_fallback_counting ###
insmod increment
# Check if boot_counter exists and boot_success=0 to activate this behaviour.
if [ -n "${boot_counter}" -a "${boot_success}" = "0" ]; then
  # if countdown has ended, choose to boot rollback deployment,
  # i.e. default=1 on OSTree-based systems.
  if  [ "${boot_counter}" = "0" -o "${boot_counter}" = "-1" ]; then
    set default=1
    set boot_counter=-1
  # otherwise decrement boot_counter
  else
    decrement boot_counter
  fi
  save_env boot_counter
fi
### END /etc/grub.d/08_fallback_counting ###

### BEGIN /etc/grub.d/10_linux ###
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=root a4464878-c50f-4c2b-a2db-d5123d269c5d
fi
insmod part_msdos
insmod xfs
set boot='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=boot --hint='hd0,msdos1'  a4464878-c50f-4c2b-a2db-d5123d269c5d
else
  search --no-floppy --fs-uuid --set=boot a4464878-c50f-4c2b-a2db-d5123d269c5d
fi

# This section was generated by a script. Do not modify the generated file - all changes
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
#
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
# populates the boot menu. Please refer to the Boot Loader Specification documentation
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.

# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
# entries populated from BootLoaderSpec files that use this variable work correctly even
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
#
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
if [ -z "${kernelopts}" ]; then
  set kernelopts="root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet "
fi

insmod blscfg
blscfg
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/10_reset_boot_success ###
# Hiding the menu is ok if last boot was ok or if this is a first boot attempt to boot the entry
if [ "${boot_success}" = "1" -o "${boot_indeterminate}" = "1" ]; then
  set menu_hide_ok=1
else
  set menu_hide_ok=0 
fi
# Reset boot_indeterminate after a successful boot
if [ "${boot_success}" = "1" ] ; then
  set boot_indeterminate=0
# Avoid boot_indeterminate causing the menu to be hidden more then once
elif [ "${boot_indeterminate}" = "1" ]; then
  set boot_indeterminate=2
fi
# Reset boot_success for current boot 
set boot_success=0
save_env boot_success boot_indeterminate
### END /etc/grub.d/10_reset_boot_success ###

### BEGIN /etc/grub.d/12_menu_auto_hide ###
if [ x$feature_timeout_style = xy ] ; then
  if [ "${menu_show_once}" ]; then
    unset menu_show_once
    save_env menu_show_once
    set timeout_style=menu
    set timeout=60
  elif [ "${menu_auto_hide}" -a "${menu_hide_ok}" = "1" ]; then
    set orig_timeout_style=${timeout_style}
    set orig_timeout=${timeout}
    if [ "${fastboot}" = "1" ]; then
      # timeout_style=menu + timeout=0 avoids the countdown code keypress check
      set timeout_style=menu
      set timeout=0
    else
      set timeout_style=hidden
      set timeout=1
    fi
  fi
fi
### END /etc/grub.d/12_menu_auto_hide ###

### BEGIN /etc/grub.d/14_menu_show_once ###
if [ x$feature_timeout_style = xy ]; then
  if [ "${menu_show_once_timeout}" ]; then
    set timeout_style=menu
    set timeout="${menu_show_once_timeout}"
    unset menu_show_once_timeout
    save_env menu_show_once_timeout
  fi
fi
### END /etc/grub.d/14_menu_show_once ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_ppc_terminfo ###
### END /etc/grub.d/20_ppc_terminfo ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
hartwork commented 3 years ago

We haven't found the place yet where the generated menuentrys lines go on your system, true? Do you have a file /boot/grub2/user.cfg or a file /boot/grub2/custom.cfg? Or you could you do a fgrep -Rl menuentry /boot/grub2/ or find /boot/grub2/ -name \*.cfg -print -exec fgrep menuentry {} + and share your findings? The menu entries have got to be somewhere :smiley:

robcollins55 commented 3 years ago

I did a bit more digging about this and got it to work !! :sweat_smile: Summary:

[rob@localhost ~]$ sudo chmod -R 755 /boot/grub2/

Then....

[rob@localhost ~]$ sudo nano /etc/default/grub

....edit or add the line to read GRUB_ENABLE_BLSCFG="false" Then use grubby to update grub (Fedora does not use the standard grub-mkconfig -o /boot/grub/grub.cfg, probably because they've gone with using BLSCFG as true/active by default):

[rob@localhost ~]$ sudo grubby update-kernel=ALL

I discovered all this by finding a discussion where the guy criticises the devs of grub2 for recently taking the grub software in a bizzare direction where grub menu entries do not by default get stored in /boot/grub2/grub.cfg. He calls them names like cluster-f*** and other equally uncomplimentary terms. I tend to agree with him going on the amount of time we've spent tracking this issue down: https://www.reddit.com/r/Fedora/comments/cg3wl4/i_cant_find_menuentries_of_my_fedora_30_install/ It seems grub now by default writes menu entries to a human unreadable (binary file?) somewhere on the system if the default grub value GRUB_ENABLE_BLSCFG="true" remains as true. The only way to correct this to the far more sane behaviour of writing menu entries in words to grub.cfg is by changing that flag to GRUB_ENABLE_BLSCFG="false"and running a grub update. Thanks for all your help Sebastian, and I hope all this helps with your very good grub2-theme-preview :smile:. Perhaps your readme.md needs an update for these insane grub pitfalls?

hartwork commented 3 years ago

Interesting! My Grub 2.05_alpha20200310 doesn't seem to have blscfg for some reason. Which version of Grub 2 do you have? Could you share the output of find /boot/loader/ | sort?

robcollins55 commented 3 years ago

Hi Sebastian. For the sake of discovering what is going on here I did a bit of googling and it seems the Fedora-CentOS-RHEL family of distros by default use the "Boot Loader Specification" method of booting grub (BLS) and therefore have largely (or completely?) retired the /etc/default/grub configuration file method. Therefore that config file file has no effect unless you set the flag in that file GRUB_ENABLE_BLSCFG="false" and run a grub refresh. For this exercise I returned the Fedora 33 system back to using BLS, rebooted and checked the /boot/loader/entries/ directory for the boot menu entries, which for BLS should be a separate file for each menu entry. Voilà, here they are:

[root@localhost rob]# cd /boot/loader/entries/
[root@localhost entries]# ls
b18f83e0df0f40f49bf84169ee0b31f8-0-rescue.conf
b18f83e0df0f40f49bf84169ee0b31f8-5.8.14-300.fc33.x86_64.conf
b18f83e0df0f40f49bf84169ee0b31f8-5.8.15-301.fc33.x86_64.conf

Contents are as follows:

[root@localhost entries]# cat b18f83e0df0f40f49bf84169ee0b31f8-0-rescue.conf 
title Fedora (0-rescue-b18f83e0df0f40f49bf84169ee0b31f8) 33 (Workstation Edition Prerelease)
version 0-rescue-b18f83e0df0f40f49bf84169ee0b31f8
linux /vmlinuz-0-rescue-b18f83e0df0f40f49bf84169ee0b31f8
initrd /initramfs-0-rescue-b18f83e0df0f40f49bf84169ee0b31f8.img
options root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet 
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
[root@localhost entries]# cat b18f83e0df0f40f49bf84169ee0b31f8-5.8.14-300.fc33.x86_64.conf 
title Fedora (5.8.14-300.fc33.x86_64) 33 (Workstation Edition Prerelease)
version 5.8.14-300.fc33.x86_64
linux /vmlinuz-5.8.14-300.fc33.x86_64
initrd /initramfs-5.8.14-300.fc33.x86_64.img
options root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet 
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
[root@localhost entries]# cat b18f83e0df0f40f49bf84169ee0b31f8-5.8.15-301.fc33.x86_64.conf 
title Fedora (5.8.15-301.fc33.x86_64) 33 (Workstation Edition)
version 5.8.15-301.fc33.x86_64
linux /vmlinuz-5.8.15-301.fc33.x86_64
initrd /initramfs-5.8.15-301.fc33.x86_64.img
options root=/dev/mapper/fedora-root ro resume=/dev/mapper/fedora-swap rd.lvm.lv=fedora/root rd.lvm.lv=fedora/swap rhgb quiet
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel

Unfortunately I am still at a loss to know how a system running BLS grub understands how to find grub theme files to display if /etc/default/grub is being ignored for writing grub boot configuration. Indeed it is for that reason I decided to try out your grub2-theme-preview in the first instance, as I could not work out why the distro icons for each entry were not being displayed at all under the BLS system (all the themes I tried displayed correctly except for missing icons). I'll do some more digging/experimenting. Have a nice weekend :smile: .

hartwork commented 3 years ago

@robcollins55 thanks for sharing your findings! I think there's some chance that we can help the blscfg command find the boot entries by adding files /boot/loader/entries/*.conf to the rescue image as well.

Could you give pull request #24 a try by any chance? Here's one way how that would work:

cd "$(mktemp -d)"
git clone --branch issue-22-include-boot-loader-entries https://github.com/hartwork/grub2-theme-preview
cd grub2-theme-preview/
virtualenv --python=python3.6 venv
source venv/bin/activate
pip install -e .
grub2-theme-preview --debug --verbose /boot/grub2/themes/Breeze

Thanks in advance! :pray:

robcollins55 commented 3 years ago

I'm absolute beginners (love David Bowie 😄) with github workflows, I only created my github account for the first time a month ago! Will absolutely do what you ask bit later today though Sebastian 😄, your coding suggestion looks great.

robcollins55 commented 3 years ago

issue resolved with recent merging of pull request #24 - thanks @hartwork :smile: