Set Screen Resolution using Kernel Boot Parameter on Linux

29/12/2020
There are times when you boot into your favorite Linux distribution and the display resolution is set incorrectly. You might be having a hard time changing the display resolution to the correct one once it has booted (especially in the Linux headless server operating systems). If this is the case for you, then there is a solution. You can actually set the display resolution with Linux kernel boot parameters.In this article, I am going to show you how to set screen resolution using the kernel boot parameters on Linux. So, let’s get started.

Changing Screen Resolution Using vga Kernel Parameter:

This is the traditional method of changing screen resolution using the Linux kernel boot parameter. It will work on CentOS 7 and older Linux distributions very well.

The vga kernel boot parameter accepts a code which represents the screen resolution. Each of the supported screen resolution on your monitor has a unique decimal number.

The easy way to find the codes is to use vga=ask boot parameter when you boot into your operating system.

To do that, go to the GRUB menu, select an entry and press e.

Now, add vga=ask at the end of the line that loads the kernel as shown in the screenshot below. Note that, the line that loads the kernel starts with linux. Once you’re done, press F10 to boot.

Now, press <Enter> to see all the supported screen resolutions.

As you can see, all the supported screen resolutions and a hexadecimal code for each screen resolution is listed. If you want to test a screen resolution to see how it works on your computer, just type in the hexadecimal code and press <Enter>.

Let’s say, the screen resolution you picked works and you would like to set it as the default screen resolution. To do that, you have to modify the GRUB configuration files on your computer.

Let’s say, the screen resolution you would like to set is 1024x768x32, which has the hexadecimal code 341. When you set it as the default on the GRUB configuration file, you have to change the hexadecimal code to an equivalent decimal code.

341 hexadecimal = 3 * 16^2 + 4 * 16^1 + 1 = 833

So, you have to add vga=833 kernel boot parameter on the GRUB configuration file.

 

First, open the GRUB configuration file with the following command:

$ sudo vi /etc/default/grub

Now, add vga=833 to the end of the GRUB_CMDLINE_LINUX as shown in the screenshot below. Once you’re done, save the file.

Now, update the GRUB configuration files with the following command:

$ sudo grub2-mkconfig -o $(sudo readlink -f /etc/grub2.cfg)

GRUB configuration files should be updated. Now, the next time you boot, the new screen resolution should be applied.

Now, reboot your computer with the following command for the changes to take effect:

$ reboot

Changing Screen Resolution Using gfxpayload:

On newer version of GRUB, the screen resolution is set using gfxpayload. So, the vga parameter may not work correctly. If it is the case for you, then this section is for you. It’s also easy to set screen resolution using this method than the traditional method.

First, press c from the GRUB menu to go to the GRUB command prompt.

You should be in the GRUB command prompt.

Now, run the following command to enable the pager module.

grub> set pager=1

Now, to find the supported screen resolution on your computer, run the following command:

grub> vbeinfo

As you can see, all the supported screen resolutions are displayed. The output is very long, so, it uses the pager. You can press <Enter> to navigate forward and see whether the screen resolution you’re looking for is supported.

As you can see, more screen resolutions are displayed. Here, you don’t have to remember any codes. Just remember the screen resolution. For example, if you want to set the screen resolution 1024x768x32, then this is what you have to put in the GRUB configuration file. Very simple.

In order to set the screen resolution, open the GRUB configuration file with the following command:

$ sudo nano /etc/default/grub

The configuration file should be opened. Now, add the line GRUB_GFXPAYLOAD_LINUX=1024x768x32 as shown in the screenshot below. Once you’re done, save the file by pressing <Ctrl> + x followed by y and <Enter>.

Now, update the GRUB configuration files with the following command:

$ sudo update-grub2

The GRUB configuration files should be updated. The next time you start your computer, the new screen resolution should be applied.

Finally, reboot your computer with the following command for the changes to take effect:

$ sudo reboot

So, that’s how you set screen resolution using the kernel boot parameters on Linux. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Moodle [Part 3] – Setup trang quản trị Admin trên Moodle.

Mục lục : Đăng nhập vào admin site của Moodle Thiết lập thông báo – đăng ký site 1....
30/12/2020

How to Install Deepin Linux

Deepin is a Debian based Linux distribution. Deepin uses its own desktop environment which is really pretty. The desktop...
28/12/2020

OpenVAS Ubuntu Installation and Tutorial

OpenVAS is the open source version of Nessus, which emerged after Nessus became a closed source scanner. Nessus was among...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Tìm Hiểu Về Thuê Proxy US – Lợi Ích và Cách Sử Dụng Hiệu Quả
11/12/2024

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024