How to compile the Linux Kernel

Source: Internet
Author: User
How to compile the Linux kernel-general Linux technology-Linux programming and kernel information. 1. Install the compiling environment first.

Enter the root account:

> Su

Enter Password

Install necessary tools:

> Apt-get install build-essential
(Install gcc, make, etc)
> Apt-get install libncurses-dev
(Library files required for installation of make menuconfig)
> Apt-get install kernel-package, fakeroot
(Some configuration files and tools for generating kernel-image in the Debian system)
> Apt-get install initramfs-tools, module-init-tools

2. Install kernel-source:

It can be installed from the Ubuntu source. The advantage is that it is simple, and the installed kernel is
Debian, but the disadvantage is that the kernel is not the latest kernel.

> Apt-get install linux-source

You can also download the kernel installation from www.kernel.org. Kernel.org's image should
Many. Select the fastest download because the file to be downloaded is large. What I will introduce here
Install the 2.6.24 kernel with the ck patch.

Download the linux-2.6.24.tar.bz2 and patch-2.6.24.bz2 and put it
Are stored in the/usr/src directory.

> Tar xvjf linux-2.6.24.tar.bz2
> Ln-s linux-2.6.24 linux
(If the linux directory already exists, delete it first)
> Cd linux
> Bzcat ../patch-2.6.24.bz2 | patch-p1

So far, the kernel source files and patches have been installed.

3. Compile the kernel

Decompress the source package to/usr/src/linux-2.6.24 and create a link named linux to/usr/src/linux-2.6.24 under/usr/src ).

Input in shell
Root @ FE2000 :~ # Cd ..
Root @ FE2000:/# cd/usr/src/linux

Root @ FE2000:/usr/src/linux # make mrproper

Root @ FE2000:/usr/src/linux # make menuconfig
Or make gconfig

At this time, qconf has read the default configuration. You can also do this:
In qconf, choose File-> Load to read other settings files.
For example/boot/config-2.6.18-23-686

Configure the. config file in qconf. Selecting "Y" is to compile it into the kernel, and selecting "M" to compile it into a module for dynamic kernel calling. If "N" is selected, it is not installed. You can also keep the default options ......
Below are just a few simple items:
General setup
Optimize for size (Look out for broken compilers !) Enthusiasts can select Y to get a smaller kernel.

Processor type and features
Symmetric multi-processing support if you do not have a multi-thread processor, you can select N
Processor family depends on your CPU.
For High Memory Support Memory larger than 1 GB, select "4 GB" and less than 1 GB, and do not plan to upgrade to 1 GB in the future. Select "off ".

Bus options (PCI, PCMCIA, EISA, MCA, ISA)
PCI support
PCI Express support vintage machines no PCI-E device available N
ISA support newer machines do not have an ISA Device. You can select N
Generally, N is selected as the MCA support.
NatSemi SCx200 support is generally N
PCI Hotplug Support
Support for PCI Hotplug (EXPERIMENTAL) if there is no PCI Hot swapping device, select N

Device Drivers
Block devices
Packet writing on CD/DVD media
Enable write caching (EXPERIMENTAL) If you have a burner and want to Enable the write cache function, select Y

ATA/ATAPI/MFM/RLL support
Include IDE/ATA-2 DISK support if your/boot is on the IDE hard DISK, You must select Y here, choose M none. Otherwise, the system prompts "waiting for root file system" to stop running.
If SCSI device support has a SATA hard disk, select Y.
SCSI disk support if your/boot is on the SATA hard disk, select Y.
Character devices
Generally, I2C support can be Y or M.
Graphics support does not recommend compiling the Graphics card driver into the kernel ., Select M and compile it into a module to facilitate driver upgrade in the future.
Support for frame buffer devices
You can select Y for vesa vga graphics support.
Logo configuration
Bootup logo if you want to see the Linux Startup logo, select Y
Sound
Select Y for Sound card support, unless you do not have a Sound card

Add or delete other drivers as needed. deleting unnecessary Drivers Based on Machine configurations can shorten the Compilation Time. You can enter lspci or dmesg in the command line to view hardware information.

File systems
CD-ROM/DVD Filesystems
ISO 9660 CDROM file system support is generally Y
DOS/FAT/NT Filesystems
VFAT (Windows-95) fs support has a FAT32 partition. Select Y.
If NTFS file system support has NTFS partitions, select Y.
NTFS write support if you want to write the NTFS partition, select Y
Native Language Support
Simplified select Y or M for the Chinese charset (CP936, GB2312) to avoid Chinese garbled characters when reading the FAT partition.

After setting, click the Save button, no matter which configuration file is loaded,
Qconfig saves the settings to the hidden file/usr/src/linux/. config.

Enter make below to start compilation. This process takes about 40-minutes, depending on your machine speed ......
Root @ FE2000:/usr/src/linux # make

Install Kernel
Root @ FE2000:/usr/src/linux # make install

Compilation Module
Root @ FE2000:/usr/src/linux # make modules

Installation Module
Root @ FE2000:/usr/src/linux # make modules_install

Then
Root @ FE2000:/usr/src/linux # cd/
Root @ FE2000:/usr/src/linux #/usr/sbin/mkinitramfs-o/boot/initrd. img-2.6.24 2.6.24

If an error occurs, it may be because initramfs-tools is not installed. Install it first.
If you do not have this step, a prompt will appear when you start the system.
......
Initrd/initrd. img-2.6.24
Error 15: File not found
4. Modify the kernel startup options
Finally, open/boot/grub/menu. lst.
In #### End Default Options ## add two sections similar to the following

Title Ubuntu, kernel 2.6.24
Root (hd0, 4)
Kernel/vmlinuz-2.6.24 root =/dev/hdd6
Initrd/initrd. img-2.6.24
Savedefault
Boot

Title Ubuntu, kernel 2.6.24 (recovery mode)
Root (hd0, 4)
Kernel/vmlinuz-2.6.24 root =/dev/hdd6 ro single
Initrd/initrd. img-2.6.24
Boot
Note that the root and kernel fields must be copied to the existing content under menu. lst.
Below is (hd0, 4), then you also write (hd0, 4), below write root =/dev/hdd6, you also write root =/dev/hdd6, only the kernel version is changed to the current compiled version.
Delete the repeated savedefault below.

Restart the computer and select a new kernel to start in GRUB.

So the new kernel can be started.
Related Article

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.