linux4.4 内核模块,编译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、确认系统具备编译软件的基本条件,即make、gcc、gcc-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后会弹出界面】[root@duwerslinux-4.4]# pwd

/sdb1/linux-4.4

[root@duwers linux-4.4]# make menuconfig

[root@duwers linux-4.4]# vim .config

400956d149d40af0b50dbc0a4879df5b.png

//系统自带的是不支持的[root@duwers linux-4.4]# vim /boot/config-3.10.0-327.el7.x86_64

d2c491623af2bf9f360411cc743350db.png

//把系统自带的拷贝到新内核文件里面,,表述不清晰,大概意思哈,看操作:[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后会弹出界面】

效果如图

2630c85396348209a23e00730f211f8d.png

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 

^

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

//完成后就下图的样子(最后几行代码)

a1bea899e41355eca6aca754176bf7b0.png

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

fe0f8021224e89cf5a61c20fec9964da.png

2)[root@duwers ~]# cd /sdb1/linux-4.4/

[root@duwers linux-4.4]# make install

56c0027a6e4a377ed1e295d732e42c82.png

8、查看或修改GRUB菜单(为了确认是不是把内核安装好了)[root@duwers ~]#vim /boot/grub2/grub.cfg

bb34e07e1b188839c007b8dba5545f73.png

9、重启系统,测试新内核工作情况

///重启要选择啊!重启要选择啊!重启要选择啊!【重要的事情说三遍】

29047418a60c1cd1d6791f8fd3dbbfc6.png

查看新内核

9c55f1766a5c4403e1e73da7098713bf.png

//修改默认的启动选项,

[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!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值