The Linux Kernel: Configuring the Kernel (Part 1)

D

DevynCJohnson

Guest
Series Index - http://www.linux.org/threads/linux-kernel-reading-guide.5384/

Now that we understand the Linux kernel, we can move on to the main event - configuring and compiling the code. Configuring code for the kernel does take a lot of time. The configuration tool asks many questions and allows developers to configure every aspect of the kernel. If unsure about any question or feature, it is best to pick the default value provided by the configuration tool. This tutorial series will walk readers through the whole process of configuring the kernel.

To configure the code, open a terminal in the main source code folder. Once a terminal is up, there are a few ways to configure the code based on the preferred configuration interface.

make config - Plain text interface (most commonly used choice)

make menuconfig - Text-based with colored menus and radiolists. This options allows developers to save their progress. ncurses must be installed (sudo apt-get install libncurses5-dev).

make nconfig - Text-based colored menus - curses (libcdk5-dev) must be installed

make xconfig - QT/X-windows interface – QT is required

make gconfig - Gtk/X-windows interface – GTK is required

make oldconfig - Plain-text interface that updates a config file (that may have been copied from another system) to be compatible with the newer kernel source code.

make silentoldconfig - This is the same as oldconfig except the questions answered by the config file will not be shown

make olddefconfig - This is like silentoldconfig except some questions are answered by their defaults

make defconfig - This option creates a config file that uses default settings based on the current system's architecture.

make ${PLATFORM}_defconfig - Creates a config file using values from arch/$ARCH/configs/${PLATFORM}_defconfig.

make allyesconfig - This option creates a config file that will answer yes to as many questions as possible.

make allmodconfig - This option creates a config file that will make as many parts of the kernel a module as possible

NOTE: Code in the Linux kernel can be put in the kernel itself or made as a module. For instance, users can add Bluetooth drivers as a module (separate from the kernel), add to the kernel itself, or not add at all. When code is added to the kernel itself, the kernel requires more RAM space and boot-up time may take longer. However, the kernel will perform better. If code is added as modules, the code will remain on the hard-drive until the code is needed. Then, the module is loaded to RAM. This will reduce the kernel's RAM usage and decrease boot time. However, the kernel's performance may suffer because the kernel and the modules will be spread throughout the RAM. The other choice is to not add some code. For illustration, a kernel developer may know that a system will never use Bluetooth devices. As a result, the drivers are not added to the kernel. This improves the kernel's performance. However, if users later need Bluetooth devices, they will need to install Bluetooth modules or update the whole kernel.

make allnoconfig - This option creates a config file that will only add essential code to the kernel; this answers no to as many questions as possible. This can sometimes make a kernel that does not work on the hardware it was compiled on.

make randconfig - This option makes random choices for the kernel
make localmodconfig - This option creates a config file based on the current list of loaded modules and system configuration.

make localyesconfig - This will set all module options to yes - most (or all) of the kernel will not be in modules

TIP: It is best to use “make menuconfig” because users can save their progress. “make config” does not offer this luxury. Because the configuration process takes a lot of time,

Configuration:

Most developers choose "make menuconfig" or one of the other graphical menus. After typing the desired command, the first question asks whether the kernel to be built is going to be a 64-bit kernel or not. The choices are "Y", "n", and "?". The question mark explains the question, "n" answers no to the question, and "Y" answers yes to the question. For this tutorial, I will choose yes. To do this I type "Y" (this is case-insensitive) and hit enter.

UPDATED NOTE: At first, I used "make config" as I wrote this series. I later used "make menuconfig" (ncurses). "make config" is linear, that is, each question is asked one after another while the ncurses interface is a branching menu. If you are using any of the configuration interfaces that use menus, start at the top of the first (main) menu and work your way down going into each menu and sub-menu. This will allow you to follow this series easily as you configure your own kernel.

NOTE: If the kernel is compiled on a 32-bit system, then the configuration tool would ask if the kernel should be 32-bit. The first question is different on other processors.

The next line shows "Cross-compiler tool prefix (CROSS_COMPILE) []". If you are not cross-compiling, hit enter. If you are cross-compiling, type something like "arm-unknown-linux-gnu-" for ARM systems or "x86_64-pc-linux-gnu-" for 64-bit PC systems. There are many other possible commands for other processor types, but the list can be quite large. Once a developer knows what processor they want to support, it is easy to research the command needed for that processor.

NOTE: Cross-compiling is compiling code to be used on other processors. For illustration, an Intel system that is cross-compiling code is making applications for processors other than Intel. So, this system may be compiling code for ARM or AMD processors.

NOTE: Each choice will change which questions come up and when they are displayed. I will include my choices so readers can follow the configuration process on their own system.

Next, users will see "Local version - append to kernel release (LOCALVERSION) []". This is where developers can give a special version number or name to their customized kernel. I will type "LinuxDotOrg". The kernel version is now “3.9.4-LinuxDotOrg”. Next, the configuration tool asks "Automatically append version information to the version string (LOCALVERSION_AUTO) [N/y/?]". If a git tree is found, the revision number will be appended. This example is not using git, so I will answer no. Other wise the git revision number will be appended to the version. Remember vmlinuz and similar files? Well, the next question asks which compression format should be used. The developer can choose one through five. The choices are

1. Gzip (KERNEL_GZIP)
2. Bzip2 (KERNEL_BZIP2)
3. LZMA (KERNEL_LZMA)
4. XZ (KERNEL_XZ)
5. LZO (KERNEL_LZO)

Gzip is the default, so I will press “1” and hit enter. Each compression format has greater or less compression ratios compared to the other formats. A better compression ratio means a smaller file, but more time is needed to uncompress the file while the opposite applies to lower compression ratios.

Now, this line is displayed - “Default hostname (DEFAULT_HOSTNAME) [(none)]”. The default hostname can be configured. Usually, developers leave this blank (I left it blank) so that Linux users can set up their own hostname.

Next, developers can enable or disable the use of swap space. Linux uses a separate partition called “swap space” to use as virtual memory. This is equivalent to Windows' paging file. Typically, developers answer yes for the line “Support for paging of anonymous memory (swap) (SWAP) [Y/n/?]”.

The next line (System V IPC (SYSVIPC) [Y/n/?]) asks if the kernel should support IPC. Inter Process Communication allows processes to communicate and sync. It is best to enable IPC, otherwise, many applications will not work. Answering yes to this question will cause the configuration tool to ask “POSIX Message Queues (POSIX_MQUEUE) [Y/n/?]”. This question will only be seen if IPC is enabled. POSIX message queues is a messaging queue (a form of interprocess communication) where each message is given a priority. The default choice is yes. Hit enter to choose the default choice (indicated by the capitalized choice).

The next question (open by fhandle syscalls (FHANDLE) [Y/n/?]) is asking if programs will be permitted to use file handles instead of filenames when performing filesystem operations if needed. By default, the answer is yes.

Sometimes, when a developer has made certain choices, some questions will automatically be answered. For instance, the next question (Auditing support (AUDIT) [Y/?]) is answered yes without prompting because previous choices require this feature. Auditing-support logs the accesses and modifications of all files. The next question relates to auditing (Enable system-call auditing support (AUDITSYSCALL) [Y/n/?]). If enabled, all system calls are logged. If the developer wants performance, then as much auditing features as possible should be disabled and not added to the kernel. Some developers may enable auditing for security monitoring. I will select “no” for this question. The next audit question (Make audit loginuid immutable (AUDIT_LOGINUID_IMMUTABLE) [N/y/?]) is asking if processes can change their loginuid (LOGIN User ID). If enabled, processes in userspace will not be able to change their own loginuids. For better performance, we will disable this feature.

NOTE: When configuring via “make config”, the questions that are answered by the configuration tool are displayed, but the user does not have a way to change the answer. When configuring via “make menuconfig”, the user cannot change the option no matter what button is pressed. Developers should not want to change options like that anyway because a previous choice requires another question to be answered a certain way.

In the next article, we can configure the IRQ subsystem and all of the following choices.
 

Attachments

  • slide.JPG
    slide.JPG
    177.1 KB · Views: 108,267
Last edited:


this guide is fantastic. please explain how to save config file in the middle of its process to be able continue rest of it in future.
 
Not all interfaces allow you to save the progress. Near the top of the article, you will see different make commands. "make menuconfig" is one that allows you to save your progress. The standard "make config" cannot save its progress.

Thank you for your interest in my article. I have written a whole series on the Linux kernel. Look for articles whose name begins with "The Linux Kernel: ". I am currently writing about the configuration process. This series is going to get more detailed. This series is far from over. There is a lot to configure in the Linux kernel.

If you have any suggestions for other topics, email me at [email protected], find me on Google+, contact me via Launchpad, or contact me through Linux.org.
 
Well, I'll be sure to read this through more thoroughly later, there's bound to be options not even I understand (although I am currently developing my own distro, the second one in my list (first was based on opensuse with a kernel upgrade and some specific configuration, the second one, still being built is made from scratch) and I already configured many kernels some options I've never touched because I never quite understood them)

Can't wait for part 2, never really researched the IRQ options ^^;
 
I will be getting in great depth, so watch the main page for the site for the next ones. I expect to have more than eight of these tutorials. I plan to be a thorough as possible. Keep reading and liking the series. If any questions arise, feel free to ask and I will clarify.
 
I will be getting in great depth, so watch the main page for the site for the next ones. I expect to have more than eight of these tutorials. I plan to be a thorough as possible. Keep reading and liking the series. If any questions arise, feel free to ask and I will clarify.
Well, truth is that the options I don't get I never bothered looking up (mostly due to lack of time) and the ones I get I mostly figured out using common sense and the comments on each entry in menuconfig.
 
Devyn,
Thanks for the series, I will be sure to check them all out as time permits.
Paul
 
I sure wish these resources were available back in the nineties. Linux was way more dificult then. Thank you for your fine work, I will be reading all in the coming days.
 
I sure wish these resources were available back in the nineties. Linux was way more dificult then. Thank you for your fine work, I will be reading all in the coming days.

Thanks for your compliments! Readers like you give me motivation to write more cool articles that you like to read. I release about one Linux kernel article a week. I also post one "random Linux topic" article per week. If you have any ideas for topics, feel free to let me know.
 
make localyesconfig - This will set all module options to yes - most of the kernel will be in modules
It actually does the opposite - it turns all LKMs to built in (it turns all incidences of 'm' to 'y' in kernel config).
 
It actually does the opposite - it turns all LKMs to built in (it turns all incidences of 'm' to 'y' in kernel config).

Thanks! I see that I do contradict myself by saying all modules will be set to "yes" and then in the same sentence say "most of the kernel will be in modules".
 
Absolutely outstanding article from a technical standpoint and from a standpoint of the content it is talking about. This is what I call an article that is worthy to be categorized as THE DOCUMENTATION BIBLE!!!
Thank You Sir.
Keep doing what you are doing and always look for a way to make it better and more efficient !!!!
 
Absolutely outstanding article from a technical standpoint and from a standpoint of the content it is talking about. This is what I call an article that is worthy to be categorized as THE DOCUMENTATION BIBLE!!!
Thank You Sir.
Keep doing what you are doing and always look for a way to make it better and more efficient !!!!

Thank you for the compliments! I love posters like you.

Feel free to give me any ideas on future topics for this series or other articles or topics in general. All three of the main authors on this site (me, Jarret Buse, and Eric Hansen) are open to ideas and suggestions. Enjoy the site!

I am thinking about starting a second article series on Python3 scripting. What do you think about that?
 
Thank you Sir,
As I said before, what you are doing, the way you are doing it is Great. Maybe one very small recommendation for an improvement of your articles would be to include some screenshots of the key steps during the course of the action you are doing. As you know , a single picture is bringing as much information as 100 words.
I don't know what your interests are therefore my ideas might not be necessary the ideas of you guys and the ideology of the web site.
I would be interesting to see articles related to architectural, design and implementation of SOA technologies with all the SOA related layers, databases, IPv6 etc. Python and Ruby would be interesting as well. There are some other ideas I have in my mind which could be interesting.
 
Thank you Sir,
As I said before, what you are doing, the way you are doing it is Great. Maybe one very small recommendation for an improvement of your articles would be to include some screenshots of the key steps during the course of the action you are doing. As you know , a single picture is bringing as much information as 100 words.
I don't know what your interests are therefore my ideas might not be necessary the ideas of you guys and the ideology of the web site.
I would be interesting to see articles related to architectural, design and implementation of SOA technologies with all the SOA related layers, databases, IPv6 etc. Python and Ruby would be interesting as well. There are some other ideas I have in my mind which could be interesting.


Thanks for the suggestions. I will do what I can. I will include more screenshots in my future articles. Thanks!

I am currently working on a Python3 tutorial (I will release it in a week or two). If I see that enough people enjoyed it, then I will write a whole tutorial series.

Last I knew, one of the authors plan to write an article on IPv6. I do not know when he will write and release it.

Later, I will create a thread for people to post article topic requests for the authors.
 
Hello,

Maybe you should also explain shortly how ncurses can be installed. For Ubuntu it is:
sudo apt-get install libncurses5-dev
The name "libncurses5-dev" is not self-explanatory, so you should mention it I think.
(or maybe there is a better way after all, I just googled it now)

Other than that, great article :)
 
Hello,

Maybe you should also explain shortly how ncurses can be installed. For Ubuntu it is:
sudo apt-get install libncurses5-dev
The name "libncurses5-dev" is not self-explanatory, so you should mention it I think.
(or maybe there is a better way after all, I just googled it now)

Other than that, great article :)

libncurses5-dev -
  • lib - LIBrary
  • ncurses - the terminal-based GUI
  • 5 - version
  • dev - for developers (contains headers, links, etc.)
Thanks for the compliment.
 
make gconfig never works on ubuntu 12.04 LTS whatever I do. Has anyone tried it?
I have also asked a question Trouble using `make gconfig` in ubuntu linux in 'Unix and Linux' on StackExchange website with details of my problem. No working answers so far :(
 

Members online


Top