Compiling a Kernel in Ubuntu
-
Upload
smithavas12 -
Category
Documents
-
view
217 -
download
0
Transcript of Compiling a Kernel in Ubuntu
-
8/6/2019 Compiling a Kernel in Ubuntu
1/2
Compiling a kernel in Ubuntu:
Basic steps:
1. Download required packages for building2. Download Source
3. Configure the build4. Fire the build5. Install the build6. Create initd image (optional)7. Configure Grub (optional)
Note: If possible su to root user before performing a kernel build. Alternatively use 'sudo' in all the commands listedbelow and 'fakeroot' for building.
1. Download required packages for Building
apt-get update
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2initramfs-tools
2. Download source:
If you have no console, you can use the following commands:
cd /usr/srcwget http://www.kernel.org/pub/linux/kernel/v2.6/
or use a browser to download from www.kernel.organd place it in /usr/src
The current user directory should be /usr/src/ after the source is downloaded/
tar xjf source-file.bz2
create a symbolic link 'linux' which points to the kernel source, make this as the
working folder:
ln -s linux
cd /usr/src/linux
3. Configure the build
Copy the configuration of a working kernel.
cp /boot/config-`uname -r` ./.config
Launch the kernel config UI:
make menuconfig
After making required changes to the configuration, save and exit the tool
4. Fire the build
Do a clean if required to force a from scratch build [recommended]
make-kpkg clean
IMPORTANT:
To make use of all the cores, set the following environment variable:
export CONCURRENCY_LEVEL=X
where X= Number of Cores + 1 [gives arnd 90% utilization on all cores]
http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.kernel.org%2Fpub%2Flinux%2Fkernel%2Fv2.6%2F&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.kernel.org&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.kernel.org&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.kernel.org%2Fpub%2Flinux%2Fkernel%2Fv2.6%2F&isImage=0&BlockImage=0 -
8/6/2019 Compiling a Kernel in Ubuntu
2/2
If you are root user fire build using:
make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
otherwise use
fakeroot make-kpkg --initrd --append-to-version=-custom kernel_image kernel_headers
5. Install the build
Go to source directory:cd /usr/src
Install the image and header packages (.deb) that are created using the command
dpkg -i
Check in \boot to see whether the kernel image and initrd images for the new kernelare copied.
You may see the initrd image missing at times, follow step 6 and 7 to generate andinstall an initrd
6. Create initrd image (optional)
update-initramfs -ckv
eg: update-initramfs -ckv 2.6.24-11-generic
7. Configure Grub (optional)
Open the config file at \boot\grub\grub.cfg
In the entry for the new kernel add the following line to load the initrd image:
initrd /boot/
You are can restart:
shutdown -r now
Select the required kernel and boot up...
References:
http://www.howtoforge.com/kernel_compilation_ubuntuhttps://answers.launchpad.net/ubuntu/+source/initramfs-tools/+question/26781
http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.howtoforge.com%2Fkernel_compilation_ubuntu&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=https%3A%2F%2Fanswers.launchpad.net%2Fubuntu%2F%2Bsource%2Finitramfs-tools%2F%2Bquestion%2F26781&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=http%3A%2F%2Fwww.howtoforge.com%2Fkernel_compilation_ubuntu&isImage=0&BlockImage=0http://www.rediffmail.com/cgi-bin/red.cgi?red=https%3A%2F%2Fanswers.launchpad.net%2Fubuntu%2F%2Bsource%2Finitramfs-tools%2F%2Bquestion%2F26781&isImage=0&BlockImage=0