GRUB2 Video Mode Switch

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
inixsoftware
Member
Member
Posts: 32
Joined: Fri Jan 31, 2014 8:21 am

GRUB2 Video Mode Switch

Post by inixsoftware »

I am using Grub2 (version 1.98) and according to the Drawing in Protected Mode page, Grub2 and patched Grub Legacy can switch the video modes. Is there a grub.cfg option that tells Grub2 to do the switch?
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: GRUB2 Video Mode Switch

Post by thepowersgang »

Grub switches to a graphical mode before passing control to the kernel if the kernel requests it (by setting the relevant flag in the multiboot header).

I think that you can configure grub to use a specific mode using grub.cfg options, but that's not needed just to get a graphics mode out of it.
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: GRUB2 Video Mode Switch

Post by Bender »

thepowersgang wrote: I think that you can configure grub to use a specific mode using grub.cfg options, but that's not needed just to get a graphics mode out of it.
Found this: https://www.gnu.org/software/grub/manua ... ation.html
GRUB_GFXMODE’
Set the resolution used on the ‘gfxterm’ graphical terminal. Note that you can only use modes which your graphics card supports via VESA BIOS Extensions (VBE), so for example native LCD panel resolutions may not be available. The default is ‘auto’, which tries to select a preferred resolution. See gfxmode.
Probably for gfxterm (GRUB's Graphical Terminal I guess), but I think you can use it for your kernel too.
Although I'm not sure if it'll fall back to the original video mode (80x25 text) after booting the kernel.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
klange
Member
Member
Posts: 679
Joined: Wed Mar 30, 2011 12:31 am
Libera.chat IRC: klange
Discord: klange

Re: GRUB2 Video Mode Switch

Post by klange »

If you want to configure the resolution in grub 2 with a properly configured multiboot kernel, use:

Code: Select all

set gfxpayload=1920x1080
... after you've loaded your kernel (right before you call boot).

You can also add "x32" to the end to force 32-bit color (and presumably x24 and so on) if it's available, otherwise I think it defaults to 24-bit.

You can also do:

Code: Select all

set gfxpayload=text
... to force VGA text-mode when you have the video flag set in your header.
Post Reply