How to edit grub menu in Fedora 42

In previous versions of Fedora when I wanted to edit the grub menu on a boot media (USB) I just mounted the USB, went to the Anaconda/efi/boot directory, copied the boot.cfg and grub.cfg files to my desktop, edit them with a text editor, then copy them back overwriting what was there. That no longer seems to be an option and I dont see any documentation on how to change it now.

Help

The grub configuration file is automatically generated by grub2-mkconfig using templates from /etc/grub.d and settings from /etc/default/grub file. You edit the /etc/default/grub file and run the sudo grub2-mkconfig -o /boot/grub2/grub.cfg command to generate the configuration file.

1 Like

When I boot to the USB there are three options on the grub menu; boot to fedora, test media and boot to fedora, and troubleshoot. I do not see those options in any of the files you mentioned.

I tried to run the grub2-mkconfig you mentioned and get the error…
/usr/bin/grub2-probe: error: failed to get canonical path of ā€˜LiveOS_rootfs’

Any ideas?

And in case I am not being clear, here is the grub.cfg file from 41 that is located in anaconda/EFI/BOOT:

set default="0"

function load_video {
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod all_video
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=60
### END /etc/grub.d/00_header ###

search --no-floppy --set=root -l 'Fedora-WS-Live-41-1-4'

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Start Fedora-Workstation-Live 41' --class fedora --class gnu-linux --class gnu --class os {
	linuxefi /images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-41-1-4  rd.live.image quiet rhgb
	initrdefi /images/pxeboot/initrd.img
}

submenu 'Troubleshooting -->' {
	menuentry 'Start Fedora-Workstation-Live 41 in basic graphics mode' --class fedora --class gnu-linux --class gnu --class os {
		linuxefi /images/pxeboot/vmlinuz root=live:CDLABEL=Fedora-WS-Live-41-1-4  rd.live.image nomodeset quiet rhgb
		initrdefi /images/pxeboot/initrd.img
	}
}

I am looking for this file in 42 and can not find it anywhere.

There are two files named grub.cfg. An autogenerated one will be created in /boot/grub2/ as a result of executing grub2-mkconfig > /boot/grub2/grub.cfg and will be used during the boot process. The other one should remain UNTOUCHED!

After backing up file /etc/default/grub, you may make changes to it. The backup’s purpose is to make it easy to remedy changes that cause undesirable results.

There is no such file as grub.cfg in /boot/grub2, only earlyboot.cfg, grubenv, and a fonts folder.

The /etc/default/grub grub.cfg file contains…

GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_DISABLE_RECOVERY=true
GRUB_CMDLINE_LINUX_DEFAULT="quiet rhgb"
GRUB_GFXMODE=auto
GRUB_TERMINAL_INPUT="console"
GRUB_TERMINAL_OUTPUT="console"
GRUB_TIMEOUT=10

Which does not contain the boot menu options I am looking for. So I am still confused.

After installation, grub2-mkconfig may be used to generate a new configuration file.

I assume you are talking about the live system iso that is copied to USB.

In the new version, the initial grub.cfg will search for the real grub.cfg which is to be found in the boot sub-directory of the iso9660 file system which is read-only.
The initial grub.cfg, however, is found in the vfat file system that is located in the second partition of the boot device. I don’t know if it would work if you just copied the boot/grub2/grub.cfg from the readonly partition 1 to EFI/BOOT/grub.cfg in the writable partition 2.

I mounted the second partition on the USB named Boot, the first was called Fedora-WS-Live-42, and looked around. There are two grub.cfg files, one in efi/boot and one in efi/fedora, neither have the boot options I am looking for (the contents of the grub.cfg I posted above from version 41). The only other things on the partition seem to be efi files.

Command line arguments can be specified in the /etc/default/grub file.

Which boot menu options are you looking for?

When I boot to the USB there are three options on the grub menu; boot to fedora, test media and boot to fedora, and troubleshoot. I do not see those options in any of the files you mentioned. These are the options I am looking for, I want to be able to edit whatever the heck is generating this menu.

You missed the file boot/grub2/grub.cfg in the iso9660 file system


# Inspired by the config used for lorax-built live media

set default="1"

if [ "$grub_platform" == "efi" ]; then
	function load_video {
		insmod efi_gop
		insmod efi_uga
		insmod video_bochs
		insmod video_cirrus
		insmod all_video
	}
	set basicgfx="nomodeset"
else
	function load_video {
		insmod all_video
	}
	set basicgfx="nomodeset vga=791"
fi

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

terminal_input console
terminal_output console

set timeout=10
set timeout_style=menu

search --file --set=root /boot/0xf3aa2021

menuentry "Start Fedora-Xfce-Live" --class fedora --class gnu-linux --class gnu --class os {
	linux ($root)/boot/x86_64/loader/linux quiet rhgb  root=live:CDLABEL=Fedora-Xfce-Live-42 rd.live.image
	initrd ($root)/boot/x86_64/loader/initrd
}
menuentry "Test this media & start Fedora-Xfce-Live" --class fedora --class gnu-linux --class gnu --class os {
	linux ($root)/boot/x86_64/loader/linux quiet rhgb  root=live:CDLABEL=Fedora-Xfce-Live-42 rd.live.image rd.live.check
	initrd ($root)/boot/x86_64/loader/initrd
}
submenu "Troubleshooting -->" {
	menuentry "Start Fedora-Xfce-Live in basic graphics mode" --class fedora --class gnu-linux --class gnu --class os {
		linux ($root)/boot/x86_64/loader/linux quiet rhgb  root=live:CDLABEL=Fedora-Xfce-Live-42 rd.live.image ${basicgfx}
		initrd ($root)/boot/x86_64/loader/initrd
	}
}

it is referred to in the search command from the initial grub.cfg

set btrfs_relative_path="yes"
search --file --set=root /boot/0xf3aa2021
set prefix=($root)/boot/grub2
configfile ($root)/boot/grub2/grub.cfg

I dont think I did. I mentioned above ā€œThere is no such file as grub.cfg in /boot/grub2, only earlyboot.cfg, grubenv, and a fonts folder.ā€ Is it hidden or something?

OK, I see where I got confused. It appears there are TWO images, one inside another. When I looked at the USB from within Windows, I saw the outside of the second image and there was no config file there. Booting to the USB shows the live filesystem and there is no config there either. I had to mount the ISO, then browse to the /boot/grub2 folder and there is the config file I have been looking for.

Wow. It went from really simple to find and edit this file to really convoluted. Nice ā€œupgradeā€.

Anyway, I am now trying to find a way to edit the ISO while leaving it bootable and structurally intact. Some programs look like they will edit it and save it, but then it wont boot after using Fedora Media Writer to make the USB. Some programs look like they will write it IF YOU PAY FOR THE PROGRAM, which I am not about to do unless I know for a fact it will work, and some programs simply don’t work at all.

–SOLUTION–

For those on Windows having my issues (not the mental ones, you can’t have those, they are mine!) You can use AnyBurn to edit the ISO, but I could not get Fedora Media Writer to make a successfully booting USB from the new image. Rufus however will.

So to recap… Install AnyBurn, open the Fedora 42 ISO, extract the grub.cfg from the /boot/grub2 folder, edit it, delete the grub.cfg from the ISO, copy the edited grub.cfg back to the ISO, save the ISO, install Rufus, open the ISO in Rufus, burn USB, done.