Hack 9. Graphics on the Console
Some of you might be familiar with a picture of Tux the penguin in the upper-left corner of the screen when your system is booting. Ever since kernel 2.2, this popular feature has graced many a Linux boot sequence. To the untrained eye, it simply looks like a penguin, but to the trained technical eye, it is a cunning use of the Linux frame buffer. A frame buffer is an abstraction for graphics hardware. This abstraction provides a common set of instructions that programs can use to access the graphics hardware on the computer. Most people see the frame buffer as a grinning Tux when the system boots. However, there's more to the frame buffer than a cartoon penguin. Typically, frame buffers are used to render the console graphically so that a resolution can be set on it. Frame buffers are useful in a number of situations, some of which include the following:
1.10.1. Setting Up the KernelSupport for the frame buffer comes from the kernel itself. Most stock kernels are supplied with frame-buffer support built into them, so this shouldn't be a problem for most people. To check if your kernel has support already, you can query it: foo@bar:~$ grep -i config_fb /boot/config-$(uname -r) CONFIG_FB=y If you have frame buffers set, the line CONFIG_FB=y will be displayed (in which case you can move on to the next section "Configuring the Bootloader"). If # CONFIG_FB is not set is displayed instead, you will need to compile support for the frame buffer into your kernel. 1.10.2. Configuring the KernelDetails on compiling a kernel are discussed in [Hack #88], and in this hack, I will simply discuss which options need to be included. The first thing to do is to make sure development features have been enabled within the "Code maturity level" options. Then, to enable frame buffers, go to the "Console drivers" page and enable "VGA text console" and "Video mode selection" support. There is a subsection under Console called "Frame-buffer support." Underneath that, you need to enable "Support for frame buffer devices," "VESA VGA graphics console," and "VGA 16-color graphics console." In addition, the subsection "Advanced low level driver options" appears under "Frame-buffer support." Under this menu, you can enable specific levels of pixel support. Now you can go ahead and compile the kernel.
1.10.3. Configuring the BootloaderWhen the bootloader loads the kernel, it will pass to it the parameters which you specify and these parameters affect how you use the frame buffer. Just like you would normally tell it which partition is your root partition, you can do the same thing by telling the kernel the values you want to use for the frame buffer. When using the frame buffer, people commonly require a higher resolution for the command-line console. To set this option, you will need to pass to the kernel the right video mode to use to enable the frame buffer. Refer to Table 1-1 to determine the code to use for your desired video mode. When you have determined the correct video mode to use, you can pass the kernel the vga parameter to set the mode. 1.10.3.1 Configure LILOTo configure LILO to use a value from the table (as an example, 1024x768 with 16-bit color), edit /etc/lilo.conf and find the following line: vga=normal Change this to the mode you want, which in this example is 0x317: vga=0x317 Finally, save the file, and as root run /sbin/lilo -v. 1.10.3.2 Configure GRUBYou configure GRUB in much the same way you configure LILO. The configuration file varies from distribution to distribution, and this is discussed in [Hack #1]. Edit your grub configuration file and add the vga parameter on the kernel line: title foo root (hd0,0) kernel /vmlinuz ro root=/dev/hda2 vga=0x317 Thomas Adam ![]() |