Ubuntu 10.10 kernel compilation to solve the problem of cocould not load/lib/modules /... /Modules. dep

Source: Internet
Author: User

I. How to download the kernel source code:

1. Download the kernel source code in ubuntu: apt-get install linux-source

 

Find the kernel source code package: apt-cache search kernel-source. Then, install the corresponding source code package and run apt-get install linux-source directly.

 

In this case, the downloaded kernel source code may be different from the current kernel version (My ubuntu kernel is 2.6.35-22, and the downloaded kernel is 2.6.35.11 ).

 

2, download a specific version of the Linux kernel, can refer to: http://forum.ubuntu.org.cn/viewtopic.php? T = 134404 Linux kernel Compilation

Example: $ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.35.2.tar.bz2

 

Ii. Compile source code

After the kernel source code is installed, enter/usr/src/and decompress the package. After decompression:

1. make menuconfig: configure the kernel

2. make: Compile the kernel

3. make modules_install: copy the compiled kernel module to the/lib/modules/<kernel-version>/directory;

4. install the kernel: make install

(The configuration file grub. cfg is/boot/grub. cfg (fedora is in the menu. lst file ))

 

3. make install

In this case, only the compressed kernel image vmlinuz is copied to/boot AND initrd has not been generated. img. add a new compiled kernel image to the cfg file (use the img of other kernel versions as the img of this kernel:Cocould not load/lib/modules/.../modules. dep

 

I was already desperate here. I feel that it has failed for so long! I found it online. Someone provided a solution, that is, using initramfs-tools to generate initrd. img, the command is as follows: update-initramfs-c-k 2.6.35.2 will generate initrd using the file in lib/modules. img-2.6.35.2 (located in the boot folder), modify grub. the img path of cfg. Restart 2.6.35.2. startup successful! Reference http://www.linuxquestions.org/questions/debian-26/modprobe-fatal-could-not-load-lib-modules-modules-dep-335214/

 

During the startup process, it is found that grub's Startup menu is not visible under ubuntu's default startup (which can be seen on a multi-system machine, but not on a virtual machine). Therefore, you need to modify grub. in cfg, the time control is timeout. There are two points:

If ["$ {recordfail}" = 1]; then
Set timeout =-1
Else
Set timeout = 10
Fi

And

If keystatus; then
If keystatus -- shift; then
Set timeout =-1
Else
Set timeout = 0
Fi
Else
If sleep -- interruptible 3; then
Set timeout = 0
Fi
Fi
Fi

The former is the waiting time for system failure or success, and the latter is the waiting time for holding down shift or not holding shift at startup, in the virtual machine, you can press shift at startup or change all the timeouts of the latter to 10. reference: http://forum.ubuntu.org.cn/viewtopic.php? F = 139 & t = 323524

 

Iv. Remarks:

1. vmlinuz is a bootable and compressed kernel.

2. initrd. img: initrd. img is an important file in the Linux Startup Process. If the driver of some devices in the system is compiled as a load mode, if INITRD =/path_to_initrd.img is not specified during startup, the system may fail to start, or a device (such as a NIC or other device) cannot be used after the device is started ). If initrd. img or specified initrd. if the img does not contain the correct driver module, the system will be suspended at startup and the error "kernel panic: VFS: Unable to mount root fs on" will be reported.

3. Improvements: for the entire process, the details of each step are unclear, such as Kernel configuration (menuconfig) and kernel source code makefile, the process of generating vmlinuz and img and the functions of the two files are unclear, and further analysis and learning are required!

 

 

References:

1. On the ubuntu Forum, the process for compiling the kernel source code is very detailed. If you find this one early, you will not be so involved:

Http://forum.ubuntu.org.cn/viewtopic.php? T = 134404

2. About SolutionCocould not load/lib/modules/.../modules. dep:

Http://www.linuxquestions.org/questions/debian-26/modprobe-fatal-could-not-load-lib-modules-modules-dep-335214/

3. Roles of vmlinuz and initrd. img:

Http://blogold.chinaunix.net/u3/100815/showart.php? Id = 2026646

4. Linux kernel source code path: http://www.kernel.org/pub/linux/kernel/v2.6/

5. About grub boot menu display: http://forum.ubuntu.org.cn/viewtopic.php? F = 139 & t = 323524

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.