=^.^=

Adjust TTY (Text Console/Terminal) Resolution for GRUB and Linux

karma

Most modern linux distributions will attempt to set the text console (for historical reasons also referred to as TTY, for TeleTYpewriter) resolution to the primary display's maximum native resolution. You may find this is not the case on your system, or more commonly these days, that the virtual display resolution of your virtual machine is undesirable. Personally I most commonly find this to be a problem when working on virtual machines through the Citrix Hypervisor XenCenter client software; when using a smaller resolution on the client machine it is necessary to constantly scroll the Console tab/undocked window up and down or scale the display which results in degraded image quality.

In ye olden days one would set the resolution using a code and the vga= kernel command line option. You can still do that however if you are booting with GRUB you can set the gfxpayload environment variable with a human-readable resolution and both grub and the kernel will run a the specified resolution.

The following edits are made to the /etc/default/grub configuration file. GRUB configuration has become complicated over the years so this meta-configuration composed of variables was introduced as an alternative to directly editing the file actually used by the bootloader directly. Among other things it allows one to specify settings that persist and are applied to multiple boot options. Since kernel upgrades and the like may overwrite that file (depending on your distribution) it's best to play ball with this system. After making your edits make sure /boot is mounted read-write if it is on another partition and run your distribution's GRUB update script (common syntax below) as root to effect the changes to the active GRUB configuration file.

If you choose to do it the old way add your vga= line to GRUB_CMDLINE_LINUX_DEFAULT; if there are already options contained in this string append it with a space. The VGA codes are such:

Colour bits Colours 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

In my case, I would like the console to be a manageable 800x600 with 24-bit colour. My vga option would look like: vga=789.

We can determine the video modes supported by GRUB by interrupting the boot menu and entering the GRUB command line on startup. Press the c key to enter the command line.

grub> set pager=1 grub> vbeinfo

This will display a table of supported resolutions. Back in /etc/default/grub we want to make sure the linux kernel inherits GRUB's resolution and doesn't try to do its own thing. We're going to add the nomodeset option instead of vga= to the kernel command line and specify GRUB's resolution in GRUB_GFXPAYLOAD_LINUX. Try to find these variables, they should already exist. If they do not, create them:

GRUB_CMDLINE_LINUX_DEFAULT="nomodeset" GRUB_GFXPAYLOAD_LINUX="800x600"

Now to update the active configuration file, depending on your system, run:

update-grub grub-update grub-mkconfig -o /boot/grub/grub.cfg grub2-mkconfig -o /boot/grub2/grub.cfg

Comments

There are no comments for this item.