GRUB and VGA Modes
VGA Modes and GRUB
Hopefully your Linux kernel will detect the video hardware
and select a good video mode.
However, especially on virtualized platforms like
Oracle VirtualBox, you may need to help it along.
The modern way to do this is through GRUB variables
GRUB_GFXMODE
and
GRUB_GFXPAYLOAD_LINUX
.
Add something like the following to
/etc/default/grub
to set the desired width×height×depth
(in pixels×pixels×bits).
[ ... lines deleted ... ] GRUB_GFXMODE=1024x768x32 GRUB_GFXPAYLOAD_LINUX=keep [ ... lines deleted ... ]
You can set multiple resolutions, including the default
auto
,, using something like this:
[ ... lines deleted ... ] GRUB_GFXMODE=1920x1080x32,1024x768x32,auto GRUB_GFXPAYLOAD_LINUX=keep [ ... lines deleted ... ]
Then update the GRUB configuration.
The GRUB configuration file is in
/boot/efi/EFI/distro-name/
or in
/boot/grub2
on a system with the EFI firmware in BIOS legacy mode.
# grub2-mkconfig -o $(find /boot -name grub.cfg)
If the command is instead grub-mkconfig
with the configuration file in /boot/grub/
on your distribution (e.g., Oracle, RHEL, CentOS, etc),
of course use that instead.
If you use command completion and file name completion
with the <Tab>
key as you should,
this wouldn't be a problem and you might not even notice
the difference.
But If That Doesn't Work...
You can add a vga=
directive to the
kernel line in the GRUB file, something like the
following:
linuxefi /vmlinuz-X.Y.Z vga=792 root=UUID=77aa6e61-df08-4480-a3ae-73bf40116336 ro
You will, of course, see something specific in place of
X.Y.Z
and you can use numbers other
than 792
.
That specific number yields 1024×768 with 65,536
possible colors.
See the table below for a variety of choices!
But first, some tips:
-
The
vga=XXX
directive can go anywhere on the line. I put it near the beginning in this example to make it easy to spot if you're viewing this page on a phone. But it will be easiest for you to add it to the end. -
Experiment!
Press
e
at the GRUB menu and add an experimental string, then press<Ctrl>-X
to boot. If you get an unwanted mode, or even a totally black screen, cycle the power and try again. Once you find a useful value, you can install it as explained below. -
You might see
linuxefi
as in my example above, orlinux
, depending on your platform. Leave that alone, you're simply looking for the line with somevmlinuz-X.Y.Z
kernel file name.
Available VGA Modes
Color bits | Colors | 640×480 | 800×600 | 1024×768 | 1280×1024 | 1400×1050 | 1600×1200 |
8 bits | 256 colors | 769 |
771 |
773 |
775 |
||
15 bits | 32,768 colors | 784 |
787 |
790 |
793 |
||
16 bits | 65,536 colors | 785 |
788 |
791 |
794 |
834 |
884 |
24 bits | 16,777,216 colors | 786 |
789 |
792 |
795 |
Installing Your Configuration Change
Do not simply edit the
/boot/grub/grub.cfg
file!
Changes to that file will be wiped out the next time you install a kernel update.
Edit the file /etc/default/grub
and look
for lines like this:
[ ... lines deleted ... ] GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX="" [ ... lines deleted ... ]
Insert your addition there. If there is only one such line, add it to that string. If there are two lines, add it to the non-empty string:
[ ... lines deleted ... ] GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792" GRUB_CMDLINE_LINUX="" [ ... lines deleted ... ]
Now, regenerate the GRUB configuration file. This will insert your addition to every stanza or boot target.
# grub-mkconfig -o $(find /boot -name grub.cfg)
For example, on a UEFI/GPT/dracut
platform,
the GRUB configuration file
might be under /boot/efi/EFI/
.
On a BIOS/MBR/isolinux
platform,
the directory might be /boot/grub2
rather than boot/grub
.
The precise location depends on your distribution.
If you instead find a file named grub.conf
,
then you're on a very old system with the legacy
GRUB 0.99 instead of GRUB 2.
Also, there may be a "2" in the command name:
grub2-mkconfig
.
What About The GRUB Menu Resolution?
Yes, there are three operating system environments on your way to what you really want to run:
- Firmware: With UEFI firmware, this can be fairly high resolution graphics. Then then firmware starts:
- GRUB boot loader: This gets whatever the UEFI has set up, although you can tell it to try a specific resolution. That's useful to change in a virtualized environment, where the boot loader is running within a window on a graphical desktop of a host OS. Then it loads and starts:
-
Operating system:
The above showed how to pass a video resolution
request like
vga=792
to the OS kernel as it's loaded.
To set the GRUB boot loader resolution:
look for a line setting GRUB_GFXMODE
within
the file /etc/default/grub
.
Add it if needed, or change what's there.
You could use double-quotes around the resolution
string but they aren't needed:
[ ... lines deleted ... ] GRUB_GRXMODE=1024x768 [ ... lines deleted ... ]
Then regenerate the GRUB configuration file.
# grub-mkconfig -o /boot/grub/grub.cfg