Вы находитесь на странице: 1из 11

Kernel What is the kernel ?

The kernel is the software that directly manages your hardware, allowing application libraries and software like GNOME and Firefox to run on many types of hardware without much difficulty. Because the Linux kernel is the core component of a GNU/Linux system, a full restart is required to complete the kernel update. Types Ubuntu packages the Linux kernel for a variety of architectures, including several variants of the x86 architecture. These include a 386 version, a 686 version, and versions for the AMD k6 and k7 processors. While most software for x86 processors in Ubuntu is compiled for 386 or better instruction sets, the kernel and a few other packages are specifically compiled for certain processors for speed reasons. Check the package documentation to determine what type of kernel will perform best for your processor. Versions Ubuntu currently packages the 3.8 kernel for optimal desktop speed and features. SMP Some motherboards have more than one processor on them, and some processors have multiple cores. If your computer is like this, then the SMP kernel is for you. Non-SMP kernels will not be able to take advantage of your multiple processors. However, if you do not have multiple processors, the additional code in an SMP kernel will only slow you down. Naturally, Ubuntu provides both SMP and non-SMP kernels for all supported architectures. PAE PAE (Physical Address Extension) allows the 32 bit version of Ubuntu to access up to 64 Gb of memory and is the standard for all members of the Ubuntu family from release 12.10 and beyond, as the non-PAE version has been dropped. For more on this please see here. If your hardware does not support PAE there is an easy workaround called fake-PAE. HowTo Upgrade or Recompile Kernel The precompiled kernels that are supplied with your distro should be fine however if you wish to update or optimise (or standardise) for your platform : From easier (1) to the more difficult (3):

1) You can UpgradeKernel easily using Ubuntu.


2) You can also Kernel/Compile it yourself from LinuxKernelSource or UbuntuKernelSource. 3) Run the following Terminal commands to install a new 32-bit Ubuntu kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline/ sudo apt-get update sudo apt-get install python-bs4 cd /tmp rm -rf medigeek-kmp* wget --no-check-certificate https://github.com/medigeek/kmp-downloader/tarball/master -O

kmpd.tar.gz tar xzf kmpd.tar.gz cd medigeek-* python kmpd.py -d The script at https://github.com/medigeek/kmp-downloader/ does not seem to allow choosing amd64 (64-bit) architecture. It only allows installing i386 (32-bit) architecture. This seems like a bug to me. Just press <ENTER> instead of a number if you get stuck on a certain question in the python script. How to Remove unwanted Kernels from your system Open the Synaptic package manager from the System->Administration menu. Click the Search button on the tool bar and search for "linux-image-2". The results should show every available and installed kernel. A green box on the left indicates that the package is installed. The only linux-image you want installed is the latest one. Find the package corresponding to the kernel to you running currently (this is the kernel you found in the terminal window). Make sure you keep that one. Now you can uninstall the old kernels from the list by clicking their boxes and selecting Mark for Removal.

Or you can uninstall kernels using the ubuntu-tweak Ubuntu PPA package. Instructions are here: http://tech.sixcolumns.com/2012/10/how-to-remove-old-kernels-from-ubuntu-12-10-usingubuntu-tweak/ Experimental Kernel Options

As per the Ubuntu Kernel Team, their typical Kernel configuration policy is that options
marked EXPERIMENTAL are disabled by default, until a request has been made to justify enabling it. For example, one may find out if an option is marked this way via: config RT2800USB_RT35XX bool "rt2800usb - Include support for rt35xx devices (EXPERIMENTAL)" depends on EXPERIMENTAL default y ---help--This adds support for rt35xx wireless chipset family to the rt2800usb driver. Supported chips: RT3572

See also

vt.handoff KernelPanic

Kernel/Upgrade Redirected from page "UpgradeKernel" Clear message

Methods From easier (1) to the more difficult (4): 1) Click on System > Administration > Update Manager > Click on Check button > Apply all updates including kernel. to install (i.e. linux-image-2.6.xx-yy-generic).

2) Use Synaptic, search for linux-image and select the generic kernel version you want 3) Compile the kernel. 4) Run the following Terminal commands to install a new 32-bit Ubuntu kernel from http://kernel.ubuntu.com/~kernel-ppa/mainline/
sudo apt-get update sudo apt-get install python-bs4 cd /tmp rm -rf medigeek-kmp* wget --no-check-certificate https://github.com/medigeek/kmp-downloader/tarball/master -O kmpd.tar.gz tar xzf kmpd.tar.gz cd medigeek-* python kmpd.py -d The script at https://github.com/medigeek/kmp-downloader/ does not seem to allow choosing amd64 (64-bit) architecture. It only allows installing i386 (32-bit) architecture. This seems like a bug to me. Just press <ENTER> instead of a number if you get stuck on a certain question in the python script. Roll-back and uninstallation You can roll back by selecting the previous (old) kernel at the boot menu and then uninstall the (new) not working kernel. With

Synaptic you can uninstall previously installed kernel packages.

See also

Kernel
Kernel/Compile

Contents

1. 2. 3. 4. 5.

Disclaimer Reasons for compiling a custom kernel Reasons for NOT compiling a custom kernel Tools you'll need Get the kernel source 1. A) Use git 2. B) Download the source archive 3. C) Download the source package 6. Modify the source for your needs 7. Build the kernel (when source is from git repository, or from apt-get source) 8. Alternate Build Method: The Old-Fashioned Debian Way 9. Install the new kernel 10.Rebuilding ''linux-restricted-modules'' 11.Speeding Up the Build 12.More documentation 13.Comments 14.External information

Disclaimer Building and using a custom kernel will make it very difficult to get support for your system. While it is a learning experience to compile your own kernel, you will not be allowed to file bugs on the custom-built kernel (if you do, they will be Rejected without further explanation). Note: This page would need significant cleaning. You may want to refer to Kernel/BuildYourOwnKernel page in Ubuntu wiki instead which is a cleaner and more up-to-date guide to (simple) kernel building If you have a commercial support contract with Ubuntu/Canonical, this will void such support. Also note that this page describes how to do things for the Edgy (2.6.17) kernel and newer! Until this kernel source, we did not have any mechanisms in place that would allow people to build their own kernels easily. This was intentional. This page does NOT describe how to build upstream kernels from kernel.org. This is how to rebuild the actual Ubuntu kernel starting from source. Reasons for compiling a custom kernel You are a kernel developer. You need the kernel compiled in a special way, that the official kernel is not compiled in (for example, with some experimental feature enabled). You are attempting to debug a problem in the stock Ubuntu kernel for which you have filed or will file a bug report. You have hardware the stock Ubuntu kernel does not support. You love computers and are curious and interested in hacking on your own GNU/Linux system to learn more about how it works (with the understanding that you'll need to fix anything you break).

Reasons for NOT compiling a custom kernel You merely need to compile a special driver. For this, you only need to install the linuxheaders packages. You have no idea what you are doing, and if you break something, you'll need help fixing it. Depending on what you do wrong, you might end up having to reinstall your system from scratch. You got to this page by mistake, and checked it out because it looked interesting, but you don't really want to learn a lot about kernels.

If you want to install a new kernel without compilation, you can use image and select the kernel version you want to install.

Synaptic, search for linux-

An easier way is to click on System > Administration > Update Manager, then click on the Check button, and finally click on Apply all updates including the kernel. Tools you'll need To start, you will need to install a few packages. The exact commands to install those packages depends on which release you are using: Hardy (8.04): sudo apt-get install linux-kernel-devel fakeroot kernel-wedge build-essential Note: The package makedumpfile is not available in Hardy. Lucid (10.04): sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge sudo apt-get build-dep linux sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev

Get the kernel source There are a few ways to obtain the Ubuntu kernel source: A) Use git

Use git (detailed instructions on it can be found in the Kernel Git Guide) - This is for
users who always want to stay in sync with the latest Ubuntu kernel source. The git repository does not include necessary control files, so you must build them by: fakeroot debian/rules clean

B) Download the source archive

Download the source archive - This is for users who want to rebuild the standard Ubuntu
packages with additional patches. Note that this will almost always be out of date compared to the latest development source, so you should use git (option A) if you need the latest patches. To install the build dependencies and extract the source (to the current directory): Ubuntu Hardy (8.04) sudo apt-get build-dep --no-install-recommends --only-source linux apt-get source --only-source linux Ubuntu modules source may also be needed if you plan to enable PAE and 64 GiB support in the kernel for 32-bit Hardy (8.04). The Ubuntu supplied modules may not be

compatible with a PAE enabled kernel. sudo apt-get build-dep --no-install-recommends linux-ubuntu-modules-$(uname -r) apt-get source linux-ubuntu-modules-$(uname -r) The source will be downloaded to a subdirectory inside the current directory. Ubuntu Karmic Koala (9.10) and newer releases sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r) apt-get source linux-image-$(uname -r)

The source will be downloaded to the current directory (for Lucid, at least) as a trio of
files (.orig.tar.gz, .diff.gz, and .dsc) and a sub-directory. For instance, if uname -r returns 2.6.32-25-generic, you'll obtain linux_2.6.32.orig.tar.gz, linux_2.6.32-25.44.diff.gz, linux_2.6.32-25.44.dsc and the sub-directory linux-2.6.32. C) Download the source package

Download the source package (detailed instructions are further down this page under Alternate Build Method: The Old-Fashioned Debian Way) - This is for users who simply
want to modify, or play around with, the Ubuntu-patched kernel source. Again, this will not be the most up-to-date (use option A/git if you need the latest source). Please be aware this is NOT the same as option B. Modify the source for your needs For most people, simply modifying the configs is enough. If you need to install a patch, read the instructions from the patch provider to learn how to apply it. The stock Ubuntu configs are located in debian/config/ARCH/ where ARCH is the architecture you are building for (Starting with Jaunty this is debian.master/config/ARCH/). In this directory there are several files. The config file is the base for all targets in that architecture. Then there are several config.FLAVOUR files that contain options specific to that target. For example, here are the files for 2.6.20, i386: ls -l debian/config/i386/ total 108 -rw-r--r-- 1 root src 73962 2007-08-13 01:29 config -rw-r--r-- 1 root root 1369 2007-08-13 01:29 config.386 -rw-r--r-- 1 root root 1330 2007-08-13 01:29 config.generic -rw-r--r-- 1 root root 1395 2007-08-13 01:29 config.server -rw-r--r-- 1 root root 1756 2007-08-13 01:29 config.server-bigiron -rw-r--r-- 1 root root 8 2007-08-13 01:25 lowlatency -rw-r--r-- 1 root root 194 2007-08-13 01:25 vars.386 -rw-r--r-- 1 root root 218 2007-08-13 01:25 vars.server-bigiron If you do not find the config files under debian/config, you may find them in your /boot directory (for instance, /boot/config-2.6.22-14-generic) otherwise you should check to see if an alternate location has been specified within debian/debian.env of your kernel source directory. If you need to change a config option, simply modify the file that contains the option. If you modify just the config file, it will affect all targets for this architecture. If you modify one of the target files, it only affects that target. After applying a patch, or adjusting the configs, it is always best to regenerate the config files to ensure they are consistent. There is a helper command for this. To regenerate all architectures run: debian/rules updateconfigs

If you just want to update one architecture, run: debian/scripts/misc/oldconfig ARCH Note: If you don't have the debian/ directory after using apt-get source, use dpkg-source x *dsc to extract the sources properly. For these two commands to work, you need to give the scripts in the debian/scripts/misc and debian/scripts directories execute permission with the following command: chmod -R u+x debian/scripts/*

Build the kernel (when source is from git repository, or from apt-get source) To build the kernel(s) is very simple. Depending on your needs, you may want to build all the kernel targets, or just one specific to your system. However, you also want to make sure that you do not clash with the stock kernels. Note: Though these outside instructions include making a separate and unique branch of the kernel, unlike here, they include thorough explanations of all necessary steps from start to finish.

Oneiric (11.10) Kernel 3.2 : http://blog.avirtualhome.com/2012/01/13/compile-linux-kernel3-2-for-ubuntu-11-10/ Oneiric (11.10) : http://blog.avirtualhome.com/2011/10/28/how-to-compile-a-new-ubuntu11-10-oneiric-kernel/ Maverick on Lucid (10.04): http://blog.avirtualhome.com/2010/07/14/how-to-compile-aubuntu-2-6-35-kernel-for-lucid/ Lucid (10.04): http://blog.avirtualhome.com/2010/05/05/how-to-compile-a-ubuntu-lucidkernel/
These instructions are specific to the git-tree and for the source downloaded via apt-get source, not when downloading the linux-source package from kernel.org Use this command to build all targets for the architecture you are building on: fakeroot debian/rules clean AUTOBUILD=1 fakeroot debian/rules binary-debs debian/rules clean creates debian/control, debian/changelog, and so on from debian.<branchname>/* (e.g. debian.master). It is necessary in git trees following git commit 3ebd3729ce35b784056239131408b9a72b0288ef "UBUNTU: [Config] Abstract the debian directory". The AUTOBUILD environment variable triggers special features in the kernel build. First, it skips normal ABI checks (ABI is the binary compatibility). It can do this because it also creates a unique ABI ID. If you used a git repo, this unique ID is generated from the git HEAD SHA. If not, it is generated from the uuidgen program (which means every time you execute the debian/rules build, the UUID will be different!). Your packages will be named using this ID. (Note that in Intrepid and newer, you will need skipabi=true to skip ABI checks.) To build a specific target, use this command: fakeroot debian/rules clean AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binary-FLAVOUR Where FLAVOUR is one of the main flavours of the kernel (e.g. generic) To build one of the custom flavours (found in debian/binary-custom.d/), use: fakeroot debian/rules clean

AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules custom-binary-FLAVOUR As of this documentation, custom flavours include xen and rt. If you have a more than one processor or more than one core, you can speed things up by running concurrent compile commands. Prepend CONCURRENCY_LEVEL=2 for two processors or two cores; replace '2' with whatever number suits your hardware setup (for Gutsy and later, you can alternatively use DEB_BUILD_OPTIONS=parallel=2). fakeroot debian/rules clean DEB_BUILD_OPTIONS=parallel=2 AUTOBUILD=1 NOEXTRAS=1 fakeroot debian/rules binarygeneric If you get ABI errors, you can avoid the ABI check with skipabi=true. For example, fakeroot debian/rules clean DEB_BUILD_OPTIONS=parallel=2 AUTOBUILD=1 NOEXTRAS=1 skipabi=true fakeroot debian/rules binary-generic To trigger a rebuild, remove the appropriate stamp file from debian/stamps (e.g. stamp-buildserver for the server flavour, etc.). The debs are placed in your kernel directory's parent directory. If needed, the Ubuntu modules source for Hardy (8.04) can be built in a similar way. cd linux-ubuntu-modules-2.6.24-2.6.24 AUTOBUILD=1 fakeroot debian/rules binary-debs Alternatively, if you need to specify a different kernel than the running one, use cd linux-ubuntu-modules-2.6.24-2.6.24 AUTOBUILD=1 fakeroot debian/rules binary-debs KDIR=/path/to/kerneldir If you get an error, try running this in the kerneldir: (example for the generic flavour) cat debian/config/i386/config debian/config/i386/config.generic > .config make prepare scripts

Alternate Build Method: The Old-Fashioned Debian Way The new Ubuntu build system is great for developers, for people who need the absolute latest bleeding-edge kernel, and people who need to build a diverse set of kernels (several "flavours"). However it can be a little complex for ordinary users. If you don't need the latest development sources, there is a simpler way to compile your kernel from the linux-source package. As suggested above, all you need for this is: sudo apt-get install linux-source device-tree-compiler # device-tree-compiler is only needed if you are targeting the PowerPC architecture mkdir ~/src cd ~/src tar xjvf /usr/src/linux-source-<version-number-here>.tar.bz2 cd linux-source-<version-number-here> Now you are in the top directory of a kernel source tree. Before building the kernel, you must configure it. If you wish to re-use the configuration of your currently-running kernel, start with cp -vi /boot/config-`uname -r` .config Before you run make menuconfig or make xconfig (which is what the next step tells you to do), make sure you have the necessary packages: sudo apt-get install qt3-dev-tools libqt3-mt-dev # if you plan to use 'make xconfig'

sudo apt-get install libncurses5 libncurses5-dev # if you plan to use 'make menuconfig' If you would like to see what is different between your original kernel config and the new one (and decide whether you want any of the new features), you can run: make oldconfig Since the 2.6.32 kernel, a new feature allows you to update the configuration to only compile modules that are actually used in your system: make localmodconfig Then, regardless of whether you're re-using an existing configuration or starting from scratch: make menuconfig # or "make xconfig" if you prefer If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into the config's "Kernel hacking"<!-- ; then, under "Kernel debugging", --> and turn OFF "Compile the kernel with debug info". Now you can compile the kernel and create the packages: make clean # only needed if you want to do a "clean" build make deb-pkg You can enable parallel make use make -j). Try 1+number of processor cores, e.g. 3 if you have a dual core processor: make -j3 deb-pkg The *.deb packages will be created in the parent directory of your Linux source directory (in this example, they would be placed in ~/src because our Linux source directory is ~/src/linuxsource-<version-number-here>). Install the new kernel If you want to see the Ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you'll want to make sure the framebuffer driver loads: echo vesafb | sudo tee -a /etc/initramfs-tools/modules echo fbcon | sudo tee -a /etc/initramfs-tools/modules Now that you've told initramfs-tools which modules it should include, and once the build is complete, you can install the generated debs using dpkg: sudo dpkg -i linux-image-2.6.20-16-2be-k7_2.6.20-16_i386.deb sudo dpkg -i linux-headers-2.6.20-16-2be-k7_2.6.20-16_i386.deb Similarly, if you have built the Ubuntu module for Hardy (8.04) earlier, install them as follows: sudo dpkg -i linux-ubuntu-modules-2.6.24-16-generic_2.6.24-16.23_i386.deb sudo dpkg -i linux-headers-lum-2.6.24-16-generic_2.6.24-16.23_i386.deb If you use modules from linux-restricted-modules, you will need to recompile this against your new linux-headers package. Note: In response to the various comments in the remainder of this section: On Ubuntu Precise (12.04) it appears that postinst DOES take care of the initramfs stuff. After installing the package my new kernel booted just fine without following any of the methods below. Someone please correct me if I'm mistaken. Since Ubuntu Lucid (10.04) the image postinst no longer runs the initramfs creation commands.

Instead, there are example scripts provided that will perform the task. These scripts will work for official kernel images as well. For example: sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postinst.d/initramfs /etc/kernel/postinst.d/initramfs sudo mkdir -p /etc/kernel/postrm.d/ sudo cp /usr/share/doc/kernel-package/examples/etc/kernel/postrm.d/initramfs /etc/kernel/postrm.d/initramfs Note: I couldn't get the above scripts to help in generating an initrd for the kernel - and so the built kernel couldn't boot; the only thing that worked for me was the recommendation in http://www.debian-administration.org/article/How_Do_I_Make_an_initrd_image, "use initramfs command. It is real solution."; what I used (after the custom-built kernel's *.deb's were installed), was: cd /boot sudo mkinitramfs -k -o initrd.img-2.6.32.15+drm33.5-mylucid 2.6.32.15+drm33.5-mylucid sudo update-grub2 Note (Michael): that is because you need to include the right package scripts to build the initrd at package install time. The make-kpkg option is --overlay-dir. By default, make-kpkg uses /usr/share/kernel-package as an overlay directory, which contains the default, uncustomised scripts for a Debian distribution, and not the ones needed for building a Ubuntu kernel.

http://crashcourse.ca/introduction-linux-kernelprogramming/intermission-building-new-ubuntu-1004-kernel-free-lesson
The following instructions are based on this link: First copy the default overlay directory to your home directory: $ cp -r /usr/share/kernel-package $HOME Then install the source of the kernel you are using currently, using the exact package name, e.g. $ cd $ apt-get source linux-image-2.6.32-24-generic which will unpack the sources to $HOME/linux-2.6.32. Now copy the control scripts into your new overlay: $ cp linux-2.6.32/debian/control-scripts/{postinst,postrm,preinst,prerm} kernelpackage/pkg/image/ $ cp linux-2.6.32/debian/control-scripts/headers-postinst kernel-package/pkg/headers/ And now you can execute make-kpkg with the additional command line option --overlaydir=$HOME/kernel-package. Rebuilding ''linux-restricted-modules'' The linux-restricted-modules (l-r-m) package contains a number of non-DFSG-free drivers (as well as some firmware and the ipw3945 wireless networking daemon) which, in a perfect world, wouldn't have to be packaged separately, but which unfortunately are not available under a GPL-compatible license. If you use any of the hardware supported by the l-r-m package, you will likely find that your system does not work as well after switching to a custom kernel. In this case you should try to compile the l-r-m package. See CustomRestrictedModules on how to rebuild l-r-m (if you use nVidia or ATI binary drivers, you do). Note: you will need around 8 hours of compilation time and around 10 Gb of hard drive space to compile all kernel flavours and restricted modules. Further note: There are no l-r-m or linux-restricted-modules packages in Lucid.

Speeding Up the Build Use distcc and, if you're rebuilding often, ccache. A good overview of using distcc on a debianbased system is available at http://myrddin.org/howto/using-distcc-with-debian. If you have AMD64 machines available on your local net, they can still participate in building 32-bit code; distcc seems to handle that automatically. However, with distcc taking over all compiles by default, you will need to set HOSTCC so that when kernel builds want to use the compiler on the host itself, they don't end up distributing jobs to the 64-bit server. If you fail to do that, you'll get link-compatibility failures between 64-bit and 32-bit code. My make-kpkg command, with /usr/lib/ccache at the head of my $PATH, looks like: MAKEFLAGS="HOSTCC=/usr/bin/gcc CCACHE_PREFIX=distcc" make-kpkg --rootcmd fakeroot --initrd --append-to-version=-suspend2 kernel-image kernel-headers kernel-source

More documentation

https://help.ubuntu.com/community/forum/software/CustomKernel UpgradeKernel , with easier ways.


Comments Please go to the community wiki page for comments, questions and discussion:

https://wiki.ubuntu.com/KernelCustomBuild
External information

http://www.howtoforge.com/kernel_compilation_ubuntu Compile a kernel from kernel.org


source in Ubuntu

http://kernel-handbook.alioth.debian.org/ch-common-tasks.html#s-common-building

In this article 'How To Update Ubuntu Kernel' example is showed for Kernel 2.6.39-0. If you want to know list of Kernel releases for Ubuntu, then you should to go the site lake are List or Check Installed Linux Kernels. You will find easy that site using Google. There you will be able to see Kernels for other Linux distributions also, but to see for Ubuntu, just scroll page down. To add Kernel repository, open Terminal and type the following command or use copy/paste method*: sudo add-apt-repository ppa:kernel-ppa/ppa and hit Enter. After you hit Enter, then it will asks you for password, so type the password and hit Enter*. Now you need to type the following command or use copy/paste method*: sudo apt-get update and hit Enter. Type the following command or to use copy/paste method to check did you add Kernel properly*: apt-cache showpkg linux-headers and hit Enter. On the list in the Terminal will be appear 3*.8.0-26 kernel if you have add the properly commands. Finally, type the following command or use copy/paste method to update your Kernel*: sudo apt-get install linux-headers-3.8.0-26 linux-headers-3.8.0-26-generic linux-image3.8.0-26-generic fix-missing Don't forget to restart your system for the changes to take effect*.

Вам также может понравиться