Compile Linux Kernel on Ubuntu 12.04 LTS
2013-03-31 02:02
561 查看
http://mitchtech.net/compile-linux-kernel-ubuntu-12-04-lts/
This tutorial will outline the process to compile your own kernel for Ubuntu. It will demonstrate both the traditional process using ‘make’ and ‘make install’ as well as the Debian method, using ‘make-dpkg’. This is a quick overview of the compilation process,
for a more thourough walkthrough, see
Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed). In both cases, we begin by installing some dependencies:
sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev linux-source qt3-dev-tools libqt3-mt-dev libncurses5 libncurses5-dev fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge kernel-package
Note: qt3-dev-tools and libqt3-mt-dev is necessary if you plan to use ‘make xconfig’ and libncurses5 and libncurses5-dev if you plan to use ‘make menuconfig’. Next, copy the kernel sources with wget:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.17.tar.bz2
Extract the archive and change into the kernel directory:
tar -xjvf linux-3.2.17.tar.bz2 cd linux-3.2.17/
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 by copying the current config contained in /boot:
cp -vi /boot/config-`uname -r` .config
Parse the .config file using make with the oldconfig flag. If there are new options available in the downloaded kernel tree, you may be prompted to make a selection to include them or not. If unsure, press enter to accept the defaults.
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. As above, make selections if prompted, otherwise hit enter for the defaults.
make localmodconfig
Now you can configure the build with ncurses using the ‘menuconfig’ flag:
make menuconfig
or, using a GUI with the ‘xconfig’ flag:
make xconfig
Now we are ready to start the build. You can speed up the compilation process by enabling parallel make with the -j flag. The recommended use is ‘processor cores + 1′, e.g. 5 if you have a quad core processor:
make -j5
Once the initial compilation has completed, install the dynamically loadable kernel modules:
sudo make modules_install
Finally, install the kernel:
sudo make install
using ‘make’ and ‘make install’, we use ‘make-kpkg’:
fakeroot make-kpkg –initrd –append-to-version=-some-string-here kernel-image kernel-headers
Unlike above, you cannot enable parallel compilation with make-kpkg using the -j flag. Instead, define the CONCURRENCY_LEVEL environment variable.
export CONCURRENCY_LEVEL=3
Once the compilation has completed, you can install the kernel and kernel headers using dpkg:
sudo dpkg -i linux-image-3.2.14-mm_3.2.14-mm-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-3.2.14-mm_3.2.14-mm-10.00.Custom_amd64.deb
This tutorial will outline the process to compile your own kernel for Ubuntu. It will demonstrate both the traditional process using ‘make’ and ‘make install’ as well as the Debian method, using ‘make-dpkg’. This is a quick overview of the compilation process,
for a more thourough walkthrough, see
Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed). In both cases, we begin by installing some dependencies:
sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev linux-source qt3-dev-tools libqt3-mt-dev libncurses5 libncurses5-dev fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge kernel-package
Note: qt3-dev-tools and libqt3-mt-dev is necessary if you plan to use ‘make xconfig’ and libncurses5 and libncurses5-dev if you plan to use ‘make menuconfig’. Next, copy the kernel sources with wget:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.17.tar.bz2
Extract the archive and change into the kernel directory:
tar -xjvf linux-3.2.17.tar.bz2 cd linux-3.2.17/
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 by copying the current config contained in /boot:
cp -vi /boot/config-`uname -r` .config
Parse the .config file using make with the oldconfig flag. If there are new options available in the downloaded kernel tree, you may be prompted to make a selection to include them or not. If unsure, press enter to accept the defaults.
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. As above, make selections if prompted, otherwise hit enter for the defaults.
make localmodconfig
Now you can configure the build with ncurses using the ‘menuconfig’ flag:
make menuconfig
or, using a GUI with the ‘xconfig’ flag:
make xconfig
Now we are ready to start the build. You can speed up the compilation process by enabling parallel make with the -j flag. The recommended use is ‘processor cores + 1′, e.g. 5 if you have a quad core processor:
make -j5
Once the initial compilation has completed, install the dynamically loadable kernel modules:
sudo make modules_install
Finally, install the kernel:
sudo make install
Debian Method:
Instead of the compilation process of above, you can alternatively compile the kernel as installable .deb packages. This improves the portability of the kernel, since installation on a different machine is as simple as installing the packages. Rather thanusing ‘make’ and ‘make install’, we use ‘make-kpkg’:
fakeroot make-kpkg –initrd –append-to-version=-some-string-here kernel-image kernel-headers
Unlike above, you cannot enable parallel compilation with make-kpkg using the -j flag. Instead, define the CONCURRENCY_LEVEL environment variable.
export CONCURRENCY_LEVEL=3
Once the compilation has completed, you can install the kernel and kernel headers using dpkg:
sudo dpkg -i linux-image-3.2.14-mm_3.2.14-mm-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-3.2.14-mm_3.2.14-mm-10.00.Custom_amd64.deb
相关文章推荐
- Compile Linux Kernel on Ubuntu 12.04 LTS (Detailed)
- (转)Ubuntu 12.04 LTS安装VMware Tools实现linux和window 互相复制:无法找到kernel header path的问题
- linux kernel stable compile on ubuntu
- Compile Linux Kernel on Ubuntu 12.10
- Compile the latest Kernel(linux-3.1-rc4) On Ubuntu Plateform
- Compile the latest Kernel(linux-3.1-rc4) On Ubuntu Plateform
- How to Compile Android on Ubuntu (12.04)
- Vim的Python编辑器详细配置过程 (Based on Ubuntu 12.04 LTS)
- (Mark) (Ubuntu)Ubuntu 12.04 LTS 64bit安装QuartusII 12.1sp1 (Linux) (Quartus II)
- Vim的Python编辑器详细配置过程 (Based on Ubuntu 12.04 LTS)
- 看看一个小时能Install CUDA 5 on Ubuntu 12.04 LTS
- ubuntu_Install Android SDK on Ubuntu 12.04 LTS
- How to compile/build QEMU 1.4.0 on Ubuntu 12.04
- Vim的Python编辑器详细配置过程 (Based on Ubuntu 12.04 LTS)
- Ubuntu 12.04 LTS安装VMware Tools无法找到kernel header path的问题 (转
- 升级 Vim 7.4 On Ubuntu 13.10, 13.04, 12.04, Linux...
- Building AMDGPU Development Linux 4.15 Kernel on Ubuntu 17.04
- Installing OpenStack on Ubuntu 12.04 LTS in 10 Minutes
- Vim的Python编辑器详细配置过程 (Based on Ubuntu 12.04 LTS)
- Vim 的 Python 编辑器详细配置过程 (Based on Ubuntu 12.04 LTS)