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

Hướng dẫn cấu hình nginx với ssl làm reverse proxy cho graylog

Gray log là 1 công cụ mạnh mẽ để quản lý và phân tích các tệp nhật ký, ở các bài trước mình...
30/12/2020

How to Install and Use Dropbox on OpenSUSE

Dropbox is definitely one of the top online storage solutions for storing and sharing photos, documents, spreadsheets,...
29/12/2020

How to Use Manjaro Hardware Detection Tool

Manjaro is based on the well-known Arch Linux. Among all the facilities, Manjaro Hardware Detection Tool is a unique one....
29/12/2020
Bài Viết

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

Dịch vụ thuê mua proxy US UK uy tín, chất lượng số #1
13/05/2024

Thuê mua proxy Việt Nam: Báo giá & các thông tin MỚI NHẤT
13/05/2024

Dịch vụ thuê mua proxy giá rẻ an toàn, tốc độ cao
13/05/2024

Thuê mua proxy V6 uy tín, chất lượng tại đâu?
11/05/2024

Thuê mua proxy Tiktok tăng doanh thu, hiệu quả cao
11/05/2024