How do I force GRUB to keep video mode after switching to the OS?

I use GRUB as a bootloader for my custom OS. I want it to enter graphics mode for me so I don’t have to do it myself in my system. However, before GRUB passes the control to the OS, video mode is changed back to 80x25 text mode. I have tried using set gfxpayload=keep but it doesn’t seem to do anything. The mode I chose (using set gfxmode=1024x768x24) works fine while GRUB is still active, but before passing the control to my OS’s entry point it goes back to text mode. Am I doing something wrong? And, here is my grub.cfg file:

set root=(hd0,1)
set gfxmode=1024x768x24
set gfxpayload=keep
insmod vbe
insmod vga
insmod video_cirrus
insmod gfxterm
set menu_color_normal=red/blue
set menu_color_highlight=green/blue
loadfont /boot/grub/fonts/unicode.pf2
terminal_input console
terminal_output gfxterm
set timeout=1
set default=0
menuentry "Trolololo" { multiboot /kernel boot
}
4

1 Answer

Problem solved. As sawdust suggested, analysing GRUB's source code was a way to go (grub_multiboot_set_console function in grub-2.00/grub-core/loader/multiboot.c file).

The problem was that my kernel is loaded by multiboot <filename> command and linux is loaded (in most cases) by linux <filename> command. Multiboot specification requires that information about preferred video mode is provided in the multiboot header. If that information is not provided, GRUB switches back to the text mode before starting the kernel and completely ignores gfxpayload variable.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like