Configuring Gentoo Kernel for VMware Player – Overview

Written: 11/03/13

Last Updated: 11/16/13

This techtorial is the fourth article in my installing Gentoo in VMware Player series. This article will give an overview of the Linux kernel. In addition to this article, three more articles were written to cover various kernel configurations: a minimal manual configuration, an optimized manual configuration, and a fully automated configuration. This article and those three will explain how to configure the kernel, and will cover chapter seven of the Gentoo handbook. If you are just now coming to this series, start with my first article.

Introduction

Before configuring a kernel, it is important that you have some basic knowledge about what the kernel actually is. Simply put, the kernel is a layer than allows the software to communicate with the hardware. This means that if you have particular hardware that you would like to use, you must include support for it in the kernel.

When configuring the kernel, you have three options for each component – built-in, module, and not included. If you have a particular feature built-in to the kernel, the required code will be included inside of the kernel image. This means that when your system needs to use that component, the kernel can automatically initialize and load it, without any user input. The advantage of this is that the feature is always ready to be used and requires no input; the downside is that because it is loaded, it will result in a larger kernel file, greater memory consumption, and a reduction of flexibility.

A module component is built outside of the kernel image into a kernel module file. Modules must be loaded before they can be used. Modules have the advantage of allowing the user to enable and disable core, low-level system functionality without needing to reboot. In the efforts of getting a slim kernel and a flexible system, it is generally preferred to use modules over built-in features. If you are using a system that has static hardware and features, like embedded systems, then you are better off using built-in features, as everything is already pre-determined.

In Gentoo you have two options for building your kernel, you may either do it manually, where you go and specify exactly what you want in the kernel, or you may use the genkernel tool which will automatically build things for you. In the efforts of completeness, I will cover both methods. I personally recommend the manual configuration, as it gives you way more control over what will be included in your kernel and it reduces compilation time, memory utilization, storage space, etc…. If this proves to be too intimidating, you may use genkernel, at any time, and you will still be able to continue with your Gentoo setup.

Generic Kernel Initializations

Regardless of whether you are going to be building your kernel manually or not, there a couple of steps that must occur before the kernel configuration. We first need to emerge the kernel source.

emerge gentoo-sources

Gentoo - Kernel Overview - 1

You should now have the latest 64 bit Gentoo kernel. To determine which version was obtained, we will check the symlink. From the screenshot, you will notice that my kernel version is 3.10.7. Your version may be different, so keep that in mind. I also want to point out that when we initially built the VM we told VMware Player to use Linux 2.6.x. This really is not important, and as long as we configure the kernel to work with the hardware, all will be well.

ls -l /usr/src/linux

Gentoo - Kernel Overview - 2

You should now decide whether you want to configure things manually or whether you want to use genkernel. If you are using genkernel, you may go ahead and skip to that article, here; otherwise, continue with the next section of this article.

Manual Kernel Initializations

Before we configure the kernel, it is a good idea to gather some information about the system. We can use lscpi and lsusb to identify a lot of the hardware. Go ahead and emerge both of those tools.

emerge sys-apps/pciutils sys-apps/usbutils

Gentoo - Kernel Overview - 3

Now run lspci to look for hardware. You can see a lot of the VMware components. Those components should be the same between my system and yours. Many of the other components may differ, so keep this in mind when following my kernel configurations.

lspci

Gentoo - Kernel Overview - 4

Running lsusb will show us all of the USB components that are connected to the system.

lsusb

Gentoo - Kernel Overview - 5

Another thing you can do to help determine what features might be needed is by running lsmod. This will show all modules that the live CD is using. We will not need a lot of these, but the output may still prove useful.

lsmod | less

Gentoo - Kernel Overview - 6

If you do not know what type of CPU you have in your system, then you will need to figure that out. You can do this by reading “/proc/cpuinfo”. As shown, I have an Intel Core i7 930, as denoted by the model name. You can use this info to help you research info that you will need for future kernel configuration settings.

cat /proc/cpuinfo

Gentoo - Kernel Overview - 7

My preferred method for manually configuring the kernel is the menuconfig option of make. This tool gives us an ncurses-based configuration menu. To navigate through the menu, use the arrow keys. To enter a sub menu, select the menu and press “Enter”. To exit a sub menu, press the “Esc” key twice. To obtain a description of an option, press “H”. To search for modules by keywords, use “/”.

I previously mentioned that all components may either be built-in, module, or not included. The notation utilized is asterisk, “*”, for built-in, “M” for module, and null, ” “, for not included. To change the state of an option use “Y” to make an option built-in, “N” to exclude an item (spacebar can be used to toggle between states), and “M” to make it a module. If the option is in square brackets, “[ ]”, it can only be built-in or excluded. If the option is in angle brackets, “< >“, it may be built-in, module, or excluded. If the option is in curly brackets, “{ }”, it can only be built-in or module. If the option is in hyphens, “- -“, then it is required by a previous option and may not be altered, unless all of the parent options (the options that require the current option) are removed.

Now we need to change our directory to where our source is, and then we can begin configuring the kernel.

cd /usr/src/linux
make menuconfig

Gentoo - Kernel Overview - 8

When the menu loads, it should look something like the following image:
Gentoo - Kernel Overview - 9

As stated earlier, I am going to split the manual kernel configuration into two sections. The first section will cover all of the core components that must be configured to have a proper system setup. These will include both VMware Player specific settings as well as general settings that any system requires.

The second section will cover kernel optimizations. For the kernel optimizations, I walk you through the process of building an extremely stripped down kernel. That kernel is the one that I am currently using. As that process is lengthy, for most of the options, I will not explain why I am not including it in the kernel. If you wish to have more information, then read the help information about the item; otherwise, you will just have to trust me 😉

Select your desired kernel configuration: basic or optimized.

Leave a Reply