This article is mainly for beginners of kernel learning, mainly on the VMware virtual machine to operate.
Install the corresponding version of the compilation Toolchain first.
Compile and install the following.
1. First unzip the source code.
2. Use the CP command to copy the extracted source code to the/USR/SRC directory for example: Cp-r linux-2.6.32.60/usr/src/
======================================
Note: If you are compiling the kernel for the first time, you do not need to perform the above but have to execute the make Mrproper command in the kernel source directory to remove the previously compiled. O and. config files.
======================================
3. Use the SU command to switch to the root user, CD to the kernel source directory in/usr/src/.
4. Copy the. config file from the/usr/src/native kernel version/directory of this machine to the kernel version directory to be compiled by/usr/src/, for example, on my machine The command is: Cp/usr/src/linux-headers-2.6.32-21/.con fig/usr/src/linux-2.6.32.60.
5.make Oldconfig. This command first reads the. config file that you just copied, and then asks if some new kernel features are compiled, and for starters, press the ENTER key.
6.make bzimage, start compiling kernel
7.make modules, start compiling the module.
8.make Modules_install, installing the kernel module
9.make install, installing the kernel
10. Execute update-initramfs-c-k kernel version number , for example on my machine: update-initramfs-c-K 2.6.32.60, this command is very important.
11. Copy the compiled kernel compressed file bzimage to the boot directory, named the vmlinuz-kernel version number, for example on my machine: cp/usr/src/linux-2.6.32.60/arch/ i386/boot/bzimage/boot/vmlinuz-2.6.32.60
12. Execute the Update-grub and Update-grub commands to update the boot file.
13.reboot
==================================================
Two. Problems with the compilation process
Loading a new kernel after installing a kernel reboot is likely to be a problem that will not start, and here is a way to load the original kernel.
Here's a straightforward way to use VMware virtual machines.
1. First click on the virtual machine-power supply-Enter the firmware when power is turned on, so we can enter the BIOS. Select the boot option in the BIOS, use the CD-ROM as the first boot entry, and then CTRL+F10 to save the restart.
2. Go to Ubuntu installation disk, do not choose to install, choose try Ubuntu, this will enter the Ubuntu trial version of the system.
3. After entering the system, first use sudo passwd to set the root password, then switch to the root user.
4. Use the FDISK-L command to see which hard drive your boot partition is on, and mine is on the/dev/sda1. (Note that if you do not partition the system when you install it, the FDISK command displays a Linux partition that contains boot).
5. Mount the boot partition to the directory you created, for example, the command used on my computer is mkdir mydir && mount/dev/sda1 Mydir, and then the CD-to-Mydir directory is on the boot partition.
We mainly edit the/boot/grub/grub.cfg file, remove all the configuration of the new kernel, for example, my machine needs to be deleted
Menuentry ' Ubuntu, with Linux 2.6.32.60 '--class Ubuntu--class gnu-linux--class GNU--class os {
..........
}
All menuentry blocks with 2.6.32.60 need to be removed.
After deletion, save the file, restart the machine, modify boot of BIOS to boot for hard disk.
(Note: There is a way to modify Grub.cfg's set default= "0" on the Internet, but it does not work on my machine).
Error: Kernel Panic-not syncing:VFS:Unable to mount Root fs on Unknown-block (0,0)
There is no way to mount Root, the workaround, to add the phrase "initrd/boot/initrd.img-kernel version number" to all new kernel-related menuentry blocks.
For example, on my machine, add initrd/boot/initrd.img-2.6.32.60,
Menuentry ' Ubuntu, with Linux 2.6.32.60.kid '--class Ubuntu--class gnu-linux--class GNU--class os {
Recordfail
Insmod ext2
Set root= ' (hd0,1) '
Search--no-floppy--fs-uuid--set b3b4f2e3-fb0d-4151-97ab-f73c88ab2742
linux/boot/vmlinuz-2.6.32.60 root=/dev/sda1 ro Quiet Splash
initrd/boot/initrd.img-2.6.32.60
}
The question about initrd can be found in the 20th chapter of the bird's Linux private dish.
This article refers to links:
Http://blog.sina.com.cn/s/blog_4ba5b45e0102e7nk.html
http://blog.csdn.net/zufeng_chen/article/details/5824544
Ubuntu10.04 compile and install the Linux kernel 2.6.32.60 version and Error resolution.