The following describes four steps to compile the Linux kernel:
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. 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. There should be a lot of kernel.org images. Select the fastest one to download, because the file to be downloaded is large. I will introduce how to install the 2.6.24 kernel and install the ck patch.
Download the linux-2.6.24.tar.bz2 and patch-2.6.24.bz2 and store them 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. Select "Y") to compile it into the kernel, select "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 to save the setting to the hidden file/usr/src/linux/. config no matter which configuration file was originally loaded.
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.