編譯Linux內核4.4實現可讀NTFS


環境:rehl7.2 x64 3G內存 3 40磁盤

 //查看內核

[root@duwers~]# uname –r                    #查看內核
  3.10.0-327.el7.x86_64


//加20G磁盤

[root@duwers ~]# mkdir /sdb1                                          
[root@duwers ~]# fdisk /dev/sdb                                    
[root@duwers ~]# mkfs.xfs /dev/sdb1                             
[root@duwers ~]# mount /dev/sdb1 /sdb1                     
[root@duwers ~]# tail -1 /etc/fstab 
/dev/sdb1 /sdb1 xfs defaults 0 0
[root@duwers ~]#

1、  下載相應內核源碼包4.4

[root@duwerssdb1]# ls
linux-4.4.tar.xz
[root@duwerssdb1]#

2、  確認系統具備編譯軟件的基本條件,即makegccgcc-c++ncurses-devel

[root@duwerssdb1]# cd
[root@duwers~]# rpm -qa | grep make
make-3.82-21.el7.x86_64
automake-1.13.4-3.el7.noarch
[root@duwers~]# rpm -qa | grep gcc
gcc-c++-4.8.5-4.el7.x86_64
libgcc-4.8.5-4.el7.x86_64
gcc-4.8.5-4.el7.x86_64
gcc-gfortran-4.8.5-4.el7.x86_64
[root@duwers~]# rpm -qa | grep gcc-c++
gcc-c++-4.8.5-4.el7.x86_64
[root@duwers~]# rpm -qa | grep ncurses-devle
[root@duwers~]#                                                  
[root@duwers~]# yum -y install ncurses-devel

3、 解壓內核源碼包

[root@duwers~]# cd /sdb1
[root@duwerssdb1]# ls
linux-4.4.tar.xz
[root@duwerssdb1]# xz -d linux-4.4.tar.xz
[root@duwerssdb1]# ls
linux-4.4.tar
[root@duwerssdb1]# tar -xf linux-4.4.tar
[root@duwerssdb1]# ls
linux-4.4  linux-4.4.tar
[root@duwerssdb1]# du -sh linux-4.4
702M         linux-4.4
[root@duwerssdb1]#

//釋放緩存

[root@duwerssdb1]# free -m
              total        used        free      shared buff/cache   available
Mem:           2993         371         721           9        1901        2398
Swap:          2047           0        2047
[root@duwerssdb1]# echo 3 > /proc/sys/vm/drop_caches
[root@duwerssdb1]# free -m
              total        used        free      shared buff/cache   available
Mem:           2993         333        2512           9         148        2507
Swap:          2047           0        2047
[root@duwerssdb1]#

4、 配置內核編譯參數【改成支持NTFS的,在make menuconfig後會彈出界面

[[email protected]]# pwd
/sdb1/linux-4.4
[root@duwers linux-4.4]# make menuconfig
[root@duwers linux-4.4]# vim .config

wKiom1dtSDCjragvAAAN-LJ7dUM550.png-wh_50

//系統自帶的是不支持的

[root@duwers linux-4.4]# vim /boot/config-3.10.0-327.el7.x86_64

wKioL1dtSGzg-sgLAAAQ_LXJ-CY097.png-wh_50

//把系統自帶的拷貝到新內核文件裏面,,表述不清晰,大概意思哈,看操作:

[root@duwers linux-4.4]#
[root@duwers linux-4.4]# cp /boot/config-3.10.0-327.el7.x86_64  /sdb1/linux-4.4/.config
cp: overwrite ‘/sdb1/linux-4.4/.config’? y
[root@duwers linux-4.4]#
[root@duwers linux-4.4]# make menuconfig
[root@duwers linux-4.4]# vim ./.config

拷貝好以後修改【改成支持NTFS的,在make menuconfig後會彈出界面

效果如圖

wKiom1dtSUrC-xV_AAARhRBw83M931.png-wh_50


5、編譯內核

//生成內核

[root@duwers linux-4.4]# make bzImage

//這裏是會報錯的喔!!報錯如下(末尾的幾行代碼)

 

HOSTCC scripts/sortextable
  HOSTCC scripts/asn1_compiler
  HOSTCC scripts/sign-file
scripts/sign-file.c:23:30:fatal error: openssl/opensslv.h: No such file or directory
 #include <openssl/opensslv.h>
                              ^
compilationterminated.
make[1]:*** [scripts/sign-file] Error 1
make: ***[scripts] Error 2
[root@duwers linux-4.4]#

//解決

[root@duwers linux-4.4]# yum -y install openssl-devel

//重新生成內核,大概半小時吧,

[root@duwers linux-4.4]# make bzImage

//完成後就下圖的樣子(最後幾行代碼)

 wKioL1dtSgXin4DcAAAomKw0plA429.png-wh_50

6、 生成新內核的驅動模塊,就下面這個make 搞了我一個多小時,忘記-j 4了

[root@duwers linux-4.4]# make modules

  // 忘記截圖了,呵呵噠                            

//清空緩存

[root@duwers linux-4.4]# sync
[root@duwers linux-4.4]# free –m

 

7、  安裝編譯好的內核與模塊

1)  安裝模塊,這個快,幾分鐘的事情

[root@duwers linux-4.4]# make modules_install

wKioL1dtSy2xzui3AABrit64oDg192.png-wh_50    

2)

[root@duwers ~]# cd /sdb1/linux-4.4/
[root@duwers linux-4.4]# make install

  wKiom1dtS4ajWyqVAAAYQW6nZgk810.png-wh_50                      


8、  查看或修改GRUB菜單(爲了確認是不是把內核安裝好了)

[root@duwers ~]#vim /boot/grub2/grub.cfg

wKiom1dtS7CSSjMAAACgTyETGuc296.png-wh_50


9、  重啓系統,測試新內核工作情況

///重啓要選擇啊!重啓要選擇啊!重啓要選擇啊!【重要的事情說三遍】


wKioL1dtTAmjaFWQAAAfYH7I1Sg645.png-wh_50


查看新內核

wKioL1dtTCCTGeMGAAAP1f6MF1A408.png-wh_50

 

//修改默認的啓動選項,


[root@duwers linux-4.6.3]# cat /boot/grub2/grub.cfg |grep menuentry 
if [x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
exportmenuentry_id_option
menuentry'Red Hat Enterprise Linux Server (4.4.0) 7.2 (Maipo)' --class red --classgnu-linux --class gnu --class os --unrestricted $menuentry_id_option'gnulinux-3.10.0-327.el7.x86_64-advanced-a91da850-a46f-4604-a494-54b56d1a2841'{
menuentry'Red Hat Enterprise Linux Server (3.10.0-327.el7.x86_64) 7.2 (Maipo)' --cla***ed --class gnu-linux --class gnu --class os --unrestricted$menuentry_id_option'gnulinux-3.10.0-327.el7.x86_64-advanced-a91da850-a46f-4604-a494-54b56d1a2841'{
menuentry'Red Hat Enterprise Linux Server (0-rescue-7dd2238acdc6468c9bfec97e0a5978fb)7.2 (Maipo)' --class red --class gnu-linux --class gnu --class os--unrestricted $menuentry_id_option'gnulinux-0-rescue-7dd2238acdc6468c9bfec97e0a5978fb-advanced-a91da850-a46f-4604-a494-54b56d1a2841'{
[root@duwers linux-4.6.3]# grub2-set-default "Red Hat Enterprise Linux Server (4.4.0)7.2 (Maipo)"
[root@duwers linux-4.6.3]# grub2-editenv list
saved_entry=RedHat Enterprise Linux Server (4.4.0) 7.2 (Maipo)
[root@duwers linux-4.6.3]#



The End!!














發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章