Compile Linux Kernel on Ubuntu 12.10
2013-09-24 18:31
399 查看
Solution A: Mainly from http://mitchtech.net/compile-linux-kernel-on-ubuntu-12-04-lts-detailed/
There are too many manuals for Ubuntu kernel compile and update, but most of them does not work for me except http://mitchtech.net/compile-linux-kernel-on-ubuntu-12-04-lts-detailed/. I did it on Ubuntu 12.10 with kernel 3.5.7.
Steps:
0. Install make tools:
sudo apt-get install libncurses5 libncurses5-dev
1. make and install kernel
cd linux-3.5.7/
cp -vi /boot/config-3.5.0-17-generic .config
make oldconfig
make localmodconfig
make menuconfig
make -j5
sudo make modules_install install
2. remove the files in /boot and /lib/modules
cd /boot
sudo mv *3.5.0-* backup/
cd /lib/modules/
sudo mv 3.5.0-17-generic backup/
3.rebuild grub
sudo update-grub2
4.reboot and run Ubuntu with new kernel
sudo reboot
Solution B:
The majority of users that are interested in building their own kernel are doing so because they have installed Ubuntu on their system and they wish to make
a small change to the kernel for that system. In many cases the user just wants to make a kernel configuration change.
The purpose of this page is to give that user a minimum amount of information for them to meet the goal of making a simple change to the kernel, building it and
installing their kernel. It is not intended to be the definitive guide to doing Ubuntu kernel development.
If you have installed a version of Ubuntu and you want to make changes to the kernel that is installed on your system, use the apt-get method
(described below) to obtain the sources.
However, if you wish to get the most up to date sources for the Ubuntu release you are running and make changes to that, use the git method
(described below) to obtain the sources.
The source code which generated a specific binary package may be obtained using the apt-get source <package>command. For example to obtain the source for
the currently running kernel you can use the command:
All of the Ubuntu Kernel source is maintained under git. The source for each release is maintained in its own git repository on kernel.ubuntu.com. To
obtain a local copy you can simply git clone the repository for the release you are interested in as shown below.
For example to obtain the maverick tree:
This take the current configuration for each architecture/flavour supported and call menuconfig for that. The chmod is needed because the way the source package is created loses the executable bits on the scripts.
If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version "2.6.38-7.37" on an amd64 system, these three .deb packages would be produced:
simple configuration changes you may want to look at:
Kernel/BuildYourOwnKernel (last edited 2012-08-28 13:10:18 by timg-tpi)
There are too many manuals for Ubuntu kernel compile and update, but most of them does not work for me except http://mitchtech.net/compile-linux-kernel-on-ubuntu-12-04-lts-detailed/. I did it on Ubuntu 12.10 with kernel 3.5.7.
Steps:
0. Install make tools:
sudo apt-get install libncurses5 libncurses5-dev
1. make and install kernel
cd linux-3.5.7/
cp -vi /boot/config-3.5.0-17-generic .config
make oldconfig
make localmodconfig
make menuconfig
make -j5
sudo make modules_install install
2. remove the files in /boot and /lib/modules
cd /boot
sudo mv *3.5.0-* backup/
cd /lib/modules/
sudo mv 3.5.0-17-generic backup/
3.rebuild grub
sudo update-grub2
4.reboot and run Ubuntu with new kernel
sudo reboot
Solution B:
BuildYourOwnKernel
This page will describe how to easily build the kernel.The majority of users that are interested in building their own kernel are doing so because they have installed Ubuntu on their system and they wish to make
a small change to the kernel for that system. In many cases the user just wants to make a kernel configuration change.
The purpose of this page is to give that user a minimum amount of information for them to meet the goal of making a simple change to the kernel, building it and
installing their kernel. It is not intended to be the definitive guide to doing Ubuntu kernel development.
Obtaining the source for an Ubuntu release
There are a number of different ways of getting the kernel sources. The two main ways will be documented here.If you have installed a version of Ubuntu and you want to make changes to the kernel that is installed on your system, use the apt-get method
(described below) to obtain the sources.
However, if you wish to get the most up to date sources for the Ubuntu release you are running and make changes to that, use the git method
(described below) to obtain the sources.
apt-get
The source code which generated a specific binary package may be obtained using the apt-get source <package>command. For example to obtain the source forthe currently running kernel you can use the command:
apt-get source linux-image-$(uname -r)
git
All of the Ubuntu Kernel source is maintained under git. The source for each release is maintained in its own git repository on kernel.ubuntu.com. Toobtain a local copy you can simply git clone the repository for the release you are interested in as shown below.
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-<release>.git
For example to obtain the maverick tree:
git clone git://kernel.ubuntu.com/ubuntu/ubuntu-maverick.git
Build Environment
If you've not built a kernel on your system before, there are some packages needed before you can successfully build. You can get these installed with:sudo apt-get build-dep linux-image-$(uname -r)
Modifying the configuration
This step can be skipped if no configuration changes are wanted. The build process will use a configuration that is put together from various sub-config files. The simplest way to modify anything here is to run:chmod a+x debian/scripts/* chmod a+x debian/scripts/misc/* fakeroot debian/rules clean fakeroot debian/rules editconfigs
This take the current configuration for each architecture/flavour supported and call menuconfig for that. The chmod is needed because the way the source package is created loses the executable bits on the scripts.
Building the kernel
Building the kernel is quite easy. Change your working directory to the root of the kernel source tree and then type the following commands:fakeroot debian/rules clean fakeroot debian/rules binary-headers binary-generic
If the build is successful, a set of three .deb binary package files will be produced in the directory above the build root directory. For example after building a kernel with version "2.6.38-7.37" on an amd64 system, these three .deb packages would be produced:
cd .. ls *.deb linux-headers-2.6.38-7_2.6.38-7.37_all.deb linux-headers-2.6.38-7-generic_2.6.38-7.37_amd64.deb linux-image-2.6.38-7-generic_2.6.38-7.37_amd64.deb
Testing the new kernel
Install the three-package set (on your build system, or on a different target system) with dpkg -i and then reboot:sudo dpkg -i linux*2.6.38-7.37*.deb sudo reboot
See also
The above instructions provide a very simple recipe for obtaining the sources and then building them. If you are going to be doing more kernel development thansimple configuration changes you may want to look at:
Git the source | More information about using git to pull down the kernel sources. |
ARM Cross Compile | For more info about ARM and cross compilation. |
相关文章推荐
- Compile the latest Kernel(linux-3.1-rc4) On Ubuntu Plateform
- compile rtplib3.9.1 on linux(ubuntu 12.10)
- Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed)
- Compile the latest Kernel(linux-3.1-rc4) On Ubuntu Plateform
- linux kernel stable compile on ubuntu
- Compile Linux Kernel on Ubuntu 12.04 LTS
- 编译Xen 3.4 Dom0 using Linux Kernel 2.6.31 on Ubuntu 9.10 (Karmic)
- How can compile Mali-T764 DRIVERS on Ubuntu Linux 14.04 on RK3288 device
- ubuntu环境下编译内核详解(linux kernel compile)
- Installing CUDA Toolkit 5.0 on Ubuntu 12.10 Linux
- Compile Linux Kernel in Ubuntu
- Compile my helloworld cpp program on Ubuntu linux
- the instructuion of ARMLinux kernel Compile
- arm-linux-gcc compile the cross-platform mpich2 on ubuntu
- Building AMDGPU Development Linux 4.15 Kernel on Ubuntu 17.04
- How to Install Oracle Java on Ubuntu Linux
- PFQ: a Linux kernel module for packet capturing on multi-core architectures
- How to Compile Linux Kernel from Source to Build Custom Kernel
- Ubuntu 12.04-12.10 Linux 3D桌面完全教程,显卡驱动安装方法,compiz特效介绍,常见问题解答
- Compile FFmpeg on Ubuntu