<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.linuxquestions.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Picobyte</id>
	<title>LQWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.linuxquestions.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Picobyte"/>
	<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/wiki/Special:Contributions/Picobyte"/>
	<updated>2026-04-22T10:46:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.0</generator>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Git&amp;diff=41640</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Git&amp;diff=41640"/>
		<updated>2008-09-19T13:29:41Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Git is a [[revision control]] originally designed for the Linux [[kernel]]. Git was eventually also used for other large open source projects. Git was originally written by Linus Torvalds and is currently maintained by Junio C Hamano.&lt;br /&gt;
&lt;br /&gt;
==Obtaining Git==&lt;br /&gt;
Your distibution may provide a precompiled package of git. Daily snapshots of the main Git development branch are also available from http://www.codemonkey.org.uk/projects/git-snapshots/git/&lt;br /&gt;
&lt;br /&gt;
After this initial installation, it is possible to get git using git:&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
git clone git://git.kernel.org/pub/scm/git/git.git&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you get this error (on Slackware):&lt;br /&gt;
 /bin/sh: docbook2x-texi: command not found&lt;br /&gt;
&lt;br /&gt;
You may want to issue as root:&lt;br /&gt;
 ln -sf /usr/bin/docbook2texi /usr/bin/docbook2x-texi&lt;br /&gt;
&lt;br /&gt;
==See also== &lt;br /&gt;
[[using git]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Git&amp;diff=41639</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Git&amp;diff=41639"/>
		<updated>2008-09-19T13:28:59Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Git is a [[revision control]] originally designed for the Linux [[kernel]]. Git was eventually also used for other large open source projects. Git was originally written by Linus Torvalds and is currently maintained by Junio C Hamano.&lt;br /&gt;
&lt;br /&gt;
==Obtaining Git==&lt;br /&gt;
Your distibution may provide a precompiled package of git. Daily snapshots of the main Git development branch are also available from http://www.codemonkey.org.uk/projects/git-snapshots/git/&lt;br /&gt;
&lt;br /&gt;
After this initial installation, it is possible to get git using git:&lt;br /&gt;
&amp;lt;tt&amp;gt;&amp;lt;CODE&amp;gt;&amp;lt;PRE&amp;gt;&lt;br /&gt;
git clone git://git.kernel.org/pub/scm/git/git.git&lt;br /&gt;
&amp;lt;/PRE&amp;gt;&amp;lt;/CODE&amp;gt;&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
if you get thi error:&lt;br /&gt;
 /bin/sh: docbook2x-texi: command not found&lt;br /&gt;
&lt;br /&gt;
You may want to issue as root:&lt;br /&gt;
 ln -sf /usr/bin/docbook2texi /usr/bin/docbook2x-texi&lt;br /&gt;
&lt;br /&gt;
==See also== &lt;br /&gt;
[[using git]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41638</id>
		<title>Sparse</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41638"/>
		<updated>2008-09-19T13:24:44Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==SPARSE==&lt;br /&gt;
===What is it:===&lt;br /&gt;
A Semantic Parser for C, can for instance be used to test the linux kernel compilation.&lt;br /&gt;
&lt;br /&gt;
===how to get it:===&lt;br /&gt;
see http://www.kernel.org/pub/software/devel/sparse/&lt;br /&gt;
you can also get it by using [[git]]:&lt;br /&gt;
 git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git&lt;br /&gt;
&lt;br /&gt;
to install in the /home/$USER/ directory issue as user:&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
and as root:&lt;br /&gt;
 make install&lt;br /&gt;
&lt;br /&gt;
In slackware, to use sparse you may want to add this to your .bashrc:&lt;br /&gt;
 export PATH=&amp;quot;$PATH:$HOME/bin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
===More information:===&lt;br /&gt;
http://www.celinuxforum.org/CelfPubWiki/Sparse&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41637</id>
		<title>Sparse</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41637"/>
		<updated>2008-09-19T13:21:18Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==SPARSE==&lt;br /&gt;
==What is it:==&lt;br /&gt;
A Semantic Parser for C, can for instance be used to test the linux kernel compilation.&lt;br /&gt;
&lt;br /&gt;
how to get it:&lt;br /&gt;
see http://www.kernel.org/pub/software/devel/sparse/&lt;br /&gt;
you can also get it by using [[git]]:&lt;br /&gt;
git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git&lt;br /&gt;
&lt;br /&gt;
to install in the /home/$USER/ directory issue as user:&lt;br /&gt;
make&lt;br /&gt;
&lt;br /&gt;
and as root:&lt;br /&gt;
make install&lt;br /&gt;
&lt;br /&gt;
In slackware, to use sparse you may want to add this to your .bashrc:&lt;br /&gt;
export PATH=&amp;quot;$PATH:$HOME/bin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
http://www.celinuxforum.org/CelfPubWiki/Sparse&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41636</id>
		<title>Sparse</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Sparse&amp;diff=41636"/>
		<updated>2008-09-19T13:20:46Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: New page: What is it: A Semantic Parser for C, can for instance be used to test the linux kernel compilation.  how to get it: see http://www.kernel.org/pub/software/devel/sparse/ you can also get it...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What is it:&lt;br /&gt;
A Semantic Parser for C, can for instance be used to test the linux kernel compilation.&lt;br /&gt;
&lt;br /&gt;
how to get it:&lt;br /&gt;
see http://www.kernel.org/pub/software/devel/sparse/&lt;br /&gt;
you can also get it by using [[git]]:&lt;br /&gt;
git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git&lt;br /&gt;
&lt;br /&gt;
to install in the /home/$USER/ directory issue as user:&lt;br /&gt;
make&lt;br /&gt;
&lt;br /&gt;
and as root:&lt;br /&gt;
make install&lt;br /&gt;
&lt;br /&gt;
In slackware, to use sparse you may want to add this to your .bashrc:&lt;br /&gt;
export PATH=&amp;quot;$PATH:$HOME/bin&amp;quot;&lt;br /&gt;
&lt;br /&gt;
More information:&lt;br /&gt;
http://www.celinuxforum.org/CelfPubWiki/Sparse&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=41324</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=41324"/>
		<updated>2008-08-25T19:06:18Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: mkdir: also parents&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir -p /home/$USER/build/kernel&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/build/kernel/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/build/kernel menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir -p /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /sbin/lsmod | tail +2 | cut -d&amp;quot; &amp;quot; -f1 | while read module; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=41191</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=41191"/>
		<updated>2008-08-15T15:42:48Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: also parent dirs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir -p /home/$USER/build/kernel&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/build/kernel/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/build/kernel menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /sbin/lsmod | tail +2 | cut -d&amp;quot; &amp;quot; -f1 | while read module; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=35171</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=35171"/>
		<updated>2007-10-06T21:02:14Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* As a script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/build/kernel&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/build/kernel/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/build/kernel menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 /sbin/lsmod | tail +2 | cut -d&amp;quot; &amp;quot; -f1 | while read module; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34914</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34914"/>
		<updated>2007-09-02T00:25:53Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* As a script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/build/kernel&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/build/kernel/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/build/kernel menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
/sbin/lsmod | tail +2 | cut -d&amp;quot; &amp;quot; -f1 | while read module; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=34913</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=34913"/>
		<updated>2007-09-01T23:54:35Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a [[kernel]]. You'll need a C-[[compiler]], [[make]], and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 [[cc]] -v&lt;br /&gt;
 [[make]] -v&lt;br /&gt;
 [[ls]] /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
=== Preparations ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
== Obtaining the kernel source ==&lt;br /&gt;
The variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; is for the kernel version. Replace x.x.x with the kernel version of the kernel you want to compile:&lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*From your [[distribution]]&lt;br /&gt;
*From [http://www.kernel.org kernel.org]&lt;br /&gt;
*From [[git]]&lt;br /&gt;
&lt;br /&gt;
===From distribution===&lt;br /&gt;
When installed it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. Link it using:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
===From kernel.org===&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'').&lt;br /&gt;
&lt;br /&gt;
Extract the sources, using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
===From git===&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it in '/home/$user/src/kernel'', the [[git repository]] will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
===Patch Kernel===&lt;br /&gt;
If you want to apply an additional patch to your kernel, you should do that before you configure your kernel, see [[patching a kernel]]. If you patched your kernel, don't forget to rename the kernel source directory accordingly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=34912</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=34912"/>
		<updated>2007-09-01T23:51:35Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a [[kernel]]. You'll need a C-[[compiler]], [[make]], and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 [[cc]] -v&lt;br /&gt;
 [[make]] -v&lt;br /&gt;
 [[ls]] /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
The variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; is for the kernel version. Replace x.x.x with the kernel version of the kernel you want to compile:&lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*From your [[distribution]]&lt;br /&gt;
*From [http://www.kernel.org kernel.org]&lt;br /&gt;
*From [[git]]&lt;br /&gt;
&lt;br /&gt;
==From distribution==&lt;br /&gt;
When installed it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. Link it using:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
==From kernel.org==&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'').&lt;br /&gt;
&lt;br /&gt;
Extract the sources, using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
==From git==&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it in '/home/$user/src/kernel'', the [[git repository]] will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to apply an additional patch to your kernel, you should do that before you configure your kernel, see [[patching a kernel]]. If you patched your kernel, don't forget to rename the kernel source directory accordingly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34911</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34911"/>
		<updated>2007-09-01T23:29:26Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/build/kernel&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/build/kernel/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/build/kernel menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for module in `/sbin/lsmod |cut -d&amp;quot; &amp;quot; -f1 | tail +2`; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34910</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34910"/>
		<updated>2007-09-01T23:13:21Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* As a script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/kbuild&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/kbuild/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/kbuild menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
You don't have to be root to run the script below, but you should be running a 2.6 kernel. It parses that kernels' .config and removes modules when not currently loaded. You may want to add some modules you'll need occasionally after running this script.&lt;br /&gt;
&lt;br /&gt;
 mkdir /home/$USER/build/kernel/&lt;br /&gt;
 cd /home/$USER/build/kernel/&lt;br /&gt;
&lt;br /&gt;
save this script debloatconfig in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for module in `/sbin/lsmod |cut -d&amp;quot; &amp;quot; -f1 | tail +2`; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x debloatconfig&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
&lt;br /&gt;
If the latter command didn't work, then the kernel you run lacks the CONFIG_IKCONFIG option. You may be able to find the .config from some other source.&lt;br /&gt;
&lt;br /&gt;
 debloatconfig /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings if you have proprietary modules, or if a module wasn't found. In the latter case the generic configuration won't be changed. &lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/build/kernel/ menuconfig&lt;br /&gt;
&lt;br /&gt;
There are a few reasons why I'd suggest you to review the settings after usage, however:&lt;br /&gt;
* Compiled in options won't be changed, although changing them may benefit your hardware.&lt;br /&gt;
* This script removes modules that are not loaded. This may include some modules you'll want to use occasionally.&lt;br /&gt;
* resolve warnings &lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes.&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34909</id>
		<title>User:Picobyte</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34909"/>
		<updated>2007-09-01T22:19:46Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;script to update slackware patches during boot.&lt;br /&gt;
Save this script as root as ''/etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # copyright GPL v2.0 by Roel Kluin 2007&lt;br /&gt;
 &lt;br /&gt;
 #specify the user authorized for downloading and storage of packages&lt;br /&gt;
 PKGUSR=&amp;quot;&amp;lt;your username here&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #specify your favorite mirror&lt;br /&gt;
 RSYNCHOST=&amp;quot;&amp;lt;your favorite rsync host&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #is equal to VERSION=&amp;quot;12.0&amp;quot;&lt;br /&gt;
 VERSION=&amp;quot;`cat /etc/slackware-version | cut -b 11-14`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # where you want to install these packages&lt;br /&gt;
 DESTDIR=&amp;quot;/home/$PKGUSR/dnld/slackware/slackware-$VERSION&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 RSYNC=&amp;quot;$RSYNCHOST::slackware/slackware-$VERSION/patches&amp;quot;&lt;br /&gt;
 BEFORE=`date +%Y%m%d%M%S`&lt;br /&gt;
 echo checking for updated slackware-$VERSION patches...&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;mkdir -p $DESTDIR&amp;quot;&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;rsync -q --exclude=patches/source -v --progress \&lt;br /&gt;
 -az --delete --log-file=$DESTDIR/rsync.log $RSYNC $DESTDIR/&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 cd $DESTDIR/patches&lt;br /&gt;
 cat CHECKSUMS.md5 | grep -e &amp;quot;.tgz$&amp;quot; | while read sum file; do&lt;br /&gt;
   # only updated files should are checked and installed&lt;br /&gt;
   if [ `date -r $file +%Y%m%d%M%S` -ge $BEFORE ]; then&lt;br /&gt;
     if [ &amp;quot;`openssl md5 $file | cut -d&amp;quot; &amp;quot; -f 2-`&amp;quot; = &amp;quot;$sum&amp;quot; ]; then&lt;br /&gt;
       if [ &amp;quot;`gpg --verify $file.asc 2&amp;gt;&amp;amp;1 | grep Slackware | cut -d&amp;quot; &amp;quot; -f2`&amp;quot; = &amp;quot;Good&amp;quot; ]; then&lt;br /&gt;
         upgradepkg --install-new $file&lt;br /&gt;
       else&lt;br /&gt;
         echo ERROR: SIGN of $file is not OK!&lt;br /&gt;
       fi&lt;br /&gt;
     else&lt;br /&gt;
       echo ERROR: MD5 sum of $file is not OK!&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
dont forget to ''chmod a+x /etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
add these lines to your ''/etc/rc.d/rc.local'' file&lt;br /&gt;
 if [ -x /etc/rc.d/rc.updateslack ]; then&lt;br /&gt;
   /etc/rc.d/rc.updateslack&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34908</id>
		<title>User:Picobyte</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34908"/>
		<updated>2007-09-01T22:14:36Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;script to update slackware patches during boot.&lt;br /&gt;
Save this script as root as ''/etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # copyright GPL v2.0 by Roel Kluin 2007&lt;br /&gt;
 &lt;br /&gt;
 #specify the user authorized for downloading and storage of packages&lt;br /&gt;
 PKGUSR=&amp;quot;&amp;lt;your username here&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #specify your favorite mirror&lt;br /&gt;
 RSYNCHOST=&amp;quot;&amp;lt;your favorite rsync host&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #is equal to VERSION=&amp;quot;12.0&amp;quot;&lt;br /&gt;
 VERSION=&amp;quot;`cat /etc/slackware-version | cut -b 11-14`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # where you want to install these packages&lt;br /&gt;
 DESTDIR=&amp;quot;/home/$PKGUSR/dnld/slackware/slackware-$VERSION&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 RSYNC=&amp;quot;$RSYNCHOST::slackware/slackware-$VERSION/patches&amp;quot;&lt;br /&gt;
 BEFORE=`date +%Y%m%d%M%S`&lt;br /&gt;
 echo checking for updated slackware-$VERSION patches...&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;mkdir -p $DESTDIR&amp;quot;&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;rsync -q --exclude=patches/source -v --progress -az --delete --log-file=$DESTDIR/rsync.log $RSYNC $DESTDIR/&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 cd $DESTDIR/patches&lt;br /&gt;
 cat CHECKSUMS.md5 | grep -e &amp;quot;.tgz$&amp;quot; | while read sum file; do&lt;br /&gt;
   # only updated files should are checked and installed&lt;br /&gt;
   if [ `date -r $file +%Y%m%d%M%S` -ge $BEFORE ]; then&lt;br /&gt;
     if [ &amp;quot;`openssl md5 $file | cut -d&amp;quot; &amp;quot; -f 2-`&amp;quot; = &amp;quot;$sum&amp;quot; ]; then&lt;br /&gt;
       if [ &amp;quot;`gpg --verify $file.asc 2&amp;gt;&amp;amp;1 | grep Slackware | cut -d&amp;quot; &amp;quot; -f2`&amp;quot; = &amp;quot;Good&amp;quot; ]; then&lt;br /&gt;
         upgradepkg --install-new $file&lt;br /&gt;
       else&lt;br /&gt;
         echo ERROR: SIGN of $file is not OK!&lt;br /&gt;
       fi&lt;br /&gt;
     else&lt;br /&gt;
       echo ERROR: MD5 sum of $file is not OK!&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
dont forget to ''chmod a+x /etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
add these lines to your ''/etc/rc.d/rc.local'' file&lt;br /&gt;
 if [ -x /etc/rc.d/rc.updateslack ]; then&lt;br /&gt;
   /etc/rc.d/rc.updateslack&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34907</id>
		<title>User:Picobyte</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34907"/>
		<updated>2007-09-01T22:13:06Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;script to update slackware patches during boot.&lt;br /&gt;
Save this script as root as ''/etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # copyright GPL v2.0 by Roel Kluin 2007&lt;br /&gt;
 &lt;br /&gt;
 #specify the user authorized for downloading and storage of packages&lt;br /&gt;
 PKGUSR=&amp;quot;&amp;lt;your username here&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #specify your favorite mirror&lt;br /&gt;
 RSYNCHOST=&amp;quot;&amp;lt;your favorite rsync host&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #is equal to VERSION=&amp;quot;12.0&amp;quot;&lt;br /&gt;
 VERSION=&amp;quot;`cat /etc/slackware-version | cut -b 11-14`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # where you want to install these packages&lt;br /&gt;
 DESTDIR=&amp;quot;/home/$PKGUSR/dnld/slackware/slackware-$VERSION&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 RSYNC=&amp;quot;$RSYNCHOST::slackware/slackware-$VERSION/patches&amp;quot;&lt;br /&gt;
 BEFORE=`date +%Y%m%d%M%S`&lt;br /&gt;
 echo checking for updated slackware-$VERSION patches...&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;mkdir -p $DESTDIR&amp;quot;&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;rsync -q --exclude=patches/source -v --progress -az --delete --log-file=$DESTDIR/rsync.log $RSYNC $DESTDIR/&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 cd $DESTDIR/patches&lt;br /&gt;
 cat CHECKSUMS.md5 | grep -e &amp;quot;.tgz$&amp;quot; | while read sum file; do&lt;br /&gt;
   # only updated files should are checked and installed&lt;br /&gt;
   if [ `date -r $file +%Y%m%d%M%S` -ge $BEFORE ]; then&lt;br /&gt;
     if [ &amp;quot;`openssl md5 $file | cut -d&amp;quot; &amp;quot; -f 2-`&amp;quot; = &amp;quot;$sum&amp;quot; ]; then&lt;br /&gt;
       if [ &amp;quot;`gpg --verify $file.asc 2&amp;gt;&amp;amp;1 | grep Slackware | cut -d&amp;quot; &amp;quot; -f2`&amp;quot; = &amp;quot;Good&amp;quot; ]; then&lt;br /&gt;
         upgradepkg --install-new $file&lt;br /&gt;
       else&lt;br /&gt;
         echo ERROR SIGN of $file is not OK!&lt;br /&gt;
       fi&lt;br /&gt;
     else&lt;br /&gt;
       echo ERROR MD5 sum of $file is not OK!&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
dont forget to ''chmod a+x /etc/rc.d/rc.updateslack''&lt;br /&gt;
&lt;br /&gt;
add these lines to your ''/etc/rc.d/rc.local'' file&lt;br /&gt;
 if [ -x /etc/rc.d/rc.updateslack ]; then&lt;br /&gt;
   /etc/rc.d/rc.updateslack&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34906</id>
		<title>User:Picobyte</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Picobyte&amp;diff=34906"/>
		<updated>2007-09-01T22:11:15Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: New page: script to update slackware patches during boot save as '''/etc/rc.d/rc.updateslack'''   #!/bin/bash  # copyright GPL v2.0 by Roel Kluin 2007    #specify the user authorized for downloading...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;script to update slackware patches during boot&lt;br /&gt;
save as '''/etc/rc.d/rc.updateslack'''&lt;br /&gt;
&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # copyright GPL v2.0 by Roel Kluin 2007&lt;br /&gt;
 &lt;br /&gt;
 #specify the user authorized for downloading and storage of packages&lt;br /&gt;
 PKGUSR=&amp;quot;&amp;lt;your username here&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #specify your favorite mirror&lt;br /&gt;
 RSYNCHOST=&amp;quot;&amp;lt;your favorite rsync host&amp;gt;&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 #is equal to VERSION=&amp;quot;12.0&amp;quot;&lt;br /&gt;
 VERSION=&amp;quot;`cat /etc/slackware-version | cut -b 11-14`&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 # where you want to install these packages&lt;br /&gt;
 DESTDIR=&amp;quot;/home/$PKGUSR/dnld/slackware/slackware-$VERSION&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 RSYNC=&amp;quot;$RSYNCHOST::slackware/slackware-$VERSION/patches&amp;quot;&lt;br /&gt;
 BEFORE=`date +%Y%m%d%M%S`&lt;br /&gt;
 echo checking for updated slackware-$VERSION patches...&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;mkdir -p $DESTDIR&amp;quot;&lt;br /&gt;
 su - $PKGUSR -c &amp;quot;rsync -q --exclude=patches/source -v --progress -az --delete --log-file=$DESTDIR/rsync.log $RSYNC $DESTDIR/&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
 cd $DESTDIR/patches&lt;br /&gt;
 cat CHECKSUMS.md5 | grep -e &amp;quot;.tgz$&amp;quot; | while read sum file; do&lt;br /&gt;
   # only updated files should are checked and installed&lt;br /&gt;
   if [ `date -r $file +%Y%m%d%M%S` -ge $BEFORE ]; then&lt;br /&gt;
     if [ &amp;quot;`openssl md5 $file | cut -d&amp;quot; &amp;quot; -f 2-`&amp;quot; = &amp;quot;$sum&amp;quot; ]; then&lt;br /&gt;
       if [ &amp;quot;`gpg --verify $file.asc 2&amp;gt;&amp;amp;1 | grep Slackware | cut -d&amp;quot; &amp;quot; -f2`&amp;quot; = &amp;quot;Good&amp;quot; ]; then&lt;br /&gt;
         upgradepkg --install-new $file&lt;br /&gt;
       else&lt;br /&gt;
         echo ERROR SIGN of $file is not OK!&lt;br /&gt;
       fi&lt;br /&gt;
     else&lt;br /&gt;
       echo ERROR MD5 sum of $file is not OK!&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
add these lines to your '''/etc/rc.d/rc.local''' file&lt;br /&gt;
 if [ -x /etc/rc.d/rc.updateslack ]; then&lt;br /&gt;
   /etc/rc.d/rc.updateslack&lt;br /&gt;
 fi&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34802</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34802"/>
		<updated>2007-08-20T20:20:48Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* As a script */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/kbuild&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/kbuild/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/kbuild menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
Ok, here's a script, kcnfsuggest, I wrote some time ago. It parses the .config and removes modules when not currently loaded. You don't have to to be root, but you should be running the generic kernel. for instance:&lt;br /&gt;
 mkdir /home/$USER/kbuild/&lt;br /&gt;
 cd /home/$USER/kbuild/&lt;br /&gt;
&lt;br /&gt;
save this script kcnfsuggest in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for module in `/sbin/lsmod |cut -d&amp;quot; &amp;quot; -f1 | tail +2`; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x kcnfsuggest&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
 kcnfsuggest /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
you may see some warnings, that you'll have to resolve manually using menuconfig (below).&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/kbuild/ menuconfig&lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes. You may want to:&lt;br /&gt;
*resolve previous warnings &lt;br /&gt;
*restore some removed modules that you'll occasionally use&lt;br /&gt;
*change options that were not modules in the original .config. specific for your hardware&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34691</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34691"/>
		<updated>2007-08-09T18:27:22Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: remove error&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/kbuild&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/kbuild/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/kbuild menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
Ok, here's a script, kcnfsuggest, I wrote some time ago. It parses the .config and removes modules when not currently loaded. You shouldn't have to to be root, but you should be running the generic kernel. for instance:&lt;br /&gt;
 mkdir /home/$USER/kbuild/&lt;br /&gt;
 cd /home/$USER/kbuild/&lt;br /&gt;
&lt;br /&gt;
save this script kcnfsuggest in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for module in `/sbin/lsmod |cut -d&amp;quot; &amp;quot; -f1 | tail +2`; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x kcnfsuggest&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
 kcnfsuggest /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
note the warnings, you'll have to resolve these manually later, in menuconfig.&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/kbuild/ menuconfig&lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes. You may want to:&lt;br /&gt;
*resolve previous warnings &lt;br /&gt;
*restore some removed modules that you'll occasionally use&lt;br /&gt;
*change options that were not modules in the original .config. specific for your hardware&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34690</id>
		<title>Configuring linux kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Configuring_linux_kernel&amp;diff=34690"/>
		<updated>2007-08-09T17:21:00Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Configuring the linux [[kernel]] is the first step when [[Compiling a Linux kernel]]. In this step you can specify what kind of computer your kernel will support. Options of linux kernel cover [[architecture]], [[device drivers]], [[filesystem]]s, [[networking]], [[security]] and other settings. &lt;br /&gt;
&lt;br /&gt;
==Requirements==&lt;br /&gt;
This document assumes you are running the latest 2.6 kernel, provided - as package - by your [[distribution]]. You can determine the kernel version with:&lt;br /&gt;
 uname -r&lt;br /&gt;
Also required are the kernel sources; here assumed to be in ''/usr/src/linux''.&lt;br /&gt;
&lt;br /&gt;
==Summary==&lt;br /&gt;
This document will describe how to recognize config options for currently running- and not running [[module]]s. That information will be used to to (de)select those options for a configuration tailored for your computer. First will be described how options can be recognized and changed manually, below also is a script that parses the configuration of your distribution and deselects not loaded modules.&lt;br /&gt;
&lt;br /&gt;
==Manually==&lt;br /&gt;
Rather than spoiling the kernel source directory we can build the kernel in a subdirectory of your home directory:&lt;br /&gt;
 mkdir /home/$USER/kbuild&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$USER/kbuild/.config&lt;br /&gt;
In the last command you extracted the .config file used to build the currently running kernel. This (hidden) ''.config'' file contains the kernel config options your distribution selected for this kernel, to support a wide range of hardware these options are mostly modules. This .config file will be loaded automaticly by menuconfig.&lt;br /&gt;
&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 [[make]] O=/home/$USER/kbuild menuconfig&lt;br /&gt;
Instead of ''menuconfig'', ''xconfig'' or ''gconfig'' will also work in a graphical environment.&lt;br /&gt;
&lt;br /&gt;
The advantages of using the ''.config'' file of the distribution are:&lt;br /&gt;
*You know that the initial kernel configuration supports most hardware&lt;br /&gt;
*You can play safe by only deselecting the options you know you don't need&lt;br /&gt;
*Going trough the options, you'll learn about the linux kernel, the computer and your hardware&lt;br /&gt;
The disadvantages:&lt;br /&gt;
*There are a LOT of options to be deselected&lt;br /&gt;
*You may not be certain about a lot of options&lt;br /&gt;
*Building the kernel with too many modules takes longer&lt;br /&gt;
&lt;br /&gt;
While it is true that the build time of a kernel without unnecessary modules will be reduced, going through all config options will take much longer than the buildtime gained. On the other hand, you'll have to do this only once thoroughly, subsequent builds can use the same .config file.&lt;br /&gt;
&lt;br /&gt;
When you exit and choose to save the options, the hidden ''.config'' file will be overwritten with the new choice of config options, and will be used when [[Compiling a Linux kernel]]. But before that, how to determine right options.&lt;br /&gt;
&lt;br /&gt;
==find config options in menu==&lt;br /&gt;
You can search for a config option in menuconfig. Press '/' and enter a config option (but strip CONFIG_). for instance 'USB_PRINTER', and it will list the current state (y/n/m), where to find this option in the menu and more.&lt;br /&gt;
&lt;br /&gt;
Searching is is nice, however, only if you know the name of the config option and the state you'll need. So now is the question, how to get these. first the state:&lt;br /&gt;
&lt;br /&gt;
==Determine the wanted modules==&lt;br /&gt;
To list all modules, type &amp;lt;code&amp;gt;/sbin/[[modprobe]] -l&amp;lt;/code&amp;gt;. To list loaded modules use &amp;lt;code&amp;gt;/sbin/[[lsmod]]&amp;lt;/code&amp;gt;. Note that the last list is much shorter. &lt;br /&gt;
&lt;br /&gt;
In lsmod the first column lists the modules for hardware that was loaded during boot. It is very probable that you'll want these in your configuration too. If modules aren't loaded, it's an indication that you may not need them. &lt;br /&gt;
&lt;br /&gt;
We'll need to have the same format like listed by modprobe to be able to determine the config option name later. Therefore we can cut the lsmod output and pipe it through modinfo:&lt;br /&gt;
 #!/bin/[[bash]]&lt;br /&gt;
 /sbin/lsmod|[[cut]] -d&amp;quot; &amp;quot; -f1|[[xargs]] /sbin/[[modinfo]] -n;&lt;br /&gt;
Save as ''loaded_mods.sh'' and make it excecutable after editing by typing &amp;lt;code&amp;gt;[[chmod]] u+x loaded_mods.sh&amp;lt;/code&amp;gt;. You can then run it by typing &amp;lt;code&amp;gt;./loaded_mods.sh&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Determine not wanted modules==&lt;br /&gt;
Sometimes you want to know what modules you don't need. To list those you can use:&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 loaded_modules=&amp;quot;`/sbin/lsmod|cut -d&amp;quot; &amp;quot; -f1|xargs /sbin/modinfo -n`&amp;quot;&lt;br /&gt;
 [[for]] m in `/sbin/modprobe -l`; do&lt;br /&gt;
   [[if]] [ -z &amp;quot;${loaded_modules/*$m*/}&amp;quot; ]; then&lt;br /&gt;
     [[echo]] $m;&lt;br /&gt;
    fi&lt;br /&gt;
 done&lt;br /&gt;
Save as ''not_loaded_mods.sh'' and make it excecutable. This will list the modules that are not loaded&lt;br /&gt;
&lt;br /&gt;
==Module names to config options==&lt;br /&gt;
Now we know how to determine the wanted state for modules, it's time to learn how to translate the module name into a config option. We can do this by parsing [[makefile]]s in kernel source (sub)directories. In the makefiles the config options and module names are listed.&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 mod=&amp;quot;${1%.ko}&amp;quot;;&lt;br /&gt;
 dir=&amp;quot;${1%/*}&amp;quot;;&lt;br /&gt;
 [[sed]] -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;${dir#*/kernel/}/Makefile&amp;quot; | \&lt;br /&gt;
 sed -n &amp;quot;s/^obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=\W*&amp;quot;${mod##*/}&amp;quot;\.o$/\1/p&amp;quot;;&lt;br /&gt;
Save as ''mod2config.sh'' and make it excecutable. This script will need an module (as listed in modprobe -l) and will translate it into a config option. So to list all not loaded modules:&lt;br /&gt;
 for f in `./not_loaded_mods.sh`; do &lt;br /&gt;
   ./mod2config.sh $f; &lt;br /&gt;
 done | less&lt;br /&gt;
and for the loaded:&lt;br /&gt;
 for f in `./loaded_mods.sh`; do&lt;br /&gt;
   ./mod2config.sh $f;&lt;br /&gt;
 done | less&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
Using this information, you can search for config options in menuconfig and activate or deactivate them. Please use some common sense, however. Only deactivate a module if you cannot think of a use for the module. Also there are options that were not modules in the original ''.config''. You'll have to figure the required settings for these for yourself.&lt;br /&gt;
&lt;br /&gt;
==As a script==&lt;br /&gt;
&lt;br /&gt;
Ok, here's a script, kcnfsuggest, I wrote some time ago. It parses the .config and removes modules when not currently loaded. You shouldn't have to to be root, but you should be running the generic kernel. for instance:&lt;br /&gt;
 mkdir /home/$USER/kbuild/&lt;br /&gt;
 cd /home/$USER/kbuild/&lt;br /&gt;
&lt;br /&gt;
save this script kcnfsuggest in this directory&lt;br /&gt;
 #!/bin/bash&lt;br /&gt;
 # Copyright (c) 2007 Roel Kluin GNU GPL v.2&lt;br /&gt;
 get_mod2conf_makefile() {&lt;br /&gt;
   sed -e :a -e '/\\$/N; s/\\\n//; ta' &amp;quot;$3/$2/Makefile&amp;quot; | \&lt;br /&gt;
   sed -n &amp;quot;s/^\W*obj-\$(CONFIG_\([A-Z0-9_]*\))\W*+=.*$1\.o$/\1/p&amp;quot;;&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 for module in `/sbin/lsmod |cut -d&amp;quot; &amp;quot; -f1`; do&lt;br /&gt;
   license=&amp;quot;`/sbin/modinfo -l &amp;quot;$module&amp;quot;`&amp;quot;;&lt;br /&gt;
   if [ -n &amp;quot;${license##*GPL*}&amp;quot; ]; then&lt;br /&gt;
     echo &amp;quot;WARNING: $module has licence \&amp;quot;$license\&amp;quot;, when \&lt;br /&gt;
 built this kernel will not include this module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
   else&lt;br /&gt;
     module=&amp;quot;`/sbin/modinfo -n $module`&amp;quot;;&lt;br /&gt;
     dir=&amp;quot;${module%/*}&amp;quot;;&lt;br /&gt;
     if [ -n &amp;quot;${dir##*/kernel/*}&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: module not in kernel directory: $module&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
       continue;&lt;br /&gt;
     fi&lt;br /&gt;
     mod=&amp;quot;${module%.ko}&amp;quot;;&lt;br /&gt;
     mod=&amp;quot;${mod##*/}&amp;quot;&lt;br /&gt;
     dir=&amp;quot;${ksrcdir}${dir#*/kernel/}&amp;quot;;&lt;br /&gt;
     option=&amp;quot;`get_mod2conf_makefile $mod $dir $1`&amp;quot;;&lt;br /&gt;
     if [ -z &amp;quot;$option&amp;quot; ]; then&lt;br /&gt;
       echo &amp;quot;WARNING: no kernel config option found for $mod&amp;quot; 1&amp;gt;&amp;amp;2;&lt;br /&gt;
     else&lt;br /&gt;
       # loop since grep/sed may return more options&lt;br /&gt;
       for op in $option; do&lt;br /&gt;
         char_count=${#enable_option};&lt;br /&gt;
         enable_option=&amp;quot;${enable_option/ $op /}&amp;quot;;&lt;br /&gt;
         if [ $char_count -ne ${#enable_option} ]; then&lt;br /&gt;
           continue;&lt;br /&gt;
         fi&lt;br /&gt;
         enable_option=&amp;quot;$enable_option $op&amp;quot;;&lt;br /&gt;
       done&lt;br /&gt;
     fi&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
 &lt;br /&gt;
 cat $2 | while read line; do&lt;br /&gt;
   option=${line##\#*}; # delete comment&lt;br /&gt;
   option=${option%=m*}; # preserve module options&lt;br /&gt;
   option=${option%%*=*}; # remove other non-module options&lt;br /&gt;
   if [ &amp;quot;${option#CONFIG_}&amp;quot; ]; then&lt;br /&gt;
     char_count=${#enable_option};&lt;br /&gt;
     enable_option=&amp;quot;${enable_option/${option#CONFIG_}/}&amp;quot;;&lt;br /&gt;
     if [ $char_count -eq ${#enable_option} ]; then&lt;br /&gt;
       echo &amp;quot;$option=n # changed by $0&amp;quot;&lt;br /&gt;
     else&lt;br /&gt;
       echo &amp;quot;$option=m&amp;quot;&lt;br /&gt;
     fi&lt;br /&gt;
   else&lt;br /&gt;
     echo &amp;quot;$line&amp;quot;; # non-module options, left unchanged&lt;br /&gt;
   fi&lt;br /&gt;
 done&lt;br /&gt;
&lt;br /&gt;
now run:&lt;br /&gt;
 chmod u+x kcnfsuggest&lt;br /&gt;
 zcat /proc/config.gz &amp;gt; std.config&lt;br /&gt;
 kcnfsuggest /usr/src/linux std.config &amp;gt; .config&lt;br /&gt;
&lt;br /&gt;
note the warnings, you'll have to resolve these manually later, in menuconfig.&lt;br /&gt;
 cd /usr/src/linux&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
&lt;br /&gt;
if you want to upgrade to a newer kernel, go to the path of that kernel's sources and do again:&lt;br /&gt;
 make O=/home/$USER/kbuild/ oldconfig&lt;br /&gt;
If source code was changed, between kernel versions, the state for the corresponding config options will be asked again.&lt;br /&gt;
&lt;br /&gt;
finally, and I still suggest you use this to review the settings:&lt;br /&gt;
 make O=/home/$USER/kbuild/ menuconfig&lt;br /&gt;
&lt;br /&gt;
The advantage is, that now you'll have to make much less changes. You may want to:&lt;br /&gt;
*resolve previous warnings &lt;br /&gt;
*restore some removed modules that you'll occasionally use&lt;br /&gt;
*change options that were not modules in the original .config. specific for your hardware&lt;br /&gt;
&lt;br /&gt;
==Other helpful tools==&lt;br /&gt;
*Documentation of your hardware (sometimes available online)&lt;br /&gt;
*''Documentation'' directory in your kernel sources&lt;br /&gt;
*&amp;lt;code&amp;gt;[[cat]] /proc/[[cpuinfo]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*&amp;lt;code&amp;gt;[[lspci]]&amp;lt;/code&amp;gt;&lt;br /&gt;
*Help options in menuconfig&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=User:Jundong&amp;diff=33763</id>
		<title>User:Jundong</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=User:Jundong&amp;diff=33763"/>
		<updated>2007-05-13T23:12:56Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: **SPAM**&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33762</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33762"/>
		<updated>2007-05-13T23:10:56Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version (or use &amp;lt;CODE&amp;gt;`ls -rt -1|tail -n1|cut -d&amp;quot;-&amp;quot; -f2-`&amp;lt;/CODE&amp;gt; instead of ''x.x.x'')&lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33761</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33761"/>
		<updated>2007-05-13T23:10:44Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version (or use &amp;lt;CODE&amp;gt;`ls -rt -1|tail -n1|cut -d&amp;quot;-&amp;quot; -f2-`&amp;lt;/CODE&amp;gt; instead of ''x.x.x'' &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33760</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33760"/>
		<updated>2007-05-13T23:09:34Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x # or `ls -rt -1|tail -n1|cut -d&amp;quot;-&amp;quot; -f2-`&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33759</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33759"/>
		<updated>2007-05-13T22:59:04Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Configuring linux kernel]]&lt;br /&gt;
*[[Compiling a kernel on Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33758</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33758"/>
		<updated>2007-05-13T22:57:54Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln]] -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33757</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33757"/>
		<updated>2007-05-13T22:57:30Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Obtaining the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (''linux-x.x.x.tar.gz'' or ''linux-x.x.x.tar.bz2'') in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33756</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33756"/>
		<updated>2007-05-13T22:57:05Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Preparations */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== From kernel.org ===&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
three ways to get the kernel sources:&lt;br /&gt;
*Get the kernel source from [http://www.kernel.org kernel.org]. Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory and extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
*Your [[distribution]] may also have provide the kernel source. after installing it usually resides in a ''/usr/src/linux-x.x.x'' subdirectory. then just link to it:&lt;br /&gt;
 [[ln -s /usr/src/linux-x.x.x /home/$user/src/kernel/linux-x.x.x&lt;br /&gt;
&lt;br /&gt;
*It is also possible to get the latest kernel development version [[using git]]. If you clone it here, it will be placed in ''/home/$user/src/kernel/linux-x.x''&lt;br /&gt;
&lt;br /&gt;
For the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33755</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33755"/>
		<updated>2007-05-13T22:38:16Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Install a boot manager */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
You can determine your root partition with:&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=$ROOTDEV initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33754</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33754"/>
		<updated>2007-05-13T22:35:31Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Extra cleaning for old kernels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for pre 2.6 kernels ===&lt;br /&gt;
This can be skipped for 2.6.x kernels. First ensures that dependancies such as include files are in place, then clean your sources so they compile correctly.&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33753</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33753"/>
		<updated>2007-05-13T22:33:48Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Extra cleaning for old kernels */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP FOR 2.6.x KERNELS&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33752</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33752"/>
		<updated>2007-05-13T22:32:51Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
*[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33751</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33751"/>
		<updated>2007-05-13T22:32:41Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Propietary nvidia module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Patching_a_kernel]]&lt;br /&gt;
[[Configuring_linux_kernel]]&lt;br /&gt;
*[[Compiling_a_kernel_on_Debian]]&lt;br /&gt;
*[[Kernel]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33750</id>
		<title>Patching a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33750"/>
		<updated>2007-05-13T22:32:07Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Patching a kernel==&lt;br /&gt;
There can be several reasons to apply a patch:&lt;br /&gt;
* To upgrade the kernel to a newer version&lt;br /&gt;
* To use patches (e.g. bugfixes) not yet merged into the kernel&lt;br /&gt;
* To add functionality using code from external sources&lt;br /&gt;
This last reason could be unsafe and should be avoided&lt;br /&gt;
&lt;br /&gt;
===Upgrading the kernel===&lt;br /&gt;
Rather than distribute the full kernel source every time there's a new stable release (roughly once a month), it is more efficient to distribute just the changes.  This is done in the form of a patch.  So instead of going to http://kernel.org/ and downloading the full source, go there and just download the changes since the last time you downloaded the full source.&lt;br /&gt;
&lt;br /&gt;
For instance, if I have linux-2.6.0.tar.bz2 already downloaded and I want to have linux-2.6.3, I need to download the patch to go from 2.6.0 to 2.6.1, the patch to go from 2.6.1 to 2.6.2 and the patch to go from 2.6.2 to 2.6.3. The patch files are called &amp;quot;patch-2.6.2.bz2&amp;quot;, etc (patch-2.6.2.bz2 is the patch file that gets you from version 2.6.1 to version 2.6.2).  Once one has these four files, one should untar the full source for 2.6.0 somewhere, and then apply the patches, one by one, in order.  Assuming source and patch are in your home directory, for example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ mkdir build&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ bunzip2 -dc ~/linux-2.6.0.tar.bz2 | tar -x&lt;br /&gt;
 $ cd linux-2.6.0&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.1.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.2.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.3.bz2 | patch -p1&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ mv linux-2.6.0 linux-2.6.3 # since the dir now represents the 2.6.3 kernel&lt;br /&gt;
&lt;br /&gt;
if you downloaded a ''.gz'' patch, use instead:&lt;br /&gt;
 gzip -cd ~/patch-2.6.xx.gz | patch -p1&lt;br /&gt;
&lt;br /&gt;
if it's not zipped:&lt;br /&gt;
  patch -E -p1  &amp;lt; ~/sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[patch]]&lt;br /&gt;
*[[Patch-o-matic]]&lt;br /&gt;
*[[Compiling_a_kernel]]&lt;br /&gt;
&lt;br /&gt;
==external sources==&lt;br /&gt;
http://www.linuxhq.com/patch-howto.html&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33749</id>
		<title>Patching a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33749"/>
		<updated>2007-05-13T22:31:05Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Patching a kernel==&lt;br /&gt;
There can be several reasons to apply a patch:&lt;br /&gt;
* To upgrade the kernel to a newer version&lt;br /&gt;
* To use patches (e.g. bugfixes) not yet merged into the kernel&lt;br /&gt;
* To add functionality using code from external sources&lt;br /&gt;
This last reason could be unsafe and should be avoided&lt;br /&gt;
&lt;br /&gt;
===Upgrading the kernel===&lt;br /&gt;
Rather than distribute the full kernel source every time there's a new stable release (roughly once a month), it is more efficient to distribute just the changes.  This is done in the form of a patch.  So instead of going to http://kernel.org/ and downloading the full source, go there and just download the changes since the last time you downloaded the full source.&lt;br /&gt;
&lt;br /&gt;
For instance, if I have linux-2.6.0.tar.bz2 already downloaded and I want to have linux-2.6.3, I need to download the patch to go from 2.6.0 to 2.6.1, the patch to go from 2.6.1 to 2.6.2 and the patch to go from 2.6.2 to 2.6.3. The patch files are called &amp;quot;patch-2.6.2.bz2&amp;quot;, etc (patch-2.6.2.bz2 is the patch file that gets you from version 2.6.1 to version 2.6.2).  Once one has these four files, one should untar the full source for 2.6.0 somewhere, and then apply the patches, one by one, in order.  Assuming source and patch are in your home directory, for example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ mkdir build&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ bunzip2 -dc ~/linux-2.6.0.tar.bz2 | tar -x&lt;br /&gt;
 $ cd linux-2.6.0&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.1.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.2.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.3.bz2 | patch -p1&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ mv linux-2.6.0 linux-2.6.3 # since the dir now represents the 2.6.3 kernel&lt;br /&gt;
&lt;br /&gt;
if you downloaded a ''.gz'' patch, use instead:&lt;br /&gt;
 gzip -cd ~/patch-2.6.xx.gz | patch -p1&lt;br /&gt;
&lt;br /&gt;
if it's not zipped:&lt;br /&gt;
  patch -E -p1  &amp;lt; ~/sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[patch]]&lt;br /&gt;
*[[Patch-o-matic]]&lt;br /&gt;
&lt;br /&gt;
==external sources==&lt;br /&gt;
http://www.linuxhq.com/patch-howto.html&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33748</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33748"/>
		<updated>2007-05-13T22:29:07Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: moved to 'Compiling_a_kernel_on_Debian'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compiling_a_kernel_on_Debian&amp;diff=33747</id>
		<title>Compiling a kernel on Debian</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compiling_a_kernel_on_Debian&amp;diff=33747"/>
		<updated>2007-05-13T22:28:08Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: New page: Debian has some utilities to make compiling a kernel easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your ...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Debian]] has some utilities to make compiling a kernel easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Debian]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33746</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33746"/>
		<updated>2007-05-13T22:19:16Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Installing the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]]. Don't forget to rename the directory afterwards.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33745</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33745"/>
		<updated>2007-05-13T22:18:19Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Installing the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
Enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
If you want to patch your kernel, you should do that now, see [[patching a kernel]].&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33744</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33744"/>
		<updated>2007-05-13T22:17:06Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: patching part moved to patching a kernel&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patch&amp;diff=33743</id>
		<title>Patch</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patch&amp;diff=33743"/>
		<updated>2007-05-13T22:16:08Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &amp;lt;b&amp;gt;patch&amp;lt;/b&amp;gt;, noun, is an update applied to a software [[application]] or [[operating system]] for the purpose of fixing bugs or exploits or for adding features. It is also a program (see below).&lt;br /&gt;
----&lt;br /&gt;
To &amp;lt;b&amp;gt;patch&amp;lt;/b&amp;gt;, verb, to use a patch to update a bug or an exploit or add a feature to a piece of software or an operating system.&lt;br /&gt;
----&lt;br /&gt;
'''Patch''' (the application) only has a small job, but it does it quickly and efficiently. It takes a sourcecode file (or any other file for that matter) and a [[diff]] file based on changes that have been made to another copy of the source. It then merges the two, applying the changes specified to the source file. This is particularly useful for allowing developers to collaborate through [[CVS]] repositories.&lt;br /&gt;
&lt;br /&gt;
Originally written by [[Larry Wall]], also the author of [[Perl]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Patch-o-matic]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
&lt;br /&gt;
*[http://www.gnu.org/software/patch/patch.html Patch Homepage]&lt;br /&gt;
*[http://man.linuxquestions.org/index.php?query=patch&amp;amp;section=0&amp;amp;type=2 patch man page]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patch&amp;diff=33742</id>
		<title>Patch</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patch&amp;diff=33742"/>
		<updated>2007-05-13T22:15:49Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: moved to 'patching a kernel'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;A &amp;lt;b&amp;gt;patch&amp;lt;/b&amp;gt;, noun, is an update applied to a software [[application]] or [[operating system]] for the purpose of fixing bugs or exploits or for adding features. It is also a program (see below).&lt;br /&gt;
----&lt;br /&gt;
To &amp;lt;b&amp;gt;patch&amp;lt;/b&amp;gt;, verb, to use a patch to update a bug or an exploit or add a feature to a piece of software or an operating system.&lt;br /&gt;
----&lt;br /&gt;
'''Patch''' (the application) only has a small job, but it does it quickly and efficiently. It takes a sourcecode file (or any other file for that matter) and a [[diff]] file based on changes that have been made to another copy of the source. It then merges the two, applying the changes specified to the source file. This is particularly useful for allowing developers to collaborate through [[CVS]] repositories.&lt;br /&gt;
&lt;br /&gt;
Originally written by [[Larry Wall]], also the author of [[Perl]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[Patching a kernel]]&lt;br /&gt;
[[Patch-o-matic]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
&lt;br /&gt;
*[http://www.gnu.org/software/patch/patch.html Patch Homepage]&lt;br /&gt;
*[http://man.linuxquestions.org/index.php?query=patch&amp;amp;section=0&amp;amp;type=2 patch man page]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Kernel&amp;diff=33741</id>
		<title>Kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Kernel&amp;diff=33741"/>
		<updated>2007-05-13T22:15:23Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The '''kernel''' is the core of the [[operating system]].  It is a single [[program]] (or sometimes a group of them) that manages the interaction of all other programs on a computer system, and the available resources of that system (like [[RAM]], [[CPU]] or [[disk]] space).&lt;br /&gt;
&lt;br /&gt;
&amp;quot;The kernel&amp;quot; is only one comparatively-small part of the total Linux system, and many users suppose that it does much more than it actually does.  The rule of thumb is:  &amp;quot;if you can see it and touch it, the kernel is what physically makes it run.&amp;quot;  &lt;br /&gt;
&lt;br /&gt;
A kernel can be thought of as a telephone switch-board - it routes calls from place to place.  It has no interest in what those calls are about, only that everyone who dials a number gets connected with the person they're calling.  The kernel must make sure that no program gets either too little or too much of the system's attention.&lt;br /&gt;
&lt;br /&gt;
Kernels are also thought of as [[monolithic]], having all the functionality built into the kernel itself, or as modular (see [[kernel module]]), having much of the functionality acting separately as modules. Although Linux supports kernel modules, it is said to be monolithic because it is not built on a microkernel [http://groups.google.com/groups?&amp;amp;selm=1992Jan29.231426.20469%40klaava.Helsinki.FI&amp;amp;rnum=1]&lt;br /&gt;
Some example production-ready kernels:&lt;br /&gt;
* The [[Linux]] kernel, developed by [[Linus Torvalds]] and contributors world-wide.  The [[history]] of Linux goes back over a decade.&lt;br /&gt;
* [[Mach]], a [[microkernel]] used by operating systems such as Apple's OS X.&lt;br /&gt;
A developmental kernel:&lt;br /&gt;
* The [[HURD]], the [[GNU]] project's kernel.&lt;br /&gt;
&lt;br /&gt;
Although the kernel is the core of any operating system, for most users differences between Unix-style kernels are not immediately noticeable. For example, if you looked at a computer running [[GNOME]] on the HURD, there wouldn't be any visible differences between the same [[desktop environment]] on Linux. Differences in capabilities, performance, and stability might be rather striking, however.&lt;br /&gt;
&lt;br /&gt;
Some important components of a kernel:&lt;br /&gt;
* [[Virtual Memory]] support&lt;br /&gt;
* [[Multitasking]]&lt;br /&gt;
* [[Context Switching]]&lt;br /&gt;
* [[Device Drivers]]&lt;br /&gt;
* [[Kernel module]]s&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Compiling a kernel]]&lt;br /&gt;
*[[Patching a kernel]]&lt;br /&gt;
*[[Kernel 2.6]]&lt;br /&gt;
*[[Dmesg]]&lt;br /&gt;
&lt;br /&gt;
==External links==&lt;br /&gt;
*[http://www.vidarholen.net/contents/wordcount/ Graphs of the incidence of various swear words in the Linux kernel (Thanks Koalaman)] (''www.vidarholen.net'')&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel| ]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33740</id>
		<title>Patching a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33740"/>
		<updated>2007-05-13T22:14:47Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* patching a kernel */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Patching a kernel==&lt;br /&gt;
There can be several reasons to apply a patch:&lt;br /&gt;
* To upgrade the kernel to a newer version&lt;br /&gt;
* To use patches (e.g. bugfixes) not yet merged into the kernel&lt;br /&gt;
* To add functionality using code from external sources&lt;br /&gt;
This last reason could be unsafe and should be avoided&lt;br /&gt;
&lt;br /&gt;
===Upgrading the kernel===&lt;br /&gt;
Rather than distribute the full kernel source every time there's a new stable release (roughly once a month), it is more efficient to distribute just the changes.  This is done in the form of a patch.  So instead of going to http://kernel.org/ and downloading the full source, go there and just download the changes since the last time you downloaded the full source.&lt;br /&gt;
&lt;br /&gt;
For instance, if I have linux-2.6.0.tar.bz2 already downloaded and I want to have linux-2.6.3, I need to download the patch to go from 2.6.0 to 2.6.1, the patch to go from 2.6.1 to 2.6.2 and the patch to go from 2.6.2 to 2.6.3. The patch files are called &amp;quot;patch-2.6.2.bz2&amp;quot;, etc (patch-2.6.2.bz2 is the patch file that gets you from version 2.6.1 to version 2.6.2).  Once one has these four files, one should untar the full source for 2.6.0 somewhere, and then apply the patches, one by one, in order.  Assuming source and patch are in your home directory, for example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ mkdir build&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ bunzip2 -dc ~/linux-2.6.0.tar.bz2 | tar -x&lt;br /&gt;
 $ cd linux-2.6.0&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.1.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.2.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.3.bz2 | patch -p1&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ mv linux-2.6.0 linux-2.6.3 # since the dir now represents the 2.6.3 kernel&lt;br /&gt;
&lt;br /&gt;
if you downloaded a ''.gz'' patch, use instead:&lt;br /&gt;
 gzip -cd ~/patch-2.6.xx.gz | patch -p1&lt;br /&gt;
&lt;br /&gt;
if it's not zipped:&lt;br /&gt;
  patch -E -p1  &amp;lt; ~/sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[patch]]&lt;br /&gt;
[[Patch-o-matic]]&lt;br /&gt;
&lt;br /&gt;
==external sources==&lt;br /&gt;
http://www.linuxhq.com/patch-howto.html&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33739</id>
		<title>Patching a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Patching_a_kernel&amp;diff=33739"/>
		<updated>2007-05-13T22:12:24Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: New page: ==patching a kernel== There can be two reasons to apply a patch: * to upgrade the kernel to a newer version * using patches (e.g. bugfixes) not yet merged into the kernel * to add function...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==patching a kernel==&lt;br /&gt;
There can be two reasons to apply a patch:&lt;br /&gt;
* to upgrade the kernel to a newer version&lt;br /&gt;
* using patches (e.g. bugfixes) not yet merged into the kernel&lt;br /&gt;
* to add functionality using code from external sources&lt;br /&gt;
&lt;br /&gt;
===upgrading the kernel===&lt;br /&gt;
Rather than distribute the full kernel source every time there's a new stable release (roughly once a month), it is more efficient to distribute just the changes.  This is done in the form of a patch.  So instead of going to http://kernel.org/ and downloading the full source, go there and just download the changes since the last time you downloaded the full source.&lt;br /&gt;
&lt;br /&gt;
For instance, if I have linux-2.6.0.tar.bz2 already downloaded and I want to have linux-2.6.3, I need to download the patch to go from 2.6.0 to 2.6.1, the patch to go from 2.6.1 to 2.6.2 and the patch to go from 2.6.2 to 2.6.3. The patch files are called &amp;quot;patch-2.6.2.bz2&amp;quot;, etc (patch-2.6.2.bz2 is the patch file that gets you from version 2.6.1 to version 2.6.2).  Once one has these four files, one should untar the full source for 2.6.0 somewhere, and then apply the patches, one by one, in order.  Assuming source and patch are in your home directory, for example:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 $ cd&lt;br /&gt;
 $ mkdir build&lt;br /&gt;
 $ cd build&lt;br /&gt;
 $ bunzip2 -dc ~/linux-2.6.0.tar.bz2 | tar -x&lt;br /&gt;
 $ cd linux-2.6.0&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.1.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.2.bz2 | patch -p1&lt;br /&gt;
 $ bunzip2 -dc ~/patch-2.6.3.bz2 | patch -p1&lt;br /&gt;
 $ cd ..&lt;br /&gt;
 $ mv linux-2.6.0 linux-2.6.3 # since the dir now represents the 2.6.3 kernel&lt;br /&gt;
&lt;br /&gt;
if you downloaded a ''.gz'' patch, use instead:&lt;br /&gt;
 gzip -cd ~/patch-2.6.xx.gz | patch -p1&lt;br /&gt;
&lt;br /&gt;
if it's not zipped:&lt;br /&gt;
  patch -E -p1  &amp;lt; ~/sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[patch]]&lt;br /&gt;
[[Patch-o-matic]]&lt;br /&gt;
&lt;br /&gt;
==external sources==&lt;br /&gt;
http://www.linuxhq.com/patch-howto.html&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33738</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33738"/>
		<updated>2007-05-13T21:47:01Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Lilo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append the kernel as boot option to your ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==instructions on how to apply patches to your kernel==&lt;br /&gt;
&lt;br /&gt;
[http://www.linuxhq.com/patch-howto.html read this] or look below ...&lt;br /&gt;
&lt;br /&gt;
This step comes after untarring your kernel source. When you download the patch, place it in the folder where you untarred your new kernel. Then type:&lt;br /&gt;
  patch -E -p1  &amp;lt; sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
Regarding having alternative boot options, this is no problem. The stuff above that I tell you to add to your lilo or grub file above could just be appended to the file, and you could just add &amp;quot;.old&amp;quot; to the title of your original kernel name for you will know the difference. Whether it's grub or lilo, add &amp;quot;read-only&amp;quot; to the end of the original entries in the lilo.conf, or grub.conf, file.&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33737</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33737"/>
		<updated>2007-05-13T21:46:16Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Lilo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append to your config to ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`[[mount]] -l | [[grep]] &amp;quot; \/ &amp;quot; | [[cut]] -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==instructions on how to apply patches to your kernel==&lt;br /&gt;
&lt;br /&gt;
[http://www.linuxhq.com/patch-howto.html read this] or look below ...&lt;br /&gt;
&lt;br /&gt;
This step comes after untarring your kernel source. When you download the patch, place it in the folder where you untarred your new kernel. Then type:&lt;br /&gt;
  patch -E -p1  &amp;lt; sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
Regarding having alternative boot options, this is no problem. The stuff above that I tell you to add to your lilo or grub file above could just be appended to the file, and you could just add &amp;quot;.old&amp;quot; to the title of your original kernel name for you will know the difference. Whether it's grub or lilo, add &amp;quot;read-only&amp;quot; to the end of the original entries in the lilo.conf, or grub.conf, file.&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33736</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33736"/>
		<updated>2007-05-13T21:43:28Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 [[su]]&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 [[rm]] -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 [[ln]] -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/[[mkinitrd]] /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
 /sbin/[[grub-install]]&lt;br /&gt;
 [[reboot]]&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append to your config to ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 [[cat]] &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/[[lilo.conf]]&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==instructions on how to apply patches to your kernel==&lt;br /&gt;
&lt;br /&gt;
[http://www.linuxhq.com/patch-howto.html read this] or look below ...&lt;br /&gt;
&lt;br /&gt;
This step comes after untarring your kernel source. When you download the patch, place it in the folder where you untarred your new kernel. Then type:&lt;br /&gt;
  patch -E -p1  &amp;lt; sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
Regarding having alternative boot options, this is no problem. The stuff above that I tell you to add to your lilo or grub file above could just be appended to the file, and you could just add &amp;quot;.old&amp;quot; to the title of your original kernel name for you will know the difference. Whether it's grub or lilo, add &amp;quot;read-only&amp;quot; to the end of the original entries in the lilo.conf, or grub.conf, file.&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33735</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33735"/>
		<updated>2007-05-13T21:41:52Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Installing the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable &amp;lt;CODE&amp;gt;$KV&amp;lt;/CODE&amp;gt; (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 su&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 rm -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 ln -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/mkinitrd /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
   /sbin/grub-install&lt;br /&gt;
   reboot&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append to your config to ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/lilo.conf&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==instructions on how to apply patches to your kernel==&lt;br /&gt;
&lt;br /&gt;
[http://www.linuxhq.com/patch-howto.html read this] or look below ...&lt;br /&gt;
&lt;br /&gt;
This step comes after untarring your kernel source. When you download the patch, place it in the folder where you untarred your new kernel. Then type:&lt;br /&gt;
  patch -E -p1  &amp;lt; sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
Regarding having alternative boot options, this is no problem. The stuff above that I tell you to add to your lilo or grub file above could just be appended to the file, and you could just add &amp;quot;.old&amp;quot; to the title of your original kernel name for you will know the difference. Whether it's grub or lilo, add &amp;quot;read-only&amp;quot; to the end of the original entries in the lilo.conf, or grub.conf, file.&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
	<entry>
		<id>https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33734</id>
		<title>Compile a kernel</title>
		<link rel="alternate" type="text/html" href="https://wiki.linuxquestions.org/index.php?title=Compile_a_kernel&amp;diff=33734"/>
		<updated>2007-05-13T21:41:28Z</updated>

		<summary type="html">&lt;p&gt;Picobyte: /* Installing the kernel source */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Requirements ==&lt;br /&gt;
Not all Linux [[distribution]]s come with all of the components needed to build a kernel. You'll need a C compiler, make, and system header files installed before you can begin to build the kernel. This document assumes you have them. You can test this with:&lt;br /&gt;
 cc -v&lt;br /&gt;
 make -v&lt;br /&gt;
 ls /usr/src/linux&lt;br /&gt;
&lt;br /&gt;
If you want to update your 2.4.x kernel to a 2.6.x, read [http://www.linux-sxs.org/upgrading/migration26.html THIS] and [http://thomer.com/linux/migrate-to-2.6.html that].&lt;br /&gt;
&lt;br /&gt;
== Preparations ==&lt;br /&gt;
&lt;br /&gt;
=== Obtaining the kernel source ===&lt;br /&gt;
To [[compiler|compile]] a kernel, you will need the kernel [[source]]. You can get it from [http://www.kernel.org kernel.org]. Your [[distribution]] may also already provide the kernel source, for instance on the cd or dvd. It is also possible to get the latest kernel development version [[using git]].&lt;br /&gt;
&lt;br /&gt;
=== Installing the kernel source ===&lt;br /&gt;
You can install the kernel source by either installing the package that came with your distribution, or extracting the [[tarball]] you downloaded from kernel.org . You can remain user (don't need to be root) until mentioned.&lt;br /&gt;
&lt;br /&gt;
It is recommended that you put new kernel sources in a subdirectory of your [[home directory]] for example:&lt;br /&gt;
 [[mkdir]] -p /home/$user/src/kernel&lt;br /&gt;
 [[cd]] /home/$user/src/kernel&lt;br /&gt;
&lt;br /&gt;
Download the kernel sources (linux-x.x.x.tar.gz or linux-x.x.x.tar.bz2) in this directory. &lt;br /&gt;
for the remaining to work with this version we'll use a variable ''$KV'' (for kernel version). Replace x.x.x with the kernel version  &lt;br /&gt;
 KV=x.x.x&lt;br /&gt;
&lt;br /&gt;
Extract the sources using one of:&lt;br /&gt;
 [[tar]] -zxvf linux-$KV.tar.gz 	 &lt;br /&gt;
 tar -jxvf linux-$KV.tar.bz2&lt;br /&gt;
&lt;br /&gt;
and enter the created subdirectory&lt;br /&gt;
 cd linux-$KV&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
It is recommended that you do not build in your kernel source directory. &lt;br /&gt;
&lt;br /&gt;
=== Preparing to build ===&lt;br /&gt;
Create another directory in your home directory:&lt;br /&gt;
 mkdir -p /home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
If this is not the first time you compile the kernel you'll have to clean up your build directory. You may want to backup the previous .config file, however:&lt;br /&gt;
 [[cp]] /home/$user/build/kernel/.config /home/$user/kernel.config&lt;br /&gt;
 [[make]] O=/home/$user/build/kernel/$KV/ mrproper&lt;br /&gt;
&lt;br /&gt;
=== Obtaining a configuration ===&lt;br /&gt;
Do this to restore the previous configuration:&lt;br /&gt;
 cp /home/$user/kernel.config /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
Otherwise, if compiling for the first time you may want to start with your distribution's .config You can obtain that from cd or do:&lt;br /&gt;
 [[zcat]] /proc/config.gz &amp;gt; /home/$user/build/kernel/$KV/.config&lt;br /&gt;
&lt;br /&gt;
If you're going to upgrade to a newer kernel, first do:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ oldconfig&lt;br /&gt;
&lt;br /&gt;
For ncurses GUI in the terminal&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ menuconfig&lt;br /&gt;
&lt;br /&gt;
;Notes: Most options are about specifying whether you want a feature [*] compiled into the kernel image, [M] compiled as a module, or [ ] not compiled at all. Do not compile your hard drive and file system type as a module - these must be compiled in the kernel [*], e.g. &amp;quot; [*] ReiserFS&amp;quot;. &lt;br /&gt;
:Here you to specify an enormous number of features. It is advisable to skim through all the sections to get a feel for the different things you can do. The kernel configuration is one LINUX program that offers lots of help--select &amp;lt; Help &amp;gt; on any feature. The raw help file is /usr/src/linux/Documentation/Configure.help can also be worth reading. See also [[configuring linux kernel]].&lt;br /&gt;
:When you're done with the config, click exit and save current configuration. Your file is now known as .config .&lt;br /&gt;
&lt;br /&gt;
=== Extra cleaning for old kernels ===&lt;br /&gt;
-------&amp;gt;SKIP SECTION IF DOING A 2.6.x KERNEL&amp;lt;------&lt;br /&gt;
Respectively 1. ensures dependancies such as include files are in place and 2. clean your sources so they compile correctly:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ dep&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ clean&lt;br /&gt;
&lt;br /&gt;
=== compiling kernel and modules ===&lt;br /&gt;
make the kernel image (compile and creates compressed image of kernel). This may take a while...&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/&lt;br /&gt;
&lt;br /&gt;
make the modules&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules&lt;br /&gt;
&lt;br /&gt;
== installation ==&lt;br /&gt;
for the remainder you need to be root:&lt;br /&gt;
 su&lt;br /&gt;
&lt;br /&gt;
To install the newly compiled modules to &amp;lt;tt&amp;gt;/lib/modules/$KV/&amp;lt;/tt&amp;gt;:&lt;br /&gt;
 make O=/home/$user/build/kernel/$KV/ modules_install&lt;br /&gt;
&lt;br /&gt;
=== Move kernel and related files ===&lt;br /&gt;
Remove the following links:&lt;br /&gt;
 rm -rf /boot/System.map&lt;br /&gt;
 rm -rf /boot/vmlinuz&lt;br /&gt;
&lt;br /&gt;
Then copy the newly created kernel and system.map to /boot&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/arch/i386/boot/bzImage /boot/vmlinuz-$KV&lt;br /&gt;
 cp /home/$user/build/kernel/$KV/System.map /boot/System.map-$KV&lt;br /&gt;
&lt;br /&gt;
Make the new links:&lt;br /&gt;
 ln -s /boot/vmlinuz-$KV /boot/vmlinuz&lt;br /&gt;
 ln -s /boot/System.map-$KV /boot/System.map &lt;br /&gt;
&lt;br /&gt;
Next, if present, remove existing initrd.img file:&lt;br /&gt;
 rm -rf /boot/initrd-$KV.img&lt;br /&gt;
&lt;br /&gt;
And create the new one:&lt;br /&gt;
 /sbin/mkinitrd /boot/initrd-$KV.img $KV&lt;br /&gt;
&lt;br /&gt;
===Install a boot manager===&lt;br /&gt;
Use The Steps That Pertain To You&amp;lt;br&amp;gt;&lt;br /&gt;
*if you use [[grub]] then edit &amp;lt;tt&amp;gt;grub.conf&amp;lt;/tt&amp;gt;&lt;br /&gt;
*if you use [[lilo]] then edit &amp;lt;tt&amp;gt;lilo.conf&amp;lt;/tt&amp;gt; &lt;br /&gt;
:remember to leave the entry to your old kernel image just in case, so modify what is in the config originally to point to the old image and make a new entry for you new image you just made...&lt;br /&gt;
&lt;br /&gt;
====GRUB====&lt;br /&gt;
Note today most distros now use menu.lst, so if you can't find grub or lilo, then you know what to look for.&lt;br /&gt;
 title New Kernel :D&lt;br /&gt;
 kernel /vmlinuz-$KV ro root=LABEL initrd /initrd-$KV.img&lt;br /&gt;
;Note:Look at the previous parameters in the grub.conf file and note what &amp;quot;root=&amp;quot; and use what is existing.&lt;br /&gt;
&lt;br /&gt;
Exit and save grub.conf, and if you want (is not mandatory) type &lt;br /&gt;
   /sbin/grub-install&lt;br /&gt;
   reboot&lt;br /&gt;
&lt;br /&gt;
====Lilo====&lt;br /&gt;
Append to your config to ''/etc/lilo.config'':&lt;br /&gt;
 ROOTDEV=`mount -l | grep &amp;quot; \/ &amp;quot; | cut -d&amp;quot; &amp;quot; -f1`&lt;br /&gt;
 cat &amp;lt;&amp;lt; EOF &amp;gt;&amp;gt; /etc/lilo.conf&lt;br /&gt;
   image = /boot/vmlinuz-$KV&lt;br /&gt;
           label = vml-$KV&lt;br /&gt;
           root = $ROOTDEV&lt;br /&gt;
           read-only&lt;br /&gt;
 EOF&lt;br /&gt;
&lt;br /&gt;
install this lilo.conf (if listed, resolve errors before rebooting!):&lt;br /&gt;
 /sbin/lilo&lt;br /&gt;
&lt;br /&gt;
===Propietary nvidia module===&lt;br /&gt;
For some it is required to install proprietary modules. This can be done after booting, see [[NVIDIA graphics drivers]], or directly from the kernel directory after installation of the kernel if you're upgrading to a newer kernel version, by running as root:&lt;br /&gt;
&lt;br /&gt;
 /path/to/NVIDIA-Linux-*-pkg1.run -a --kernel-name=&amp;quot;`grep -o &amp;quot;2\..\.[0-9]*.*$&amp;quot; .config`&amp;quot; \&lt;br /&gt;
 --no-x-check --no-runlevel-check --kernel-module-only -s;&lt;br /&gt;
&lt;br /&gt;
==instructions on how to apply patches to your kernel==&lt;br /&gt;
&lt;br /&gt;
[http://www.linuxhq.com/patch-howto.html read this] or look below ...&lt;br /&gt;
&lt;br /&gt;
This step comes after untarring your kernel source. When you download the patch, place it in the folder where you untarred your new kernel. Then type:&lt;br /&gt;
  patch -E -p1  &amp;lt; sound_patch&lt;br /&gt;
Purely an example and you would type whatever the file name is in replace of sound_patch.&lt;br /&gt;
&lt;br /&gt;
Regarding having alternative boot options, this is no problem. The stuff above that I tell you to add to your lilo or grub file above could just be appended to the file, and you could just add &amp;quot;.old&amp;quot; to the title of your original kernel name for you will know the difference. Whether it's grub or lilo, add &amp;quot;read-only&amp;quot; to the end of the original entries in the lilo.conf, or grub.conf, file.&lt;br /&gt;
&lt;br /&gt;
=== Special notes for Debian Users ===&lt;br /&gt;
[[Debian]] has some utilities to make your life a little easier. The kernel-package set of utilities allows to to create your own kernel package. For most users, this just means that your kernel shows up like all other debian packages. However, if you have multiple machines running the same kernel, it allows an easy way to install it on all of them. So let's get started.&lt;br /&gt;
&lt;br /&gt;
First, make sure you have the kernel-package tools. You can install them with the command&lt;br /&gt;
   apt-get install kernel-package&lt;br /&gt;
&lt;br /&gt;
The initial steps are the same&lt;br /&gt;
   [[make]] clean &lt;br /&gt;
   make menuconfig (or xconfig etc...). &lt;br /&gt;
Once your kernel is configured, type &lt;br /&gt;
   [[make-kpkg]] kernel_image &lt;br /&gt;
and it will make your kernel. &lt;br /&gt;
&lt;br /&gt;
Assuming the compile was successful, it will create a .deb in /usr/src which you can then install by typing&lt;br /&gt;
   [[dpkg]] -i kernel-package-filename&lt;br /&gt;
follow the instructions and [[reboot]].&lt;br /&gt;
&lt;br /&gt;
You can also create a custom kernel name (to avoid overwriting other kernels you have made) by typing something like: &lt;br /&gt;
   make-kpkg kernel_image --revision=custom.1&lt;br /&gt;
&lt;br /&gt;
This is just a quick review of the commands you need, for more information check out this [http://newbiedoc.sourceforge.net/tutorials/kernel-pkg/index-kernel-pkg.html guide] to compiling using the kernel package program.&lt;br /&gt;
&lt;br /&gt;
[[Category:Kernel]]&lt;br /&gt;
[[Category:Example]]&lt;/div&gt;</summary>
		<author><name>Picobyte</name></author>
	</entry>
</feed>