题记:今天装docker,提示我最好用3.10以上的内核
一.环境
1.1 系统环境
[root@test kernels]# lsb
lsblk lsb_release
[root@test kernels]# lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.5 (Final)
Release: 6.5
Codename: Final
1.2 当前内核版本
Display all 259 possibilities? (y or n)
[root@test kernels]# more /proc/version
Linux version 2.6.32-431.el6.x86_64 (mockbuild@c6b8.bsys.dev.centos.org) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) ) #1 SMP Fri Nov 22 03:15:09 UTC 2013
二.安装
2.1 获取高版本内核,并解压到/usr/src/kernels
cd /root/soft
wget
cd /usr/src/kernels
tar -xJvf /root/soft/linux-3.10.87.tar.xz
2.2 编译&安装
A:进入内核目录,执行make menuconfig 修改编译配置文件
[root@test kernels]# cd linux-3.10.87/
[root@test linux-3.10.87]# pwd
/usr/src/kernels/linux-3.10.87
[root@test linux-3.10.87]# make menuconfig
HOSTCC scripts/basic/fixdep
HOSTCC scripts/kconfig/conf.o
HOSTCC scripts/kconfig/lxdialog/checklist.o
HOSTCC scripts/kconfig/lxdialog/inputbox.o
HOSTCC scripts/kconfig/lxdialog/menubox.o
HOSTCC scripts/kconfig/lxdialog/textbox.o
HOSTCC scripts/kconfig/lxdialog/util.o
HOSTCC scripts/kconfig/lxdialog/yesno.o
HOSTCC scripts/kconfig/mconf.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/mconf
scripts/kconfig/mconf Kconfig
#
# using defaults found in /boot/config-2.6.32-431.el6.x86_64
#
/boot/config-2.6.32-431.el6.x86_64:497:warning: symbol value 'm' invalid for X86_INTEL_PSTATE
/boot/config-2.6.32-431.el6.x86_64:565:warning: symbol value 'm' invalid for PCCARD_NONSTATIC
/boot/config-2.6.32-431.el6.x86_64:2730:warning: symbol value 'm' invalid for MFD_WM8400
/boot/config-2.6.32-431.el6.x86_64:2731:warning: symbol value 'm' invalid for MFD_WM831X
/boot/config-2.6.32-431.el6.x86_64:2732:warning: symbol value 'm' invalid for MFD_WM8350
/boot/config-2.6.32-431.el6.x86_64:2745:warning: symbol value 'm' invalid for MFD_WM8350_I2C
/boot/config-2.6.32-431.el6.x86_64:2747:warning: symbol value 'm' invalid for AB3100_COR
注意:此处我的系统是64位,所以要选用64-bit kernel
然后保存,检查配置文件 .config
[root@test linux-3.10.87]# ls -al
总用量 684
drwxrwxr-x 23 root root 4096 8月 20 14:39 .
drwxr-xr-x. 4 www root 4096 8月 20 14:16 ..
drwxrwxr-x 32 root root 4096 8月 17 11:52 arch
drwxrwxr-x 3 root root 4096 8月 17 11:52 block
-rw-r----- 1 root root 119834 8月 20 14:39 .config
-rw-rw-r-- 1 root root 18693 8月 17 11:52 COPYING
-rw-rw-r-- 1 root root 95317 8月 17 11:52 CREDITS
drwxrwxr-x 4 root root 4096 8月
B:编译 make all 这一步 执行的时间很长,我这边有一个小时左右
[root@test linux-3.10.87]# pwd
/usr/src/kernels/linux-3.10.87
[root@test linux-3.10.87]# make all
C: 安装模块
[root@test linux-3.10.87]# make modules_install
D:执行make install
[root@test linux-3.10.87]# make install
sh /usr/src/kernels/linux-3.10.87/arch/x86/boot/install.sh 3.10.87 arch/x86/boot/bzImage \
System.map "/boot"
ERROR: modinfo: could not find module xt_MARK
ERROR: modinfo: could not find module ipt_MASQUERADE
ERROR: modinfo: could not find module iptable_nat
ERROR: modinfo: could not find module nf_nat
ERROR: modinfo: could not find module vmhgfs
ERROR: modinfo: could not find module vsock
ERROR: modinfo: could not find module vmware_balloon
ERROR: modinfo: could not find module vmci
[root@test linux-3.10.87]#
报错了
暂时未解决
解决问题:在系统上lsmod 确实有上面几个模块
[root@test 2.6.32-504.3.3.el6.x86_64]# lsmod | grep xt_MARK
xt_MARK 1057 3
[root@test 2.6.32-504.3.3.el6.x86_64]# pwd
/usr/src/kernels/2.6.32-504.3.3.el6.x86_64
但是我在/usr/src/kernels/2.6.32-504.3.3.el6.x86_64/.config 里也没找到这些模块
[root@test 2.6.32-504.3.3.el6.x86_64]# grep ipt_MASQUERADE .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep xt_MARK .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep iptable_nat .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep nf_nat .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep vmhgfs .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep vsock .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep vmware_balloon .config
[root@test 2.6.32-504.3.3.el6.x86_64]# grep vmci .config
[root@test 2.6.32-504.3.3.el6.x86_64]# lsmod | grep xt_MARK
xt_MARK 1057 3
[root@test 2.6.32-504.3.3.el6.x86_64]# pwd
/usr/src/kernels/2.6.32-504.3.3.el6.x86_64
[root@test 2.6.32-504.3.3.el6.x86_64]# pwd
/usr/src/kernels/2.6.32-504.3.3.el6.x86_64
所以上面的报错可能不影响正常使用,正在继续测试中
E:修改启动文件 /boot/grub/grub.conf
步骤:先备份该文件
[root@test boot]# cd grub/
[root@test grub]# ls -al
总用量 280
drwxr-xr-x. 2 root root 1024 8月 24 22:26 .
dr-xr-xr-x. 5 root root 1024 8月 24 22:12 ..
-rw-r--r--. 1 root root 63 10月 25 2014 device.map
-rw-r--r--. 1 root root 13380 10月 25 2014 e2fs_stage1_5
-rw-r--r--. 1 root root 12620 10月 25 2014 fat_stage1_5
-rw-r--r--. 1 root root 11748 10月 25 2014 ffs_stage1_5
-rw------- 1 root root 1080 8月 24 22:26 grub.conf
-rw------- 1 root root 1080 8月 24 22:26 grub.conf.bak
-rw-r--r--. 1 root root 11756 10月 25 2014 iso9660_stage1_5
-rw-r--r--. 1 root root 13268 10月 25 2014 jfs_stage1_5
lrwxrwxrwx. 1 root root 11 10月 25 2014 menu.lst -> ./grub.conf
-rw-r--r--. 1 root root 11956 10月 25 2014 minix_stage1_5
-rw-r--r--. 1 root root 14412 10月 25 2014 reiserfs_stage1_5
-rw-r--r--. 1 root root 1341 11月 15 2010 splash.xpm.gz
-rw-r--r--. 1 root root 512 10月 25 2014 stage1
-rw-r--r--. 1 root root 126100 10月 25 2014 stage2
-rw-r--r--. 1 root root 12024 10月 25 2014 ufs2_stage1_5
-rw-r--r--. 1 root root 11364 10月 25 2014 vstafs_stage1_5
-rw-r--r--. 1 root root 13964 10月 25 2014 xfs_stage1_5
[root@test grub]# pwd
/boot/grub
[root@test grub]# cp grub.conf grub.conf.bak
然后修改参数default=0
0表示启动第一个
1表示启动第二个
下面是我的已修改版:
[root@test grub]# less grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.87)
root (hd0,0)
kernel /vmlinuz-3.10.87 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=VolGroup/lv_swap crashkernel=auto.UTF-8 rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-3.10.87.img
title CentOS (2.6.32-431.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS rd_NO_MD rd_LVM_LV=VolGroup/lv_swap crashkernel=auto.UTF-8 rd_LVM_LV=VolGroup/lv_root KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-431.el6.x86_64.img
三 验证
3.1 重启
[root@test grub]# reboot
3.2 检查
[root@test grub]# uname -a
Linux test.localdomain 3.10.87 #1 SMP Mon Aug 24 21:43:03 CST 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@test grub]# cat /proc/version
Linux version 3.10.87 (root@test.localdomain) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP Mon Aug 24 21:43:03 CST 2015
[root@test grub]#
http://smilejay.com/2013/11/kernel-install-error-could-not-find-module/