CentOS6.5 upgrade Kernel to 3.10.28--verified

Source: Internet
Author: User

This article applies to CentOS 6.4, CentOS 6.5, and is also estimated for other Linux distributions.

1. Preparation work confirm kernel and version information
[root@hostname ~]# uname -r2.6.32-220.el6.x86_64[root@hostname ~]# cat /etc/centos-release CentOS release 6.5 (Final)
Installing the Software

Compile and install the new kernel, depending on the development environment and the development library

# yum grouplist  //查看已经安装的和未安装的软件包组,来判断我们是否安装了相应的开发环境和开发库;# yum groupinstall "Development Tools"  //一般是安装这两个软件包组,这样做会确定你拥有编译时所需的一切工具# yum install ncurses-devel //你必须这样才能让 make *config 这个指令正确地执行# yum install qt-devel //如果你没有 X 环境,这一条可以不用# yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel //创建 CentOS-6 内核时需要它们

If the installation system was selected software workstation, the above installation package is almost always included.

2. Compile the kernel to get and unzip the kernel source code, configure the compilation

There are two versions of the Linux kernel: stable and development, and the Linux kernel version number consists of 3 numbers: r.x.y

    • R: Major Version number
    • X: Minor version number, even for stable version, odd for developing version.
    • Y: Revision number, indicating number of changes

Go to http://www.kernel.org home, you can see there are stable, longterm and other versions, longterm is more stable than stable version, the president time update, so I choose 3.10.58.

[root@sean ~]#wget  Https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.10.28.tar.xz

[root@sean ~]# tar -xf linux-3.10.58.tar.xz -C /usr/src/[root@sean ~]# cd /usr/src/linux-3.10.58/[root@sean linux-3.10.58]# cp /boot/config-2.6.32-220.el6.x86_64 .config

We set up a new compilation option based on the original kernel configuration file of the system, so we copied a copy to the current directory, named. config. Next, continue with the configuration:

[Root@sean linux-3.10.58]# sh-c ' Yes ' | Make Oldconfig 'HOSTCC SCRIPTS/BASIC/FIXDEPHOSTCC SCRIPTS/KCONFIG/CONF.OSHIPPED SCRIPTS/KCONFIG/ZCONF.TAB.CSHIPPED scripts/kconfig/zconf.lex.cSHIPPED scripts/kconfig/zconf.hash.cHOSTCC SCRIPTS/KCONFIG/ZCONF.TAB.OHostld scripts/kconfig/confscripts/kconfig/conf--oldconfigKconfig.Config555: Warning: Symbol value' M ' InvalidForPccard_nonstatic.Config2567: Warning: Symbol value' M ' InvalidFormfd_wm8400.Config2568: Warning: Symbol value' M ' InvalidForMfd_wm831x.Config2569: Warning: Symbol value' M ' InvalidFormfd_wm8350.Config2582: Warning: Symbol value' M ' InvalidForMFD_WM8350_I2C.Config2584: Warning: Symbol value' M ' InvalidForAb3100_core.Config3502: Warning: Symbol value' M ' InvalidFormmc_ricoh_mmc**restart config...*** general setup* ... XZ decompressor Tester (xz_dec_test) [N/m/y /?] (new) averaging functions ( AVERAGE) [y/?] (new) ycordic algorithm ( CORDIC) [n/m/y/?] (new) jedec DDR data (ddr) [n/y/?] (new) ## configuration written To. config               

   make oldconfigWill read the file in the current directory .config , the .config file does not find the option to prompt the user to fill in, and then back up the .config file as .config.old , and generate a new .config file, refer to http://stackoverflow.com/questions/ 4178526/what-does-make-oldconfig-do-exactly-linux-kernel-makefile

Some documents describe the use of make memuconfig, which is to customize the module as needed, similar interface as follows: (not required here)

Start compiling
[root@sean linux-3.10.58]# make -j4 bzImage  //生成内核文件[root@sean linux-3.10.58]# make -j4 modules //编译模块[root@sean linux-3.10.58]# make -j4 modules_install //编译安装模块

The number behind-J is the number of threads, which is used to speed up compilation, and the general experience is that the logical CPU fills that number, for example, with 8 cores, or-J8. (Modules part time more than 30 minutes)

Installation

[Root@sean linux-3.10.58]# make install
The actual run to this step occurs ERROR: modinfo: could not find module vmware_balloon , but does not affect the kernel installation, because the modules that vsphere requires are not compiled, to avoid this problem, you need to modify the. config file before make, add
Hypervisor_guest=yconfig_vmware_balloon=m
(This part is more prone to problems, refer to the exception section below)

Modify GRUB Boot, restart

After the installation is complete, you need to modify the Grub boot order so that the newly installed kernel is the default kernel.
Edit Grub.conf file,

vi /etc/grub.conf#boot=/dev/sdadefault=0timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (3.10.58)    root (hd0,0)...

Count the newly installed kernel in which location, starting with 0, then set the default to that number, generally the newly installed kernel is in the first position, so set default=0.
Restart reboot :

Confirm when kernel version
[root@sean ~]# uname -r3.10.58

Upgrade Kernel success!

3. Exception compilation failures (such as missing dependency packages)

You can clear and then recompile:

# make mrproper         #完成或者安装过程出错,可以清理上次编译的现场# make clean
Compiled on a VMware virtual machine with an error similar to the following
  [Root @sean linux- 3.10.58]# make install sh/usr/src/ Linux-3.10. 58/arch/x86/boot/install.sh 3.10. Arch/x86/boot/bzimage system.map  "/boot" errormodinfo:could not find module vmware_balloon            

Can be ignored, if you have obsessive-compulsive disorder, try the following methods:
To install Vmware_balloon on VMware, you can modify the. config file directly, but if the VI join CONFIG_VMWARE_BALLOON=m is still ineffective because it relies on HYPERVISOR_GUEST=y . If you do not know this layer of dependency, make menuconfig after passing, Device Drivers-MISC devices can not find the VMware Balloon driver. (Manual VI config modifies the hypervisor_guest, it can be found), in addition, either through make menuconfig or Direct VI config, finally run sh -c ‘yes "" | make oldconfig‘ once to get the final compile configuration options.
Then, taking into account that Vmware_balloon may have been renamed to Vmw_balloon in this version, it is safe to use the following method:

# cd /lib/modules/3.10.58/kernel/drivers/misc/# ln -s vmw_balloon.ko vmware_balloon.ko #建立软连接

In fact, the most sensible option for installing Docker's kernel compilation environment is to use the. config file that Sciurus helps us configure.
It is also recommended to make bzImage run the script check-config.sh before checking the modules that are missing from the current kernel running Docker.
When you are prompted for a missing other module, such as Nf_nat_ipv4, you can also resolve it by using the method above and then recompile.

4. Introduction to several important Linux kernel files

In the network, many servers adopt the Linux system. To further improve server performance, you may need to recompile the Linux kernel based on specific hardware and requirements. Compiling the Linux kernel requires a set of steps, and several important files are involved in the process of compiling the kernel. For example, for Redhat Linux, there are some Linux kernel-related files in the/boot directory, enter/Boot execution: ls–l. The people who compiled the Redhat Linux kernel may have a deep impression of System.map, Vmlinuz, initrd-2.4.7-10.img, because the process of compiling the kernel involves the creation of these files. So how did these files come about? What's the effect?

(1)Vmlinuz

The Vmlinuz is a bootable, compressed kernel. "VM" stands for "Virtual Memory". Linux supports virtual memory, unlike older operating systems such as DOS, which have 640KB memory limitations. Linux is able to use hard disk space as virtual memory, hence the name "VM". Vmlinuz is an executable Linux kernel, which is located in/boot/vmlinuz, which is generally a soft link.

There are two ways to build a vmlinuz.

The first is to compile the kernel through "make zimage" created, and then through: "Cp/usr/src/linux-2.4/arch/i386/linux/boot/zimage/boot/vmlinuz" generated. Zimage is suitable for small cores, it exists for backwards compatibility.

Second, the kernel compiles by command make Bzimage, and then through: "Cp/usr/src/linux-2.4/arch/i386/linux/boot/bzimage/boot/vmlinuz" generated.

Bzimage is a compressed kernel image, it should be noted that bzimage is not compressed with bzip2, the BZ in Bzimage is prone to misunderstanding, BZ said "Big Zimage". B in Bzimage is the meaning of "big".

Zimage (Vmlinuz) and Bzimage (Vmlinuz) are compressed with gzip. Not only are they a compressed file, they are also embedded with the Gzip decompression code at the beginning of these two files. So you can't unpack vmlinuz with Gunzip or GZIP–DC.

The kernel file contains a miniature gzip to decompress the kernel and boot it. The difference is that the old Zimage unzip the kernel to low-end memory (the first 640K), bzimage the kernel to high-end memory (1M or more). If the kernel is small, you can use one of the zimage or Bzimage, and the two modes of booting the system run the same. The large kernel uses bzimage and cannot use Zimage.

Vmlinux is an uncompressed kernel, Vmlinuz is a compressed file of Vmlinux.

(2) initrd-x.x.x.img

INITRD is a shorthand for "initial RAMDisk". INITRD is generally used to temporarily boot the hardware to the actual kernel vmlinuz to be able to take over and continue the boot state. For example, if you are using a SCSI hard disk, and the kernel Vmlinuz does not have this SCSI hardware driver, the kernel cannot load the root file system until the SCSI module is loaded, but the SCSI module is stored under the/lib/modules of the root file system. To solve this problem, you can boot a INITRD kernel that reads the actual kernel and fix the SCSI boot problem with INITRD. Initrd-2.4.7-10.img is a file that is compressed with gzip, take a look at the contents of this file.

INITRD implements loading some modules and installing file systems.

The INITRD image file was created using MKINITRD. The MKINITRD utility is capable of creating INITRD image files. This command is Redhat proprietary. Other Linux distributions may have the appropriate commands. This is a handy utility. For details, see Help: Man MKINITRD

The following command creates a INITRD image file:

(3) System.map

System.map is a kernel symbol table for a specific kernel. It is a link to the system.map of the kernel you are currently running.

How is the kernel symbol table created? System.map are produced by "nm Vmlinux" and are not related to the symbol being filtered out. For the example in this article, when compiling the kernel, System.map is created in/usr/src/linux-2.4/system.map. Like this:

nm/boot/vmlinux-2.4.7-10 > System.map

The following lines come from/usr/src/linux-2.4/makefile:

NM Vmlinux | Grep-v ' (compiled) | (. O

) Span id= "mathjax-span-4" class= "Texatom" > | ([a uw ]) < Span id= "mathjax-span-15" class= "Mrow" >| (ng

)| (Lash[rl]di) ' | Sort > System.map

Then copy to/boot:

Cp/usr/src/linux/system.map/boot/system.map-2.4.7-10

When you are programming, you name symbols such as variable names or function names. The Linux kernel is a very complex block of code, with lots of global symbols.

Instead of using symbolic names, the Linux kernel uses the address of a variable or function to identify a variable or function name. For example, instead of using symbols such as size_t bytesread, this variable is referenced like C0343f20.

For people who use computers, they prefer to use names like size_t bytesread rather than names like C0343f20. The kernel is written mainly in C, so the compiler/connector allows us to encode using the symbolic name when the kernel is running with the address.

However, in some cases, we need to know the address of the symbol, or we need to know the corresponding symbol of the address. This is done by the symbol table, which is a list of all the symbols along with their addresses. The Linux symbol table uses up to 2 files:/proc/ksyms and System.map.

/proc/ksyms is a "proc file" that is created when the kernel is booted. In fact, it's not really a file, it's just a representation of the kernel data, but it gives people the illusion of a disk file, which can be seen from its file size of 0. However, System.map is the actual file that exists on your file system. When you compile a new kernel, the address of each symbol name changes, and your old system.map has the wrong symbolic information. Each time the kernel compiles a new system.map, you should replace the old System.map with the new System.map.

Although the kernel itself does not really use SYSTEM.MAP, other programs such as KLOGD, lsof and PS need a correct system.map. If you use the wrong or no SYSTEM.MAP,KLOGD output will be unreliable, this will be difficult to troubleshoot the program. Without System.map, you may face some annoying tips.

The other few drivers need system.map to parse the symbols, and there are no system.map created for the specific kernel that you are currently running, and they do not work properly.

Linux kernel log daemon klogd in order to perform name-address resolution, KLOGD needs to use System.map. The system.map should be placed where the software using it can find it. Execution: Man klogd that if you do not give klogd the position of System.map as a variable, it will find System.map in three places in the following order:

/boot/system.map

/system.map

/usr/src/linux/system.map

System.map also has version information, KLOGD is able to intelligently find the correct image (map) file.

5. References
      • CentOS 6.5 upgrade Kernel to 3.10.28
      • Linux Kernel kernel configuration details
      • How to upgrade the kernel on CentOS
      • CentOS 6.4 Upgrade to 3.x Kernel
      • CentOS Linux Upgrade Kernel steps and methods

CentOS6.5 upgrade Kernel to 3.10.28--verified

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.