Compile and update the kernel version in Ubuntu 8.04 Linux

Source: Internet
Author: User

Ubuntu 8.04 was tested on the virtualbox virtual machine.
1. Download the kernelSource 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/kernel/v2.6/linux-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 and execute Tar-jxvf linux-2.6.25.7.tar.bz2 Command to extract the sourceCode 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 the. o file. config file is not in the source code directory)

Kernel configuration tool

(1) make config (character-only prompt Mode)



(2)

# Make menuconfig (Configure various kernel options, which are in the ncurse menu selection mode)

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 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 it again. Make modules_install Command to install the 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 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 ", Will be generated under the current directory

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 you 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. Program Package it into IMG, and then in the memory at startup

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.