First steps
Install the required tools and packages.
Open a terminal and type the following,
sudo apt-get install fakeroot kernel-wedge build-essential makedumpfile kernel-package libncurses5 libncurses5-dev
Then run the following command,
sudo apt-get build-dep --no-install-recommends linux-image-$(uname -r)
And finally type,
mkdir ~/src
cd ~/src
apt-get source linux-image-$(uname -r)
cd linux-2.6.32
At the time of writing 2.6.32 was the current kernel source, it should remain at this version throughout the life of Ubuntu 10.04
It is a good idea to start with the same .config as the currently running kernel, so type the following,
cp -vi /boot/config-`uname -r` .config
Now we are ready to customize the build and kernel options.
make menuconfig
Once you have finished, save and exit. It is now time to compile. However to speed up the build if you have a dual core processor type,
export CONCURRENCY_LEVEL=3
The general rule is 1 + the number of processor cores.
make-kpkg clean
fakeroot make-kpkg --initrd --append-to-version=-some-string-here kernel-image kernel-headers
Remember to substitute the writing in green for something else, for example -alpha
After a few minutes or hours your kernel compile will be complete. The next step is to install it.
The kernel package will be created in the parent directory of ~/src/linux-2.6.32 (i.e. ~/src)
cd ~/src
sudo dpkg -i linux-image-2.6.32.11+drm33.2-alpha_2.6.32.11+drm33.2-alpha-10.00.Custom_amd64.deb
sudo dpkg -i linux-headers-2.6.32.11+drm33.2-alpha_2.6.32.11+drm33.2-alpha-10.00.Custom_amd64.deb
Please note the text in green must be changed to reflect your version.
We are almost ready, prior to 10.04 the initramfs kernel image was automatically created. The Ubuntu wiki suggests using the scripts to create the image but I have been unsuccessful in using this method, hence the manual approach.
sudo update-initramfs -c -k all
BUG: Please use the alternate method described below as this command fails to create an image for your new kernel. Special thanks to Helios38. - 16/06/2010
Alternatively if you know the kernel version, substitute the word all with the kernel version.
Example, sudo update-initramfs -c -k 2.6.32.11+drm33.2-alpha
Finally we need to add the initramfs image to the grub.cfg file located at /boot/grub/grub.cfg.
For the easy and automatic method as oppose to manually editing the grub.cfg file, just type the following,
sudo update-grub
Now just reboot and your new kernel should automatically load.
How to remove your kernel
sudo dpkg -r linux-headers-2.6.32.11+drm33.2-alpha
sudo dpkg -r linux-image-2.6.32.11+drm33.2-alpha
sudo rm /boot/initrd.img-2.6.32.11+drm33.2-alpha
Enjoy compiling your own kernels.
'【Fundamental Tech】 > Ubuntu' 카테고리의 다른 글
How to Compile and Install Linux Kernel 3.0 in Ubuntu 11.04, 10.10 and 10.04 (0) | 2011.09.19 |
---|---|
우분투 10.04를 설치한 뒤 해준 삽질들 (0) | 2011.09.19 |
How to compile DiskSim 4.0 + SSDSim(MS) in Ubuntu (0) | 2010.12.05 |
[Ubuntu 10.04] disksim 3/4 Compile하기 (0) | 2010.10.04 |
root 계정으로 로그인하기, 루트(root) 계정 만들기 (0) | 2010.10.04 |