Compile and update the kernel version in Ubuntu8.04Linux

Source: Internet
Author: User
In Ubuntu8.04Linux, compile and update the kernel version-general Linux technology-Linux technology and application information. For details, refer to the following section. This is an article I saw on the Internet about Linux kernel upgrade. Although it was reprinted, it is the most important thing for me to turn others' things into my own things. I also upgraded ubuntu8.04 from 2.6.24 to 2.6.27-8. After the upgrade is successful, you are excited. It may take more than two hours to install the Linux Kernel configuration, but if it is a virtual machine, you can let it compile it by yourself (this step takes a little longer, it takes about 2 hours), and then go to windows to do what you love to do ..... You can follow the steps below to compile the kernel and then modify the Startup file (/boot/grub/menu. lst, this step is also critical, because I have not modified it here. When I select a new kernel to start, the system prompts can not find files. Finally, I modified the example in the system/boot/menu. lst and started the new kernel !)
(You can download the latest kernel. The kernel provided in this article is earlier)


Ubuntu 8.04 tested on a virtual machine.

1. Download the kernel source code
Http://www.kernel.org/

Download The latest stable version of the Linux kernel is: 2.6.25.7. Click "F" to download it.

Http://www.kernel.org/pub/linux/... ux-2.6.25.7.tar.bz2 file.


2. Switch the su rootcommand to the rootpermission limit on the terminal, and then copy the linux-2.6.25.7.tar.bz2 file to the/usr/src/directory.
In ubuntu, you cannot log on to the interface as the root user. This is strange.

3. cd to the/usr/src/directory, execute the tar-jxvf linux-2.6.25.7.tar.bz2 command to decompress the source code package. It will be decompressed

/Usr/src/linux-2.6.25.7, I copied it to the/usr/src/linux-2.6.25.7-widebrihgt directory again,/usr/src/

The linux-2.6.25.7-widebrihgt is attached with an 8 GB disk.

4. root User, cd to/usr/src/linux-2.6.25.7-widebright directory
# Make mrproper (this command ensures that there are no incorrect. o file. config files in the source code directory)


Kernel configuration tool
(1) make config (character-only prompt Mode)

(2)
# Make menuconfig (configure the kernel options and select the mode from the ncurse menu)
The ncurse library is required. It is not installed in ubuntu by default and needs to be installed.
# Apt-get install libncurses5-dev

(3)
# Make xconfig (graphical interface of the X Window, configure various kernel options)
Xconfig is based on X11 and uses the qt library. Install the qt library in Ubuntu first:
# Apt-get install libqt3-headers libqt3-mt-dev


I configured it with menuconfig after installing the libncurses5-dev, all with his default configuration,
Besides
General setup --->
() Local version-append to kernel release ()
This can be followed by a character string in the kernel version. I entered widebrighgt
Select the last one and save the configuration file. It will generate the. config file in/usr/src/linux-2.6.25.7-widebright.







5. Compile the kernel
Just run make.
# Make

Run make clean to clear the generated Kernel File before execution, or there is a problem in the compilation process. To re-compile, you can use this

First, clear the generated kernel files.

I run the make command in the ubuntu8.04 SYSTEM OF THE VirtualBox virtual machine. The result of making is that the compilation time should be in two

Hours or more. Note that the remaining space for/usr/src/linux-2.6.25.7-widebright is above GB, And I mount it to

2 GB disk. When the result is compiled, the system prompts that there is no space. Later, I tried several times and spent a lot of time mounting an 8 GB disk.

The compilation is successful. After reading it, the occupied control is about GB.

This make statement is equivalent to the following two steps:
# Make bzImage
# Make modules)

Make bzImage will generate a name named

BzImage kernel image file. The make zImage command can actually generate a kernel image. The difference between bzImage is that it is a pressure

.

Make modules is to produce a large number of *. ko kernel files, that is, modular kernel drivers, etc. You don't compile it

A separate ko file will be generated in bzImage, And the ko module will be loaded by the kernel when necessary.


6. Install the kernel

(1)
Run the make install command.

After running this step, I am prompted to point the entry point to/boot/vmlinuz-in the GRUB menu. lst configuration file-

2.6.25.7widebright file. The bzImage generated in the previous step has been copied to the/boot directory of the system.

-L take a look at the/boot directory, you can already link the vmlinuz file to the vmlinuz-2.6.25.7widebright file System. map

File is linked to the System. map-2.6.25.7widebright file, the config file is linked to the config-2.6.25.7widebright File


.

(2)
I didn't see the module configuration output, so I ran the make modules_install command again. This is the installation module.
This will install a lot of ko files, and finally output DEPMOD 2.6.25.7widebright. I don't know what the process looks like. However

Under the/lib/modules/directory, a 2.6.25.7widebright directory is generated.

The ko kernel module files.

(3) The above compilation process does not seem to generate the initrd image file. I don't know what's going on, so I had to do it manually. What is initrd mirror?

See the last article
Generate the initrd image file. Use the new-kernel-pkg command in the redhat system.

The command does not know what the system is. I searched for it on the internet in ubuntu, and it should be generated using the mkinittramfs command.

Run "mkinitramfs-o initrd. img-2.6.25.7widebrihgt 2.6.25.7widebrihgt" to generate

An initrd image file named initrd. The img-2.6.25.7widebrihgt size is around M. Finally, I moved it to/boot/object.

.
Note: The last parameter "2.6.25.7widebrihgt" is version. Specify the kernel version, that is, the corresponding

Folder name. This must be specified. Otherwise, the system uses the version of the running system by default.

.


(4) Check the grub configuration file.
Cat/boot/grub/menu. lst. It seems that the make install command does not automatically write the configuration of the newly compiled kernel to the grub configuration file.

. Modify the timeout attribute to 10, so that the wait time is longer, and then copy the original configuration to add a new item at the beginning, because the default value at the beginning is set to 0, the default value is the first item. The added content is as follows:

Title Ubuntu 8.04, kernel 2.6.25-7-widebright
Root (hd0, 0)
Kernel/boot/vmlinuz-2.6.25.7widebright root = UUID = a082d103-894e-443a-bf58-8b128c7e5dd1 ro quiet splash locale = zh_CN
Initrd/boot/initrd. img-2.6.25.7widebright
Quiet

Note that both the kernel and initrd point to their own image files. The root UUID may be different from others. For details, refer to the GRUB configuration file description.







After completing the preceding steps, restart the system. When the system prompts to press the ESC key, you can select and enter the GRUB menu. You can see that your kernel version is displayed.



After selecting to enter, everything is normal.

Run the uname-a command to check whether the current kernel has been updated.

Widebright @ widebright-desktop :~ $ Uname-r
2.6.25.7widebright
Widebright @ widebright-desktop :~ $ Uname-
Linux widebright-desktop 2.6.25.7widebright #1 SMP Sat Jun 21 05:37:09 CST 2008 i686 GNU/Linux
Widebright @ widebright-desktop :~ $





======= Additional initrd image Article ============================ ================================
Functions and production of initrd image files

We usually edit the lilo. conf and grub. conf files when installing the new kernel. There is a section "initrd =/boot/initrd-

* **. Img "(in which ** indicates the kernel version number) is rarely noticed. Sometimes this line can be avoided.

Boot normally. So what exactly is this initrd ***. img used?

In fact, initrd ***. img is an image file, similar to ramdisk. It packs a program into img, and then

Open up a region, usually 2 m, and put it there for running, are some initialization programs, such as sisc_mod, ext3,

Sd_mod and other modules and commands such as insmod and nash. For different kernels, the initialized img can be the same or different. If not,

You can add no initrd in grub. conf to skip initrd detection and execution. It seems that there was no initrd in the past and it was only available later.


Before mount/partition, the system needs to perform some operations. For example, if a scsi driver is mounted, the system releases initrd

Save, make a virtual/, and then execute a script "linuxrc" in the root directory to run the insmod and nash commands to install the module.

Why can I boot normally if we do not add this line to the configuration file of lilo or grub? This is because of our average PC

The scsi hard disk and other devices that need to be loaded first, so even if there is no initrd ***. img, the device can be properly started. However

If we want to compile a new kernel for it on the server, do not forget to create an initrd file for it!


Well, let's take a look at how to view the content in initrd ***. img and how to create a new initrd. imgfile for your new kernel.


View initrd. img:
Although the suffix of initrd ***. img is "img", it is actually a file in the gz format. We can decompress it first, and then attach it

Directory:
1. cp initrd. img initrd.gz
2. guzip initrd.gz
3. mount-o loop initrd/mnt/floppy
In the/mnt/floppy directory, we can see the true nature of the initrd ***. imgfile.


Create an initrd File
When we compile a new kernel, do not forget to create a new initrd image for our scsi device:


Syntax:
Mkinitrd file name Kernel Directory Name


Example:
Mkinitrd initrd-2.4.19.img 2.4.19
The initrd-2.4.19.img file is your own, but it is best to match your own kernel version.
2.4.19 is the directory name in/lib/modules, corresponding to the kernel version.


Of course, we can also directly add modules to the/lib directory after installing the initrd ***. imgfile, and then modify the linuxrc script to open it.

Host for mounting. However, you must be able to use shell scripts.

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.