Linux Kernel Compilation Guide

Source: Internet
Author: User
Tags uuid

Recently helped a project to compile the kernel, especially learned a bit, write down the process. If the problem, you can contact me in time

Compile command

1. Clean-up work objectives
Make clean: Deletes the compiled intermediate file, but retains the configuration
Make Mrproper: Delete all build files that include configuration files
Make Distclean: Perform everything that mrproper does and delete the backup file

2. Configuring the Kernel
Make Menuconfig: Text graphics mode configuration kernel
Make Oldconfig: Update the kernel based on the current. config file hint
Make Defconfig: Generate the default kernel configuration
Make allmodconfig: All optional options are built into modules
Make Allyesconfig: Build all selection is kernel configuration
Make noconfig: Generate a kernel configuration for all Select No

3. Build the kernel target
Make all: Build all targets
Make Bzimage: Build kernel image
Make modules: Build all drivers
Make dir/: Build the specified directory
Make Dir/file. [S|o|i]: Build the specified file
Make Dir/file.ko: Build the specified drive

4. Install the kernel
Make install: Install the kernel
Make Modules_install: Install driver

5. Packaging Tools
Make RPM: RMP package that generates the kernel
Make rpm-pkg: Generate RPM package with source code
Make binrpm-pkg: Generate RMP Package with kernel and driver
Make deb-pkg: Build a Debian package with kernel and driver

6. Generate Documentation Tools
Make Xmldocs: Generate an XML document
Make Pdfdocs: Generate PDF document
Maek Htmldocs: Generating HTML documents

Get the kernel source code

Go directly to www.kernel.org website to download. If you are under Ubuntu, you can download it via Apt-get install Linux-source, the downloaded directory is/USR/SRC

Unzip the file
tar xvf linux-source-3.13.0.tar.bz2
Clean up the environment
make mrproper

This operation is not required for the first compilation

Creating a kernel configuration
make menuconfig


Hidden files for. config are generated in the current directory after saving.

Build the kernel

Be sure to compile the kernel with root permissions, or it will create a lot of weird problems.

all-j4

Compile time depends on the configuration of the compiled host, the powerful machine can be compiled in about 20 minutes to complete. Configuration differences can take several hours. When the compilation is complete, the./arch/x86/boot/bzimage and Initrd.image files are generated primarily.

Installing the kernel
install

The default is to install Vmlinuz-3.16.0ydoing, initrd.img-3.16.0ydoing, system.map-3.16.0ydoing, config-3.16.0ydoing files to the path is/boot.

modifying Startup Items

I was operating on a Ubuntu14.04 machine, and the boot tool was grub2. This is the default installation, note is not grub1, so to modify the/boot/grub/grub.cfg. I thought it was grub1, modified the menu.list, found no use, depressed for a long time. Grub.cfg is not writable by default, so change the file permissions before you modify it.

chmod +x grub.cfgvim grub.cfg

The imitation of the existing menuentry is added as follows:

Menuentry' Ubuntu, with Linux 3.16.0ydoing '--class ubuntu--class gnu-linux--class GNU--class os$menuentry _id_option ' gnulinux-3.16.0ydoing-advanced-e65c8b88-8698-45a3-8420-384d43b37119 '{Recordfail Load_video Gfxmode$linux _gfx_modeInsmod Gzio insmod part_msdos insmod ext2Setroot=' HD0,MSDOS6 '                if[x$feature _platform_search_hint= XY]; ThenSearch--no-floppy--fs-uuid--set=root--hint-bios=hd0,msdos6--hint-efi=hd0,msdos6--HINT-BAREMETAL=AHCI0,MSDOS6 e65c8b88-8698- $a3-8420-384d43b37119ElseSearch--no-floppy--fs-uuid--set=root e65c8b88-8698- $a3-8420-384d43b37119fi                Echo    ' Loading Linux 3.16.0ydoing ... 'linux/boot/vmlinuz-3.16.0Ydoing root=uuid=e65c8b88-8698- $a3-8420-384d43b37119 ro Quiet Splash$VT _handoff                Echo    ' Loading initial ramdisk ... 'initrd/boot/initrd.img-3.16.0Ydoing}

Note To modify there are 3 places, one is Menuentry ' Ubuntu, with Linux 3.16.0ydoing ', the second is linux/boot/vmlinuz-3.16.0ydoing, the third one is initrd/boot/ Initrd.img-3.16.0ydoing.

After restarting you can see Ubuntu in the Grub menu, with Linux 3.16.0ydoing options

Initrd.img can be compiled into the Bzimage

Initrd.img and Bzimage can be merged, as long as the make Menuconfig
The path to configuring Initramfs is compiled again.

Linux Kernel Compilation Guide

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.