centos linux内核编译环境,CENTOS linux kernel 内核编译
題記:今天裝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/
總結
以上是生活随笔為你收集整理的centos linux内核编译环境,CENTOS linux kernel 内核编译的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux调用一个函数失败 打印错误,l
- 下一篇: linux显示界面指令规范,linux的