CentOS6.5 upgrade kernel to 3.10.28

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

1. Ready to 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)

install software###

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

# yum grouplist  //Check the installed and uninstalled package groups to determine whether we have installed the corresponding development environment and development libraries;# yum groupinstall "Development Tools"  //Generally install these two package groups, doing so will make sure you have all the tools needed for compilation# yum install ncurses-devel //You have to do this to make make*The config command is executed correctly# yum install qt-devel //If you don’t have an X environment, this one can be omitted# yum install hmaccalc zlib-devel binutils-devel elfutils-libelf-devel //Create CentOS-They are needed for 6 cores

If you chose Software workstation to install the system, almost all of the above installation packages are included.

2. Compile the kernel#

Obtain and decompress the kernel source code, configure the compiled item###

There are two Linux kernel versions: stable and development versions. The Linux kernel version number consists of 3 numbers: rxy

Go to http://www.kernel.org homepage, you can see that there are stable, longterm and other versions. Longterm is a more stable version than stable and will be updated for a long time, 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 create a new compilation option based on the original kernel configuration file of the system, so copy a copy to the current directory and name it .config. Next continue to configure:

[ root@sean linux-3.10.58]# sh -c 'yes "" | make oldconfig'
 HOSTCC  scripts/basic/fixdep  HOSTCC  scripts/kconfig/conf.o  SHIPPED scripts/kconfig/zconf.tab.c  SHIPPED scripts/kconfig/zconf.lex.c  SHIPPED scripts/kconfig/zconf.hash.c  HOSTCC  scripts/kconfig/zconf.tab.o  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf --oldconfig Kconfig.config:555:warning: symbol value 'm' invalid for PCCARD_NONSTATIC.config:2567:warning: symbol value 'm' invalid for MFD_WM8400.config:2568:warning: symbol value 'm' invalid for MFD_WM831X.config:2569:warning: symbol value 'm' invalid for MFD_WM8350.config:2582:warning: symbol value 'm' invalid for MFD_WM8350_I2C.config:2584:warning: symbol value 'm' invalid for AB3100_CORE.config:3502:warning: symbol value 'm' invalid for MMC_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 oldconfig will read the .config file in the current directory, and prompt the user to fill in the options that are not found in the .config file, then back up the .config file as .config.old and generate a new one .config file, refer to http://stackoverflow.com/questions/4178526/what-does-make-oldconfig-do-exactly-linux-kernel-makefile

Some documents introduce the use of make memuconfig, which is to customize modules according to needs. The similar interface is as follows: (not needed here)

Start compiling

[ root@sean linux-3.10.58]# make -j4 bzImage  //Generate core files[root@sean linux-3.10.58]# make -j4 modules  //Compile module[root@sean linux-3.10.58]# make -j4 modules_install  //Compile and install modules

installation###

[ root@sean linux-3.10.58]# make install
When actually running to this step, ERROR: modinfo: could not find module vmware_balloon appears, but it does not affect the kernel installation. The module required by vsphere is not compiled. To avoid this problem, you need to modify the .config file before make. Join
HYPERVISOR_GUEST=yCONFIG_VMWARE_BALLOON=m
(This part is more prone to problems, please refer to the abnormal part below)

Modify grub boot, restart###

After the installation is complete, you need to modify the Grub boot sequence to make the newly installed kernel as the default kernel.
Edit the grub.conf file,

vi /etc/grub.conf#boot=/dev/sdadefault=0timeout=5splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS(3.10.58)root(hd0,0)...

Count the location of the newly installed kernel, starting from 0, and then set default to that number. Generally, the newly installed kernel is in the first position, so set default=0.
Restart reboot:

Confirm when the kernel version###

[ root@sean ~]# uname -r3.10.58

The kernel upgrade is successful!

3. abnormal#

Compilation failure (such as lack of dependent packages)

You can clear it first, and then recompile:

# make mrproper         #Finished or the installation process went wrong, you can clean up the last compiled site# make clean

Compiling on the vmware virtual machine, an error similar to the following appears

[ root@sean linux-3.10.58]# make install sh /usr/src/linux-3.10.58/arch/x86/boot/install.sh 3.10.58 arch/x86/boot/bzImage \        System.map "/boot"ERROR: modinfo: could not find module vmware_balloon

You can ignore it, if you have obsessive-compulsive disorder, try the following:
To install VMWARE_BALLOON on vmware, you can directly modify the .config file, but if vi directly adds CONFIG_VMWARE_BALLOON=m, it still has no effect, because it depends on HYPERVISOR_GUEST=y. If you don't know this layer of dependencies, after passing make menuconfig, VMware Balloon Driver cannot be found under Device Drivers -> MISC devices. (You can find this item after manually modifying HYPERVISOR_GUEST with vi .config). In addition, whether it is through make menuconfig or directly vi .config, you must run sh -c'yes "" | make oldconfig' once to get the final Compiler configuration options.
Then, considering that vmware_balloon may have been renamed vmw_balloon in this version, use the following method to be safe:

# cd /lib/modules/3.10.58/kernel/drivers/misc/# ln -s vmw_balloon.ko vmware_balloon.ko #Establish soft connection

In fact, for the kernel compilation environment where Docker is installed, the most sensible choice is to use sciurus to help us configure the .config file.
It is also recommended to run the script check-config.sh before make bzImage to check the missing modules of the current kernel running docker.
When it prompts that other modules are missing, such as NF_NAT_IPV4, it can also be solved by the above method, and then recompile.

4. Introduction to several important Linux kernel files

In the network, many servers use Linux systems. In order to further improve the performance of the server, it may be necessary to recompile the Linux kernel according to specific hardware and requirements. Compiling the Linux kernel needs to follow the prescribed steps. Several important files are involved in the process of compiling the kernel. For example, for RedHat Linux, there are some files related to the Linux kernel in the /boot directory, enter /boot to execute: ls -l. Those who have compiled the RedHat Linux kernel may be more impressed with System.map, vmlinuz, and initrd-2.4.7-10.img, because the process of compiling the kernel involves operations such as the establishment of these files. So how are these files generated? What's the effect?

(1)vmlinuz

vmlinuz is a bootable, compressed kernel. "Vm" stands for "Virtual Memory". Linux supports virtual memory, unlike older operating systems such as DOS which has a 640KB memory limit. Linux can use hard disk space as virtual memory, hence the name "vm". vmlinuz is an executable Linux kernel, it is located in /boot/vmlinuz, and it is generally a soft link.

There are two ways to establish vmlinuz.

One is created by "make zImage" when compiling the kernel, and then generated by: "cp /usr/src/linux-2.4/arch/i386/linux/boot/zImage /boot/vmlinuz". zImage is suitable for small kernels, and it exists for backward compatibility.

The second is to create the kernel through the command make bzImage when compiling, and then through: "cp /usr/src/linux-2.4/arch/i386/linux/boot/bzImage /boot/vmlinuz".

bzImage is a compressed kernel image. It should be noted that bzImage is not compressed with bzip2. The bz in bzImage is easily misunderstood, and bz stands for "big zImage". The b in bzImage means "big".

Both zImage (vmlinuz) and bzImage (vmlinuz) are compressed with gzip. They are not only a compressed file, but the gzip decompression code is embedded in the beginning of the two files. So you cannot unpack vmlinuz with gunzip or gzip -dc.

The kernel file contains a tiny gzip to decompress the kernel and boot it. The difference between the two is that the old zImage decompresses the kernel to the low-end memory (the first 640K), and the bzImage decompresses the kernel to the high-end memory (above 1M). If the kernel is relatively small, one of zImage or bzImage can be used. The operating time of the system booted by the two methods is the same. The big kernel uses bzImage, but not zImage.

vmlinux is an uncompressed kernel, and vmlinuz is a compressed file of vmlinux.

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

initrd is short for "initial ramdisk". Initrd is generally used to temporarily boot the hardware to a state where the actual kernel vmlinuz can take over and continue booting. For example, if the scsi hard disk is used, and there is no driver for this scsi hardware in the kernel vmlinuz, the kernel cannot load the root file system before loading the scsi module, but the scsi module is stored under /lib/modules of the root file system. To solve this problem, you can boot an initrd kernel that can read the actual kernel and use initrd to correct the scsi boot problem. initrd-2.4.7-10.img is a file compressed with gzip, let's take a look at the content of this file.

Initrd realizes loading some modules and installing file system.

The initrd image file is created using mkinitrd. The mkinitrd utility can create an initrd image file. This command is proprietary to RedHat. Other Linux distributions may have corresponding commands. This is a very convenient utility. For details, please see help: man mkinitrd

The following command creates the initrd image file:

(3) System.map

System.map is a kernel symbol table of 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 is generated by "nm vmlinux" and irrelevant symbols are 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 the following:

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

The following lines are from /usr/src/linux-2.4/Makefile:

nm vmlinux | grep -v '(compiled)|(.o

)|([* aUw*])|(..ng

)|( LASH[RL]DI)' | sort > System.map

Then copy to /boot:

cp /usr/src/linux/System.map /boot/System.map-2.4.7-10

During program design, some symbols such as variable names or function names are named. The Linux kernel is a very complex code block, with many global symbols.

The Linux kernel does not use symbolic names, but uses the address of the variable or function to identify the variable or function name. For example, instead of using symbols such as size_t BytesRead, you can refer to this variable like c0343f20.

For people who use computers, they prefer to use names like size_t BytesRead rather than names like c0343f20. The kernel is mainly written in C, so the compiler/linker allows us to use symbolic names when coding and addresses when the kernel is running.

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

/proc/ksyms is a "proc file", created when the kernel boots. In fact, it is not really a file, it is only a representation of kernel data, but it gives people the illusion of a disk file, which can be seen from its file size being 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 will change, and your old System.map has wrong symbol information. A new System.map is generated every time the kernel is compiled, and 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, the output of klogd will be unreliable, which will bring difficulties to troubleshooting. Without System.map, you may face some annoying messages.

In addition, a few drivers require System.map to resolve symbols, and they will not work properly without a System.map created for the specific kernel you are currently running.

In order to perform name-address resolution, the Linux kernel log daemon klogd needs to use System.map. System.map should be placed where the software that uses it can find it. Execution: man klogd knows that if System.map is not given to klogd as a variable location, then it will look for 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, and klogd can intelligently find the correct map file.

5. References#

This article is reproduced from the Internet

Recommended Posts

CentOS6.5 upgrade kernel to 3.10.28
Centos7 upgrade kernel
CentOS7.5-1804 system kernel upgrade
Centos 6.4 python 2.6 upgrade to 2.7
Centos 6.4 python 2.6 upgrade to 2.7
Centos kernel version upgrade
Centos default python2.6 upgrade to
CentOS upgrade python2 to pyth
How to upgrade CentOS7 to CentOS8 (detailed steps)
Linux: Centos7 upgrade the original kernel
Centos6.7 comes with python upgrade to
Remember a centos 7 kernel upgrade accident
CentOS7 upgrade python3
CentOS6.X upgrade kernel Kernel
Centos6.5 openssh upgrade
centos6.9 rabbitmq 3.6.8 upgrade 3.8.2
ubuntu16.04 method steps to upgrade the kernel
Centos kernel compilation configuration
How to upgrade to Ubuntu 20.04
Centos7 delete useless kernel
CentOS 5 to CentOS 5.8 YUM source
How to upgrade to Ubuntu 20.04
Centos delete redundant kernel
Upgrade Ubuntu 18.04 on Azure to 18.10
ububtu10.04, 11.10 online upgrade to ubuntu12.04LTS
Debug Kernel Panic in Centos
centos6.5: gcc upgrade (5.2.0) process record
Update gcc to 6.4.0 in centos
How to upgrade to Ubuntu 16.04 LTS
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
CentOS 8 (2)
CentOS 6/7 configure sendEmail to send mail
[Introduction to redis] Install redis under Centos
How to Update to gcc4.9.x on Centos7
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install PHP7.4 in CentOS
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
Centos7 upgrade git version control tool
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to upgrade to PHP 7 on Ubuntu 14.04
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
Centos6 method steps to build gitlab
How to install Ruby on CentOS 8
How to install Skype on CentOS 8