Get linux kernel config

Where can I get the 11.04 kernel .config file?

I’m using Maverick with the latest available kernels on kernel.org and building them myself. Until now I’ve been basing my configuration off the stock Maverick kernel and accepting the make oldconfig defaults. I’ve been doing this for 3 major releases now so I figure I’m starting to slip behind the current «standard». I would like to re-base my kernels off the new Natty .config file. Is this available somewhere online or do I have to download the whole kernel package and extract it? Edit: I’ve manually pulled in the config from the latest Natty kernel package and I can confirm that I propbably should have done this sooner. A lot of differences between my old «evolved» config and the Natty default. Now if I could just do this without 20 minutes of hunting and downloading the package so I can re-base in the future.

4 Answers 4

Each linux-image package contains the exact configuration file that it was built with in /boot/config-* . To see the configuration file for the currently running Linux kernel, do:

I have checked with the Ubuntu kernel people (on Freenode #ubuntu-kernel ) and they have confirmed my belief that there isn’t really «the config», but it is actually constructed at build/compile time by including a number of Kconfig files; these depend on the exact architecture and target (desktop/server/cloud). You should be able to read that (short) conversation at:

A list of that variety can be found using packages.ubuntu.com and the following search:

Hunting, around, it would appear that the .config is also included in the linux-headers-* packages. These are .deb files (which are simple .ar archives that will open with file-roller ) and only about 800 kB each. If you know the particular target, architecture and version you’re after, you can grab these straight from Launchpad or from the archive itself:

If you want to automate the whole process into one command, you could try the following; make sure you keep it all on one line!

Источник

How do I get the correct .config file for compiling the Linux kernel source specific to my hardware?

I tried using make defconfig to compile the kernel, but as expected, it failed to boot. I was wondering what .config file do kernel vendors like Canonical for Ubuntu use, that the kernel is able to boot right out-of-the-box. Of course, I am still a beginner and configuring the various parameters, is a little out of my league currently. Specifically,I am looking to load a basic «hello, world!» module to my running kernel 2.6.32.41. For that, I would need to compile kernels source against the same .config file that was used for the running kernel.

4 Answers 4

If your running kernel was compiled with the CONFIG_IKCONFIG_PROC option, you can get the config in /proc/config.gz :

$ zcat /proc/config.gz >my_config 

Copy my_config into your kernel build directory as .config and run make config to be prompted for configuration options that are absent from your config file (this will only happen if you are using a kernel source that is newer than your running kernel). You should then be able to compile a new kernel with the same features as your current one.

Читайте также:  Linux get cpu temp

Distros typically use their own kernel configuration, where most of the drivers are compiled as modules to be dynamically loaded when the corresponding hardware is requested. Also the kernel needs to be booted with relevant boot options (like the one specifying the root filesystem). Your defconfig kernel probably failed to boot because of that.

Does CONFIG_IKCONFIG_PROC increase the size of the too much or why distros do not have this by default?

I don’t know about getting the one that’s «correct for your hardware», but you can use the config that Ubuntu gives you by looking in /boot/ for a file starting with the name config . There may be more than one, in which case use the command uname -r to tell which kernel you’re currently running, and then you can use the appropriate config.

source code of your booted system

cd /usr/src/linux-headers-3.2.0-29; 

this will generate .config

sudo make oldconfig; vi .config 
zcat /proc/config.gz > my_config 
echo /boot/config* > my_config 

«defconfig» is usually pegged at the commonly used hardware — x86, or x86_64, and perhaps not so recent chipset or motherboard. Sometimes, like my Lenovo laptop, only the latest kernel source, and with enabling some config option, after googling through the bugzilla database, will it work.

Like what Jeff Welling said, to get the config in use, u can look under /boot directory. Same for my Fedora Core too. But if u want to compile a basic program as a «kernel module», and by that it simply means «loadable kernel module», u don’t need to compile the kernel source. U just need the kernel headers for that current version. For example, «apt-cache search» in Ubuntu 10.04 returns several possible option:

linux-headers-2.6.38 - Header files related to Linux kernel, specifically, linux-libc-dev - Linux Kernel Headers for development 

Ubuntu normally patched the stock kernel (from kernel.org) to have their own kernel. If u have downloaded the stock kernel, and attempt to use the /boot’s config file (or sometimes u can find the currently loaded config as /proc/config.gz, like the Backtrack’s Ubuntu, which is based on 10.04 LTS), then u may need to do a «make oldconfig» with the current config file named as «.config». «make oldconfig» will then use the .config to generate a new .config that is compatible with the kernel source.

Источник

View Current Kernel Configuration¶

Be cautious if examining the files mentioned here, altering them can change the behavior of the actual running kernel!

These two interfaces allow you to view and change the parameters of the currently running kernel.

Note that if you do an ls -l on some of these files, they will show as «0» length, but if you cat them out they actually contain data. Most of them are ASCII and editable, however some are binary. In either case commands like file or stat will typically just return «empty file» or «0» for lengths, although they will show you other information.

Читайте также:  Linux консоль постраничный вывод

The preferred and standard programs for interacting with these functions are lsmod , modinfo , and sysctl , among others.

See what your currently running «kernel release» version is with:

uname -r and substitute its return value in commands by using $(uname -r)

RHEL and derivative distributions (Fedora, CentOS Stream, Scientific Linux, RockyLinux, AlmaLinux, et. al.) also store the configuration used for bootable installed kernels in the /boot directory used by Grub2 as ASCII files:

To check the currently running kernel configuration for a particular value:

cat /boot/config-$(uname -r) | grep -i
  • «=m» if compiled in as a kernel module
  • «=y» if compiled statically into the kernel
  • «is not set» if that setting was commented out
  • a numeric value
  • a quoted string value

Some distributions, like Gentoo and Arch, use the configs kernel module to provide /proc/config.gz by default instead:

zcat /proc/config.gz | grep -i zgrep /proc/config.gz 

For any distribution, if your running kernel has set both CONFIG_IKCONFIG and CONFIG_IKCONFIG_PROC and if

exists and is executable (searchable in the case of a dir) then you can create /proc/config.gz with this command if it is not present:

This document does not currently cover kernel packages that might have come from non-default repos such as:

appstream-debug, appstream-source, baseos-debug, baseos-source, or devel

The kernel-devel packages install the config file used to compile each installed standard kernel package as an ASCII file in the following location:

This file is more commonly accessed by a symlinked path provided by the kernel-core packages:

/lib/modules//build/ -> /usr/src/kernels// 

If you have kernel-debug-devel packages installed, you will also have this directory:

You can look in any of the following for details on the config values used to build an installed kernel:

/lib/modules//config /lib/modules//build/.config /usr/src/kernels//.config /usr/src/kernels/+debug/.config 

Configured modules for the currently running kernel, whether compiled as builtin (i.e., statically into the kernel itself) or a loadable module, are listed by sub directories named as the module name in:

For each installed kernel-release you can examine these files to see what values were compiled into that kernel, and what version of GCC was used to compile it:

cat /lib/modules/$(uname -r)/config | grep -i
cat /lib/modules/$(uname -r)/build/.config | grep -i
cat /usr/src/kernels/$(uname -r)/.config | grep -i
cat /usr/src/kernels/$(uname -r)+debug/.config | grep -i

You can check for kernel module dependencies in the file:

but it is easier to read or parse the output of the «Used-by» field in lsmod .

Reference:¶

Contributors: Steven Spencer

Источник

How to get the .config from a linux kernel image?

In Linux, the .config file is a configuration file that is used to build the Linux kernel. The .config file is used to specify which features and drivers should be included in the kernel image, as well as to set various configuration options. If you have a Linux kernel image and you want to get the .config file that was used to build it, there are several methods you can use to do this.

Читайте также:  Узнать свой ip через командную строку linux

Method 1: Use the ‘modinfo’ Command

To get the .config from a Linux kernel image using the ‘modinfo’ command, follow these steps:

  1. Open the terminal and navigate to the directory where the Linux kernel image is located.
  2. Use the ‘modinfo’ command to get the path of the kernel module. For example:
$ modinfo ./vmlinuz-5.4.0-42-generic
filename: ./vmlinuz-5.4.0-42-generic
$ sudo scripts/extract-ikconfig ./vmlinuz-5.4.0-42-generic > config-5.4.0-42-generic
$ ls -l config-5.4.0-42-generic -rw-r--r-- 1 root root 189603 Jul 26 16:02 config-5.4.0-42-generic

This will extract the .config from the kernel image and save it to a file called ‘config-5.4.0-42-generic’ in the current directory.

This will display the contents of the .config file, which should contain the kernel configuration options.

That’s it! You have successfully extracted the .config from a Linux kernel image using the ‘modinfo’ command.

Method 2: Extract the .config from a Running Kernel

To extract the .config from a running Linux kernel, follow these steps:

sudo apt-get update sudo apt-get install linux-source
tar xvf /usr/src/linux-source-$(uname -r).tar.bz2 cd linux-source-$(uname -r)
cp /boot/config-$(uname -r) .config
sudo apt-get install build-essential

Note: The above steps assume that you are running a Debian-based distribution of Linux.

You can also use the zcat command to extract the .config file from the /proc/config.gz file:

zcat /proc/config.gz > .config

This will extract the .config file from the running kernel and save it to the current directory.

Another way to extract the .config file is to use the modprobe command:

sudo modprobe configs sudo cat /proc/config.gz > .config

This will load the configs module and extract the .config file from the running kernel.

Method 3: Extract the .config from a Compressed Kernel Image

To extract the .config file from a compressed Linux kernel image, you can use the extract-ikconfig script. This script is included in the kernel source code and can be found in the scripts directory.

Here are the steps to extract the .config file:

  1. Download the compressed kernel image that you want to extract the .config file from.
  2. Extract the compressed kernel image using the appropriate tool. For example, if the kernel image is compressed with gzip, you can use the following command:
$ scripts/extract-ikconfig kernel-image > kernel-config

This will output the contents of the .config file to the kernel-config file.

Here is an example of using these commands:

$ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.7.tar.xz $ tar -xvf linux-5.10.7.tar.xz $ cd linux-5.10.7 $ gzip -d < arch/x86/boot/bzImage >kernel-image $ scripts/extract-ikconfig kernel-image > kernel-config

This will extract the .config file from the compressed kernel image arch/x86/boot/bzImage and save it to the kernel-config file.

Note that the extract-ikconfig script requires that the kernel image was compiled with the CONFIG_IKCONFIG option enabled. If this option was not enabled, the script will not be able to extract the .config file.

Also, the extract-ikconfig script can only extract the .config file from uncompressed or compressed kernel images that use the gzip or bzip2 compression formats. If the kernel image uses a different compression format, you will need to use a different tool to extract the .config file.

Источник

Оцените статью
Adblock
detector