Linux Kernel compilation-general Linux technology-Linux programming and kernel information. For more information, see the following section. Author: wangling219
The kernel of 2.6.22 was compiled today! A small problem occurred during compilation yesterday. I have been searching for BAIDU and GOOGLE for a long time and have not been able to find it, but there are also a lot of such problems. Here I will refer to the content of a friend who has the same problem with me. It is difficult for me to type:
Make [1]: Entering directory:
CHK...
CHK...
CHK...
/Usr/src/linux-2.6.18/scripts/gen_initramfs.sh: Cannot open 'y'
Make [1]: *** [usr/initramfs_data.cpio.gz] Error 1
Make [2]: * Error 2
I still did not solve the problem, but later I used the menu to configure the kernel, changed something, and then compiled it. so, my friends, if you have this error, re-configure the kernel. It is estimated that the kernel is incompatible.
During compilation, I have referred to the following article (Thank you)
For new linux users, it is relatively difficult to compile the kernel, and I don't even know how to start with it. I collected this information online and finally compiled it successfully. now I have summarized this article, which is a relatively detailed step. I hope it will be helpful to new users.
1. Preparations
(1) sort out the hardware, file system types, and network protocols to be supported by the system.
(2) The uname command is recommended? R. Check the system version. If your system version is the same as the kernel version to be compiled, we recommend that you back up the content under/lib/modules, otherwise, the file generated by the make modules_install step will overwrite the content in this path.
(3) A: Download and decompress the Linux kernel, it is recommended to download the kernel from the http://www.kernel.org/pub/linux/kernel/, because the source code installed during the installation of the system supports many devices by default, this increases the difficulty of Kernel Cutting. Assume that you have downloaded the linux-x-y-z.tar.gz kernel. Generally, the Linux kernel source code is put under/usr/src. We still follow this habit. If the kernel version already exists under your path, we recommend that you change the name of the existing kernel.
B: If the kernel has been installed (the/usr/src/directory has a linux subdirectory), skip to the linux installation CD in the optical drive if it is not installed, find the kernel-source-2.xx.xx.rpm file (xx represents a number, represents the kernel version number), for example, the RedHat linux RPMS directory is the/RedHat/RPMS/directory, and then use the command rpm-ivh kernel-source-2.xx.xx.rpm to install the kernel
2. Clear the residual. o files and unnecessary associations during previous kernel compilation.
Cd/usr/src/linux
Make mrproper
Make sure that there is no correct. o file and file dependency in the source code directory. After executing this command, the kernel option will return to the default state. If you download the kernel source code and it is the first compilation, you do not need to perform this step.
3. Configure the kernel and modify relevant parameters. For more information, see.
In the graphic interface, make xconfig; In the character interface, make menuconfig
Set a kernel option correctly in the Kernel configuration menu, save and exit
4. correctly set the associated file
Make dep
Create the file dependency based on the options selected in the previous step.
5. make clean
Clear unnecessary files. If you delete some options based on the previous compilation, we recommend that you perform this step. Otherwise, it is unnecessary.
6. Compile the kernel
For large kernels (such as SCSI support), make bzImage
For small kernels, make zImage
7. Compilation Module
Make modules
Compile and load the module (that is, select M as the kernel option). The compilation time is related to the number of M options.
8. Installation Module
Make modules_install
Copy compiled modules to/lib/modules, which is why you are reminded of the backup in step 3 of "Preparation.
9. Use the new kernel
Method 1:
(1) kernel replacement: A, mv/usr/src/linuxX. X. X/system. map/boot/system. map
B. mv/usr/src/linuxX. X. X/arch/i386/boot/bzImage/boot/vmlinuz
(2) modify the/etc/lilo. conf file, add a startup option, and start it with the new kernel bzImage/zImage. The format is as follows:
Boot =/dev/hda
Map =/boot/map
Install =/boot. B
Prompt
Timeout = 50
Linear
Default = linux-new ### tell lilo to start linux using the new kernel by default ###
Append = "mem = 256 M"
Image =/boot/vmlinuz-2.2.14-5.0
Label = linux
Read-only
Root =/dev/hda5
Retain the old boot options to ensure that the new kernel cannot be booted. You can also perform other operations in linux.
After saving and exiting, do not forget the most important step. Run/sbin/lilo to make the modification take effect.
Method 2: Use GRUB (modify the grub. conf file)
(1) kernel replacement: A, mv/usr/src/linuxX. X. X/system. map/boot/system. map
B. mv/usr/src/linuxX. X. X/arch/i386/boot/bzImage/boot/vmlinuz
(2) modify the Boot manager Grub,/etc/grub. conf
The content is as follows:
# Boot =/dev/had
Default = 0
Timeout = 10
Splashimage = (hd0, 0)/grub/splash.xpm.gz
Title Red Hat Linux (2.4.20-8)
Root (hd0, 0)
Kernel/vmlinuz-2.4.20-8 ro root = LABEL =/
Initrd/initrd-2.4.20-8.img
Method 3: Modify the startup configuration file
Currently, grub is used to start. You need to modify/boot/grub. conf and add the corresponding startup information. The simplest format of the content to be added is as follows:
Title name displayed on the Startup Menu
Root file system mount Partition
Kernel File Name compressed by kernel
Initrd root file system file name
For example:
Title My new kernel
Root (hd0, 2)
Kernel/boot/vmlinuz-x.y.z
Initrd/boot/initrd-x.y.z.img
I have added some of the above: (I have also referred to many other articles)
First, use make bzImage, because make zImage can be compiled, but the kernel will be prompted to be too large, so it will not work (we are 2.6.XX ).
Second, when modifying GRUB, you must pay attention to the backup, and do not delete the original system first. in case of new system configuration errors.
Third: In GRUB, some systems may not be able to use the mkinitrd command. In this case, GRUB can also be left unchanged. directly enter the command "make install" in/USR/SRC/LINUX, it will automatically write data to GRUB, but the default system will remain unchanged.
Fourth: Some friends may not know what version they have installed. You can view it in the/LIB/MODULES directory, for example, 2.6.22 2.6.20. This is generally the last version.
Fifth: I am also a newbie. I haven't been playing LINUX for less than a year.
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.