====== Recompiling_Ubuntu's_Kernel ====== ===== Recompiling the Kernel in Ubuntu ===== * Since pretty much every command in this guide will require root privileges, change to root first: sudo su * First install the packages that will be necessary to recompile the kernel: apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 * You'll also need the kernel source: apt-get install linux-source * Change to the **/usr/src** directory: cd /usr/src * You should have a file in this directory named something like **"linux-source-2.6.24.tar.bz2"**. Unzip it: tar -xjf //linux-source-2.6.24.tar.bz2// * Create a symlink named "linux" to the directory that tar created: ln -s //linux-source-2.6.24// linux * Change into that directory (symlink): cd linux * Copy your current kernel's configuration file to the current directory, but named **".config"**: cp /boot///config-2.6.24-generic// ./.config :This will allow you to load the current kernel's configuration into the build configuration program, so you can just change what you want, without having to change everything. * Run the kernel configuration application: make menuconfig * Select the **"Load an Alternative Configuration"** option at the bottom of the screen. It'll ask you for a filename, and the default is the ".config" file we just copied our current configuration to, so just press enter. Now you can browse all the configuration options changing what you need. Get rid of anything you won't need so you can keep the kernel as fast as possible, and enable anything you do need (e.g. Physical Address Extension, which is under the **"Processor Type and Features"** menu, named **"High Memory Support"**; set it to **"64GB"** to enable PAE). * Run: make-kpkg clean * Run: fakeroot make-kpkg --initrd --append-to-version=//**-my-custom-kernel//** kernel_image kernel_headers :replacing **"my-custom-kernel"** with a string of your choice, used to identify the kernel (it'll show up in the kernel's name – in ''`uname –r`'' - as, for example, **"2.6.24-my-custom-kernel"**). This process can take a very long time, so go and do something else for an hour or so. * Change up a directory: cd .. * Install the .deb packages for both your new kernel and the headers. These .deb files can be transported to another system (with similar hardware) to save recompiling it again on that machine. To do this, run: dpkg -i //linux-image-2.6.24-**my-custom-kernel**_2.6.24-**my-custom-kernel**-10.00.Custom_i386.deb// :and dpkg -i //linux-headers-2.6.24-**my-custom-kernel**_2.6.24_**my-custom-kernel**-10.00.Custom_i386.deb// ==== Warning ==== Certain alpha builds of Ubuntu Hardy Heron (8.04) have a bug in the **update-grub** script that the ''dpkg'' command runs leading to an error message saying that **"/var/cache/debconf/config.dat is locked by another process"**. This is a known bug and has been fixed, apparently, but my workaround was to copy the **/usr/sbin/update-grub** script from a 7.10 Ubuntu installation into the local **/usr/sbin** directory then re-running the ''dpkg'' commands above. It will warn that a directory already exists, but as it was from a failed installation just answer "no" to the prompt. ===== See Also ===== https://help.ubuntu.com/community/Kernel/Compile#Alternate Build Method: The Old-Fashioned Debian Way http://ubuntuforums.org/showpost.php?p=9638461&postcount=1488 ===== References ===== http://www.howtoforge.com/kernel_compilation_ubuntu
http://www.beginlinux.com/index.php/desktop_training/ubuntu/ubfile_m/ub_compile