Ubuntu kernel Compilation

Source: Internet
Author: User
Disclaimer: This article is a summary of kernel 2.6.25 compilation for personal reference on the Internet. For example, the responsibility caused by kernel compilation by following the steps in this article is irrelevant to the author of this article.
This article put above my blog: http://hi.baidu.com/ffbp89/
This article also contains a companion article titled kernel guide for compiling a notebook 2.6.20
If any modification is made, it is also on the blog.
You are welcome to repost this article, but do not cancel this statement.
This article is mainly intended for teaching purposes. Students can review shell commands in conjunction with the compiling kernel.

1. DownloadSource codeAnd prepare the compilation software
Download the kernel sourceCode: Http://www.kernel.org/
Note: Click version F of kernel 2.6.25, which is the full version.
If you are too reluctant to connect to a website, run the following command:

Code: $ Cd ~
$ Wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.10.tar.bz2

Install related compilationProgram. Install make, GCC, make-kpkg, run menuconfig, and other kernel-related tools.
Unable to install. Check the/etc/APT/sources. list file.
Related commands:Code:$ Sudo apt-Get install build-essential kernel-package libncurses5-dev

Ii. decompress the source code
Note: In many online tutorials, you should extract the package to/usr/src. This is purely just for example. Linux Director Linus said that the package can be decompressed to any directory. Of course, the Linus statement is correct. I put the src directory in my home directory.
If you download the source code in your home directory or run the wget command above, run the following command:Code:$ Cd ~
$ Mkdir SRC & tar jfx linux-2.6.25.10.tar.bz2-C src/

Now, the source code is in ~ /Src/linux-2.6.25.10
Go to the source code directory and prepare for the next step. This directory is used later.Code:$ Cd ~ /Src/linux-2.6.25.10

3. Start preparations before compilation.
First, clear the temporary files left during previous compilation. If the package is just unlocked, you do not need to perform this step. If it is the second or the nth compilation, it must be executed.
The related commands are as follows:Code:$ Sudo make mrproper

In many online tutorials, we copy the current kernel config for reference. It is not required for experiments. Ubuntu also has
Debian automatically performs this step. However, you can learn about this command. Of course, you can copy the previous configuration.
Command:Code:CP/boot/config-'uname-R'./. config

4. Start to configure the kernel options.
Related commands:Code:$ Sudo make menuconfig

Only a few keys are used for configuration. The ESC exits from the menu, the space changes the option status, the cursor key moves up, down, and left, and press enter to select.
Option meaning: m is compiled into a module that can be added at any time, * is compiled into the kernel, empty is not.
There are many configuration options. For specific configurations, refer to the document translated by Mr. Jin BU: Linux 2.6.19.x kernel compilation configuration options.
Reference: http://lamp.linux.gov.cn/Linux/kernel_options.html
For a success, please follow the principle that if you have selected an option for your own kernel, do not change it if you have no good reason. In this way, although the kernel is not so streamlined, It is not prone to problems.
What we can streamline is the hardware module, so we do not have to hesitate to clear hardware that we don't have.
If you are persistent, or you are clean, you can choose one item for the past, according to the description of Mr. Jin bu.

5. Several options that must be emphasized:
1. "prompt for development and/or incomplete code/drivers" in "General setup" is not required. However, if your hardware is relatively new, it is almost required. In this way, we can find the 4965 wireless Nic and ALSA sound driver.
Kernel log buffer size I select 15, dual-core. If you use IA64, select 16.
Control group support cluster support? Can not
Choose Slab allocator (slub (unqueued Allocator) memory management mode slab and slub select slub.

2. In block layer, if there is no 2 TB hard disk, remove: Support for Large Block devices. Support for large single files is not required either. Who has 2 TB files?

3. The processor type and features are about the CPU. You must select them carefully.
Symmetric Multi-processing support enables the multi-core switch. My CPU is dual-core and selected.
Processor family (Core 2/newer Xeon) I use core 2/newer Xeon. Find your CPU and cancel the generic x86 support option.
Select subarchitecture type (PC-compatible)
Maximum number of CPUs: Enter the number of cores. I enter 2.
SMT (hyperthreading) sched100 support is about hyper-Threading Technology. P4 supports this technology. My t8100 does not support this technology. Currently, most of the market's household CPU does not support this technology.
High memory support (4 GB) 1 GB or less select 1g; I am 3G, select 4G; 4G or above select 16g
In "timer frequency", the default value is 250Hz. You can select 1000Hz for all new CPUs, providing better performance.

4. Disable APM (Advanced Power Management) BIOS support in power management options. Now all the computers use ACPI.
CPU frequency scaling is a notebook CPU power-saving technology
Default cpufreq governor (conservative) has four CPU power-saving modes. By default, conservative is preferred for a notebook.
The ACPI processor p-States driver must be selected, or the CPU frequency cannot be used.
Later I chose intel enhanced speedstep and Intel speedstep on ICH-M chipsets, all of which were eliminated.

5. Selection of bus options:
Bus options (PCI, PCMCIA, Eisa, MCA, Isa)
PCI support
PCI Express support now the newly purchased machines are basically PCI Express
New ISA support machines do not have an ISA Device.
Remove MCA support
Remove natsemi scx200 support
PCI Hotplug support
Support for PCI hotplug (experimental) if there is no PCI Hot swapping device, remove
The options here can be compiled into the kernel rather than in the form of modules.

6. device drivers is the focus. Because Linux is not only for personal workstations, but also for server-oriented applications, you can remove all the hardware that you do not have on your machine, instead of everything. However, the general-purpose options should be cautious.

For example, in the NIC section, except for my Gigabit Nic Broadcom tigon3 support and 4965 wireless Nic Intel Wireless WiFi 4965AGN, all other hardware support is removed.

For example, in the sound card section, I use the HD sound card. I only select the Intel HD sound card in PCI devices, and then select build IDT/sigmatel HD-audio codec support, in addition, all hardware support is removed.
The sound card has another detail. In ubuntu7.10, you need to go to/etc/modprobe. add options snd-hda-Intel probe_mask = 1 model = 3 stack to the end of D/ALSA-base so that the speaker in my notebook can be voiced. Otherwise, only external headphones or speakers can be added. After this compilation, this action is no longer necessary, but only one of the two headphone plug-ins can be used.

For example, if my computer does not have the "AGP" option, you can directly cancel all the options related to the "AGP" option.

Note:
ATA/atapi/MFM/rll support
Include IDE/ATA-2 disk support if your/boot is on the IDE hard disk, then you must select *, choose M none. Otherwise, the system prompts "waiting for root file system" to stop running.
SCSI emulation support must be selected.

SCSI device support is a SATA hard disk. Select *
SCSI disk support if your/boot is on the SATA hard disk, select *.
Scsi cdrom support although Kang Bao recorder is an IDE interface, it must be treated as a SCSI interface, which is an old problem. A burner is required.

Graphics support
Support for frame buffer devices selected, go to select
Vesa vga graphics support is selected, or the character interface startup may fail,
The following video card selection: Because my video card is NVIDIA 8400gs, You have to install the driver of NVIDIA, so no one is selected. In this way, the Ubuntu boot animation will fail. I simply delete all the splash characters in grub and disable the boot animation. The character interface is normal.

Console display driver support character console error after startup, that is, this option is not selected, a problem occurs.
Framebuffer console support must be enabled.
The boot icon of the bootup logo will be added to the self-check screen. You need to add the VGA = option on grub, refer to http://dotimes.com/articles/t23-slackware-framebuffer.html

7. File Systems
Filesystem in userspace support (fuse. Required. If you want to use Windows partition.

CD-ROM/DVD filesystems
ISO 9660 CDROM File System Support *
DOS/fat/NT filesystems
Vfat (Windows-95) FS Support has a FAT32 partition. *
NTFS file system support has NTFS partitions. *
NTFS write support if you want to write the NTFS partition, select *

The file system of the boot disk must be compiled into the kernel. By default, It is compiled into a module, so that the system cannot be started. The file system used in Ubuntu is ext3. compile all necessary options related to ext2 and ext3 into the kernel.

8. The virtualization category is the main reason why I spend several hundred yuan to buy t8100, because t8100 supports intel VT technology.
This greatly improves the performance of virtual machines on Linux. The options here are compiled into modules except AMD.

9. All settings are complete. The last one is to save the settings.
According to my habits, first save a backup in the previous directory, the file name is similar to ../config20080630
And save it to the starting directory. The file name is. config.
Exit the setup program.

6. start compiling the kernel.
The Ubuntu tool is make-kpkg, which is relatively simple compared with other releases.
Related commands:Code:$ Sudo make-kpkg clean command does not seem to require super permissions. Many documents are required, but this is not a matter of principle.
$ Sudo make-kpkg-initrd -- append-to-version = dell1400 kernel_image kernel-headers

The dell1400 in the preceding command can be replaced by your favorite character. The final character must be a number.
Before entering the preceding command, we recommend that you turn off all other applications in the browser, which is difficult for the machine to start. My machine takes about 10 minutes.

7. Install the kernel
After compilation is completed, the installation is completed. The compiled kernel is located in the previous directory. Including Linux-headers -... -_ i386.deb and Linux-image -... -i386.deb files. If you do not develop the file, you only need to install the kernel. You can use the header file later.
Installation commands:Code:$ CD ..
$ Sudo dpkg-I Linux-image-(press the tab key)

The file name is very long. If you do not need to use tab to make up automatically, it is impossible. Long live the tab key.
After the installation is complete, compare the size with the old kernel.Code:$ LS-L/boot/

8. Restart to verify the new kernel.Code:$ Sudo reboot

9. graphics card driver
If your video card is similar to my NVIDIA video card, you will not be able to enter the X-window normally after it is started. Even if you can see the WordPress logon interface, the effect is poor.
Install the NVIDIA driver.
Use CTRL + ALT + F1 to enter the character command line, enter the user name and password to log on.
Command:Code:Download driver
$ Wget http://us.download.nvidia.com/XFree86/Linux-x86/173.14.12/NVIDIA-Linux-x86-173.14.12-pkg1.run

$ Sudo-S
Enter the password to obtain the super permission.
# Ps ax
Take a look at the processes related to the gestational disease and shut down them all; Use sudo/etc/init. d/gestational disease stop to possibly have a process not closed:
# Kill process number
Then install the NVIDIA graphics card driver. Of course, the driver should first be ready and run in the directory where the NVIDIA driver is located:
# Sh./NVIDIA-Linux-x86-173.14.12-pkg1.run

After restarting, click OK. The NVIDIA driver must be used to upgrade the kernel each time.

10. Wireless Network Card
The related kernel options are
Networking --->
Wireless --->
Generic IEEE 802.11 networking stack (mac80211)
There are also 4965 drivers.

Although the 4965 wireless NIC driver has been compiled into the kernel, it cannot be used without firmware. I need to copy the firmware of the original kernel to the corresponding directory of the new kernel, the name is the same as the kernel, my kernel is the linux-image-2.6.25.10dell1400, the directory name is 2.6.25.10dell1400.

Code: Specific commands:
$ CD/lib/firmware/
$ Sudo mkdir 2.6.25.10dell1400
Copy the firmware of 4965 in your old kernel.
$ Sudo CP 2.6.24-16-generic/* 2.6.25.10dell1400/

The above command is equivalent to the following command:
$ CD/lib/firmware/
$ Sudo CP-r 2.6.24-16-generic/2.6.25.10dell1400/

Restart the system, and the wireless NIC will be normal.

Attached compiled and used machine configuration: Dell vostro 1400, t8100, NVIDIA 8400cs graphics card, built-in sigmatel stac9228 chip sound card, 4965 wireless network card, bcm5906m gigabit network card, 3G memory, G hard drive, combo burning.
Compile the system version: Ubuntu 8.04 desktop version.

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.