linux内核启动配置文件
The Linux kernel has a generic driver for a graphic framebuffer named vesafb on intel boxes. It provides a nice large console for most of modern displays.
Linux内核在intel盒上有一个通用驱动程序,用于名为vesafb的图形帧缓冲区。 它为大多数现代显示器提供了一个不错的大型控制台。
Setting VESA modes for Linux kernel with 32-bit and 16-bit boot protocol are different. We introduce both methods here.
使用32位和16位启动协议为Linux内核设置VESA模式是不同的。 我们在这里介绍两种方法。
具有32位启动协议的Linux内核 (Linux kernel with 32-bit boot protocol)
For machine with some new BIOS other than legacy BIOS, such as EFI, LinuxBIOS, etc, and kexec, the 16-bit real mode setup code in kernel based on legacy BIOS can not be used, so a 32-bit boot protocol needs to be defined.
对于具有旧版BIOS以外的某些新BIOS(例如EFI,LinuxBIOS等)和kexec的计算机,不能使用基于旧版BIOS的内核中的16位实模式设置代码,因此需要使用32位启动协议被定义。
– from THE LINUX/x86 BOOT PROTOCOL
The modes can be set by adding ‘video=…’ to the kernel boot parameter.
可以通过在内核引导参数中添加“ video =…”来设置模式。
The syntax is like this (ref: Kernel Mode-setting):
语法是这样的(参考: 内核模式设置 ):
video=<conn>:<xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
For Grub2, this can be added by 2 steps.
对于Grub2 ,可以通过2个步骤将其添加。
Edit ‘/etc/default/grub’ and edit the line for ‘GRUB_CMDLINE_LINUX’. For example, to set the video mode to 1024×800 with 32-bit color depth:
编辑'/ etc / default / grub'并编辑'GRUB_CMDLINE_LINUX'的行。 例如,将视频模式设置为具有32位色深的1024×800:
GRUB_CMDLINE_LINUX="rd.md=0 rd.lvm=0 rd.dm=0 KEYTABLE=us rd.luks=0 LANG=en_US.UTF-8 video=1024x800-32"
After editing the file, generate the new configuration file for grub2 following How to Regenerate Grub2 Config Files on Linux.
编辑文件后,请按照如何在Linux上重新生成Grub2配置文件生成用于grub2的新配置文件。
Add to ‘/etc/default/grub’:
添加到'/ etc / default / grub'中:
GRUB_GFXMODE=1024x800x32
GRUB_GFXPAYLOAD_LINUX=keep
GRUB_TERMINAL=gfxterm
Then, make the new Grub2 config file following How to Regenerate Grub2 Config Files on Linux
然后,按照如何在Linux上重新生成Grub2配置文件 ,制作新的Grub2配置文件。
具有16位启动协议的Linux内核 (Linux kernel with 16-bit boot protocol)
Switching VESA modes of Linux kernel at boot time can be done by using the “vga=…“ kernel boot parameter. This parameter accept the decimal value of Linux video mode numbers instead of VESA video mode numbers. The Linux video mode number can be easily derived from the VESA number.
可以在启动时切换Linux内核的VESA模式,方法是使用“ vga =… ”内核启动参数。 此参数接受Linux视频模式编号的十进制值 ,而不是VESA视频模式编号。 可以从VESA编号轻松得出Linux视频模式编号。
The video mode number of the Linux kernel is the VESA mode number plus 0×200.
Linux内核的视频模式编号是VESA模式编号加0×200。
Linux_kernel_mode_number = VESA_mode_number + 0x200
Here are some of the VESA mode numbers:
以下是一些VESA模式编号:
| 640x480 800x600 1024x768 1280x1024
----+-------------------------------------
256 | 0x101 0x103 0x105 0x107
32k | 0x110 0x113 0x116 0x119
64k | 0x111 0x114 0x117 0x11A
16M | 0x112 0x115 0x118 0x11B
So the table for the Kernel mode numbers are:
因此,内核模式编号表为:
| 640x480 800x600 1024x768 1280x1024
----+-------------------------------------
256 | 0x301 0x303 0x305 0x307
32k | 0x310 0x313 0x316 0x319
64k | 0x311 0x314 0x317 0x31A
16M | 0x312 0x315 0x318 0x31B
The decimal value of the Linux kernel video mode number can be passed to the kernel in the form “vga=YYY“, where YYY is the decimal value.
Linux内核视频模式编号的十进制值可以以“ vga = YYY ”的形式传递给内核,其中YYY是十进制值。
Update: vga=ask
is not supported by GRUB2. Use the new method as follows to find out supported video modes. The method is credited to suggested by Sebastian.
更新 :GRUB2不支持vga=ask
。 使用以下新方法找出支持的视频模式。 该方法由Sebastian建议使用 。
Just edit a GRUB menu entry when booting, remove everything and enter “vbeinfo” and Ctrl+x to execute it. The VESA modes output looks like this:
只需在启动时编辑GRUB菜单项,删除所有内容并输入“ vbeinfo”和Ctrl + x即可执行。 VESA模式输出如下所示:
VBE info: version: 2.0 OEM software rev 1.0
total memory: 4096 KiB
List of compatible video modes:
Legend: P=Packed pixel, D=Direct color, mask/pos=R/G/B/reserved
0x101: 640 x 480 x 8 Packed
0x110: 640 x 480 x 15 Direct, mask: 5/5/5/1 pos: 10/5/0/15
...
Configured VBE mode (vbe_mode) = 0x101
Press any key to continue ...
Press a key and Esc and you’re back in the boot menu.
按一个键和Esc键,您又回到了引导菜单。
Instead of the YYY decimal value, the “vga” parameter also accept “ask” which will list all the Linux kernel mode numbers and let the user select one. You can used it if you want to be asked every time booting Linux. It can also be used to find the best Linux video mode on your console.
代替YYY十进制值,“ vga ”参数还接受“ ask” ,它将列出所有Linux内核模式编号,并让用户选择一个。 如果您希望每次引导Linux时都被询问,可以使用它。 它也可以用来在控制台上找到最佳的Linux视频模式。
The best way for configuring the “vga=YYY” parameter is following these steps.
按照以下步骤配置“ vga = YYY”参数的最佳方法。
First, add “vga=ask” parameter to the Linux kernel entry in grub configuration file /boot/grub/grub.conf. Like this:
首先,在grub配置文件/boot/grub/grub.conf中的Linux内核条目中添加“ vga = ask”参数。 像这样:
kernel /vmlinuz-2.6.32.16-141.fc12.i686 ro root=/dev/mapper/VolGroup-LogVol00 vga=ask
内核/vmlinuz-2.6.32.16-141.fc12.i686 ro root = / dev / mapper / VolGroup-LogVol00 vga = ask
Second, reboot Linux and hit return when the kernel ask for the vga mode. Then select one mode from the list and remember the Linux mode number which is a hexdecimal value in the format YYY. You can also get more choice by entering “scan“.
其次,重启Linux并在内核要求使用vga模式时按回车键。 然后从列表中选择一种模式,并记住Linux模式号,它是YYY格式的十六进制值。 您还可以通过输入“ scan ”获得更多选择。
Last, calculate the decimal value of the Linux video mode number. This simple python command can be used:
最后,计算Linux视频模式编号的十进制值。 可以使用以下简单的python命令:
python -c "print 0xYYY"
YYY is the hexdecimal value you got.
YYY是您获得的十六进制值。
Then change “ask” in grub configuration file to the decimal value calculated.
然后将grub配置文件中的“ ask ”更改为计算出的十进制值。
Here is a list of usually used Linux mode number and the decimal value if you like to choose one directly:
如果您想直接选择一个Linux模式号和十进制值,则这是它们的列表:
320×200 | 640×400 | 640×480 | 800×500 | 800×600 | 896×672 | 1024×640 | 1024×768 | 1280×1024 | |
4 bits | 770 (302) | 774 (306) | |||||||
8 bits | 768 (300) | 769 (301) | 879 (36F) | 701 (303) | 815 (32F) | 874 (36A) | 773 (305) | 775 (307) | |
15 bits | 781 (30D) | 801 (321) | 784 (310) | 880 (370) | 787 (313) | 816 (330) | 875 (36B) | 790 (316) | 793 (319) |
16 bits | 782 (30E) | 802 (322) | 785 (311) | 881 (371) | 788 (314) | 817 (331) | 876 (36C) | 791 (317) | 794 (31A) |
24 bits | 783 (30F) | 803 (323) | 786 (312) | 882 (372) | 789 (315) | 818 (332) | 877 (36D) | 792 (318) | 795 (31B) |
32 bits | 804 (324) | 809 (329) | 883 (373) | 814 (32E) | 819 (333) | 878 (36E) | 824 (338) | 829 (33D) |
| 320×200 | 640×400 | 640×480 | 800×500 | 800×600 | 896×672 | 1024×640 | 1024×768 | 1280×1024 |
4位 | 770(302) | 774(306) | |||||||
8位 | 768(300) | 769(301) | 879(36F) | 701(303) | 815(32F) | 874(36A) | 773(305) | 775(307) | |
15位 | 781(30天) | 801(321) | 784(310) | 880(370) | 787(313) | 816(330) | 875(36B) | 790(316) | 793(319) |
16位 | 782(30E) | 802(322) | 785(311) | 881(371) | 788(314) | 817(331) | 876(36℃) | 791(317) | 794(31A) |
24位 | 783(30F) | 803(323) | 786(312) | 882(372) | 789(315) | 818(332) | 877(36D) | 792(318) | 795(31B) |
32位 | 804(324) | 809(329) | 883(373) | 814(32E) | 819(333) | 878(36E) | 824(338) | 829(33D) |
Update on Apr. 29, 2015: add vbeinfo
method suggested by Sebastian; suggest grub2-regen-cfg.bash
for regenerating Grub2 config file instead of the manual way.
2015年4月29日更新:添加了Sebastian建议的vbeinfo
方法; 建议使用grub2-regen-cfg.bash
来重新生成Grub2配置文件,而不是手动方式。
翻译自: https://www.systutorials.com/configuration-of-linux-kernel-video-mode/
linux内核启动配置文件