Centos7編譯安裝

內核編譯安裝系統
1/從官網下載kernel包文件;www.kernel.org

2/下載完成后解壓到/root下;查看文件大小;
 #ll -h linux-4.12.tar.xz
 查看分區空間及硬盤空間大?。皇欠褡銐颍?

3/解壓kernel包;
 tar -xvf kernel-4.12.tar.xz

 
4/查看目錄大小
#du -sh linux-4.12

5/參考當前操作系統文件為模板進行調整
[root@centos7 ~]#ll /boot/vmlinuz-3.10.0-514.el7.x86_64 -rwxr-xr-x. 1 root root 5392080 Nov 23  2016 /boot/vmlinuz-3.10.0-514.el7.x86_64
模板對應的配置文件;
#cd /boot
config-3.10.0-514.el7.x86_64  模板配置文件
grub
grub2
initramfs-0-rescue-c13ed9ba529c45d6bf915ca67e74c338.img
initramfs-3.10.0-514.el7.x86_64.img
initramfs-3.10.0-514.el7.x86_64kdump.img
initrd-plymouth.img
symvers-3.10.0-514.el7.x86_64.gz
System.map-3.10.0-514.el7.x86_64
vmlinuz-0-rescue-c13ed9ba529c45d6bf915ca67e74c338
vmlinuz-3.10.0-514.el7.x86_64

***
confing-3.10.0-514.el7.x86_64 
在此文件里有記錄了vmlinuz所選的功能,給以在此之上選擇想加進去的功能選項;

有些不常用的驅動模塊放置到 /lib/modules里
***
/boot/vmlinuz-3.10.0-514.el7.x86_6
常用的驅動放置

/usr/lib/modules/3.10.0-514.el7.x86_64---ko文件,模塊方式
不常用的驅動模塊放置
***

vim confing-3.10.0-514.el7.x86_64
查看配置文件,


[root@centos7 boot]#updatedb
[root@centos7 boot]#locate ntfs.ko
[root@centos7 boot]#vim config-3.10.0-514.el7.x86_64 

# Automatically generated file; DO NOT EDIT.
# Linux/x86_64 3.10.0-514.el7.x86_64 Kernel Configuration
#
CONFIG_64BIT=y              y表示安裝到/boot/vmlinuz-3.10.0-514.el7.x86_6
CONFIG_X86=y
CONFIG_INSTRUCTION_DECODER=y
CONFIG_OUTPUT_FORMAT="elf64-x86-64"
CONFIG_ARCH_DEFCONFIG="arch/x86/configs/x86_64_defconfig"

CONFIG_SLUB=y
CONFIG_PROFILING=y
CONFIG_TRACEPOINTS=y
CONFIG_OPROFILE=m           m表示安裝到/usr/lib/modules/3.10.0-514.el7.x86_64
CONFIG_OPROFILE_EVENT_MULTIPLEX=y
CONFIG_HAVE_OPROFILE=y
CONFIG_OPROFILE_NMI_TIMER=y
CONFIG_KPROBES=y

# CONFIG_EXT3_FS is not set
CONFIG_EXT4_FS=m             模塊文件
CONFIG_EXT4_USE_FOR_EXT23=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y


[root@centos7 ~]#locate ext.ko
/usr/lib/modules/3.10.0-514.el7.x86_64/kernel/net/sched/em_text.ko


6/將配置文件拷貝到/root/linux-4.12/.config

[root@centos7 boot]#cp config-3.10.0-514.el7.x86_64  /root/linux-4.12/.config
[root@centos7 boot]#wc -l /root/linux-4.12/.config 
5848 /root/linux-4.12/.config
查看文件行數

配置文件行數較多,用菜單工具定制內核選項;
需安裝開發工具包組
[root@centos7 boot]#yum install "Development tools"
[root@centos7 boot]#yum groupinstall "Development tools"

包組安裝完成后,運行軟件工具 make menuconfig

進入到/linux-4.12目錄下運行軟件工具;


[root@centos7 ~]#ls
1.log                  Downloads             Pictures
2017-07-02-22.tar.xz   initial-setup-ks.cfg  Public
2017-07-02-Jul.tar.xz  IP.sh                 script
a                      linux-4.12            select.sh
anaconda-ks.cfg        linux-4.12.tar.xz     Templates
cat                    Music                 testdir
Desktop                oper2017-07-07.log    Videos
Documents              opertion.sh
[root@centos7 ~]#cd linux-4.12
[root@centos7 linux-4.12]#ls
arch     crypto         include  kernel       net       sound
block    Documentation  init     lib          README    tools
certs    drivers        ipc      MAINTAINERS  samples   usr
COPYING  firmware       Kbuild   Makefile     scripts   virt
CREDITS  fs             Kconfig  mm           security
[root@centos7 linux-4.12]#make menuconfig
  HOSTCC  scripts/basic/fixdep
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
make: *** [menuconfig] Error 2
[root@centos7 linux-4.12]#yum install ncurses-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.hust.edu.cn
 * extras: mirror.lzu.edu.cn
 * updates: mirrors.nju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package ncurses-devel.x86_64 0:5.9-13.20130511.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================
 Package            Arch        Version                   Repository
                                                                     Size
==========================================================================
Installing:
 ncurses-devel      x86_64      5.9-13.20130511.el7       base      713 k

Transaction Summary
==========================================================================
Install  1 Package

Total download size: 713 k
Installed size: 2.1 M
Is this ok [y/d/N]: y
Downloading packages:
ncurses-devel-5.9-13.20130511.el7.x86_64.rpm         | 713 kB   00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ncurses-devel-5.9-13.20130511.el7.x86_64               1/1 
  Verifying  : ncurses-devel-5.9-13.20130511.el7.x86_64               1/1 

Installed:
  ncurses-devel.x86_64 0:5.9-13.20130511.el7                              

Complete!


安裝缺少的安裝包;

進入到/root/linux-4.12目錄下(解壓的目錄):
[root@centos7 linux-4.12]#make menuconfig

* 為保存到內核文件/boot/vmlinuz

M 為保存到模塊文件/usr/lib/modules/


進入圖形菜單欄,編輯本地kernel版本,
General setup--->

local - append to kernel release

save---保存

File systems --->編輯文件系統

DOS/FAT/NT Filesystems --->

<M> NTFS file system support                           

[*]   NTFS debugging support                          
[*]   NTFS write support 

save ---> 保存退出

[root@centos7 linux-4.12]#ll .config /boot/config-3.10.0-514.el7.x86_64 
-rw-r--r--. 1 root root 137696 Nov 23  2016 /boot/config-3.10.0-514.el7.x86_64
-rw-r--r--. 1 root root 168537 Jul 12 17:40 .config

# CONFIG_FAT_DEFAULT_UTF8 is not set
CONFIG_NTFS_FS=m      設置成功
CONFIG_NTFS_DEBUG=y
CONFIG_NTFS_RW=y

#
# Pseudo filesystems


#在/root/linux-4.2-- 目錄下
#make -j 4 編譯

#ll -sh


#make modules_install 生成KO文件;

[root@centos7 linux-4.12]#ls /lib/modules
3.10.0-514.el7.x86_64  4.12.0-byf-1.2

[root@centos7 modules]#find 4.12.0-byf-1.2/ -name "*.ko"

[root@centos7 linux-4.12]#make install
Makefile:933: "Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel"
sh ./arch/x86/boot/install.sh 4.12.0-byf-1.2 arch/x86/boot/bzImage \
        System.map "/boot"
^Cmkinitrd failed
make: *** [install] Interrupt

[root@centos7 linux-4.12]#yum install  elfutils-libelf-devel
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.hust.edu.cn
 * extras: mirror.lzu.edu.cn
 * updates: mirrors.nju.edu.cn
Resolving Dependencies
--> Running transaction check
---> Package elfutils-libelf-devel.x86_64 0:0.166-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================
 Package                                Arch                    Version                      Repository             Size
=========================================================================================================================
Installing:
 elfutils-libelf-devel                  x86_64                  0.166-2.el7                  base                   37 k

Transaction Summary
=========================================================================================================================
Install  1 Package

Total download size: 37 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
elfutils-libelf-devel-0.166-2.el7.x86_64.rpm                                                      |  37 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : elfutils-libelf-devel-0.166-2.el7.x86_64                                                              1/1 
  Verifying  : elfutils-libelf-devel-0.166-2.el7.x86_64                                                              1/1 

Installed:
  elfutils-libelf-devel.x86_64 0:0.166-2.el7                                                                             

Complete!



[root@centos7 linux-4.12]#[root@centos7 linux-4.12]#ls /boot
config-3.10.0-514.el7.x86_64                             System.map-3.10.0-514.el7.x86_64
grub                                                     System.map-4.12.0-byf-1.2
grub2                                                    System.map-4.12.0-byf-1.2.old
initramfs-0-rescue-c13ed9ba529c45d6bf915ca67e74c338.img  vmlinuz
initramfs-3.10.0-514.el7.x86_64.img                      vmlinuz-0-rescue-c13ed9ba529c45d6bf915ca67e74c338
initramfs-3.10.0-514.el7.x86_64kdump.img                 vmlinuz-3.10.0-514.el7.x86_64
initrd-plymouth.img                                      vmlinuz-4.12.0-byf-1.2
symvers-3.10.0-514.el7.x86_64.gz                         vmlinuz-4.12.0-byf-1.2.old


[root@centos7 linux-4.12]#make install
sh ./arch/x86/boot/install.sh 4.12.0-byf-1.2 arch/x86/boot/bzImage \
        System.map "/boot"

[root@centos7 linux-4.12]#cat /boot/grub2/grub.cfg 
查看配置文件是否生成
menuentry 'CentOS Linux (4.12.0-byf-1.2) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-514.el7.x86_64-advanced-f86bb45c-c257-4f7c-ae3c-fa72b50f277c' 


[root@centos7 linux-4.12]#uname -r
3.10.0-514.el7.x86_64

重啟選擇編譯的內核啟動;

[root@centos7 ~]#uname -r
4.12.0-byf-1.2
啟動成功;

ntfs格式linux只支持只讀;
#mount -o rw /dev/sdc1 /mnt
#mount 可以看出只讀;
1下載kernel 源碼包
tar xf linux.XXX.xz
/root/linux.4.12/

2 生成配置模版文件 
cp /boot/config.XXX /root/linux.4.12/.config

3 yum groupnstall  "Development Tools"
yum install ncurses-devel 

4 make menuconfig 
選中NTFS
local version 

5 make -j 4 && for i in {1..10};do echo -e "\a";sleep 1;done

6 make modules_install  /lib/modules/`uname -r`

7 make install  /boot/vmlinuz  /boot/grub2/grub.cfg
在已經執行過編譯操作的內核源碼樹做重新編譯
?  需要事先清理操作:
make clean :清理大多數編譯生成的文件,但會保留
config 文件等
make mrproper:  清理所有編譯生成的文件、config 及某
些備份文件
make distclean :mrproper 、patches以及編輯器備份文件

?  刪除/lib/modules/ 目錄下不需要的內核庫文件
?  刪除/usr/src/linux/ 目錄下不需要的內核源碼
?  刪除/boot 目錄下啟動的內核和內核映像文件
?  更改grub 的配置文件,刪除不需要的內核啟動列表

編譯安裝

cd isolinux/
ll vmlinuz 內核文件
跟boot目錄下的一樣
出廠版本,及日期

上傳 linux-4.12.tar.xz文件(rz)

占用10G多的空間

解開包--解壓縮 
tar xf linux---


#du -sh linux-4.12


ll /boot/vmlinuz  參考文件進行修改

cd /boot

config----   配置文件,

ls /lib/modules


更新數據庫updatedb

locate ntfs.ko

ls

locate ext4.ko

菜單工具

安裝開發工具包組
yum groupinstall "development Tools“


make menuconfig 運行軟件工具


install 安裝缺少的包文件
 

uname -r
內核版本


fIle system 
文件系統


DOS/FAT/NT  ntfs


make -j  4  有四顆cpu 四線程
 
cd /root/lnux---
ls 
查看生成的目錄

(b)make manuconfig

ls /lib/modules
make  modules_install
自動添加到配置文建中
 
編譯:
cd /root/linux

ls net/

1、可以選擇性編譯

2、指定某個特定的目錄進行編譯


編譯的平臺 make ARHM


updatedb 更新

locate ntfs.ko
看文件

make modules_install


cd /root/linux-
切換 并進行操作 make install

reboot
重啟后選擇新的內核啟動


系統中的程序支持不支持內核,不支持將使用不了

ntfs 不支持,只讀更改不了{windows}

locate /lib/modules

選擇性編譯;




#############################################make clean 清除文件
在 想~清理的目錄下進行清理

make mrproper 清理所有的編譯生成的文件

makedistclean  

############################################
卸載內核 





############################################
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市,隨后出現的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 228,936評論 6 535
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 98,744評論 3 421
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 176,879評論 0 381
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,181評論 1 315
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 71,935評論 6 410
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 55,325評論 1 324
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,384評論 3 443
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 42,534評論 0 289
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,084評論 1 335
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 40,892評論 3 356
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,067評論 1 371
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 38,623評論 5 362
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,322評論 3 347
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 34,735評論 0 27
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 35,990評論 1 289
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 51,800評論 3 395
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,084評論 2 375

推薦閱讀更多精彩內容

  • 構建DNS服務的最基礎的軟件是bind,DNS服務的進程名是named。為了增強安全性,我們要安裝最新版的bind...
    不知歲月惜閱讀 1,779評論 0 1
  • 架構圖參考如下: 1.下載nginx 2.解壓nginx壓縮包.tar.gz 解壓后得到文件夾 3.安裝gcc[r...
    yhyok閱讀 1,362評論 0 50
  • 我們說的Linux其實指的就是 內核(kernel)而已。這個內核控制你主機的所有硬件并提供系統所有的功能,所以它...
    Zhang21閱讀 7,447評論 0 18
  • 獲取知識,首先遵循“簡化原則”,也就是清楚自己的目的,既要學會總結概括邏輯架構,也要排除一些沒用的內容干擾。“速度...
    張彥博Burgess閱讀 140評論 0 0
  • 這絕對是一個不一樣的暑假,接觸新的領域,挑戰著自己的極限,外貿與健身就像我的衣服和鞋子,與我如影隨...
    桂哥1111閱讀 567評論 16 4