serial terminal options for GRUB2 (RHEL 9 kvm guest image)

Latest response

In the KVM guest image, grub.cfg is very small and references some variables immediately before calling blscfg:

[root@ipa6 ~]# cat /boot/grub2/grub.cfg 

set timeout=0

# load the grubenv file
load_env

# selection of the next boot entry via variables 'next_entry' and
# `saved_entry` present in the 'grubenv' file. Both variables are
# set by grub tools, like grub2-reboot, grub2-set-default

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

search --no-floppy --set=root --fs-uuid 5e75a2b9-1367-4cc8-bb38-4d6abc3964b8
set boot=${root}
function load_video {
  insmod all_video
}
${serial}${terminal_input}${terminal_output}
blscfg

I guess these are taken from /boot/grub2/grubenv and are manipulated by grub2-editenv. I've tried the following:

grub2-editenv /boot/grub2/grubenv set serial='serial --unit=0 --speed=115200' terminal_input='terminal_input serial' terminal_output='terminal_output serial'

grub2-editenv /boot/grub2/grubenv set serial=$'serial --unit=0 --speed=115200\n' terminal_input=$'terminal_input serial\n' terminal_output=$'terminal_output serial\n'

grub2-editenv /boot/grub2/grubenv set serial='serial --unit=0 --speed=115200;' terminal_input='terminal_input serial;' terminal_output='terminal_output serial;'

but neither seem to do anything: while watching the serial port during boot, I can see the output from the BIOS, followed by nothing for a few seconds while presumably GRUB is displaying a menu somewhere, followed by the kernel output.

Does anyone know the proper way to enable serial output from GRUB2 with the kvm guest image?

Responses