编译Linux内核4.4实现可读NTFS
环境:rehl7.2 x64 3G内存 3核 40磁盘
[[email protected]~]# uname –r #查看内核
3.10.0-327.el7.x86_64
[[email protected] ~]# mkdir /sdb1 #建立挂载点/sdb1
[[email protected] ~]# fdisk /dev/sdb #把所有空间给sdb1
[[email protected] ~]# mkfs.xfs /dev/sdb1 #格式化sdb1
[[email protected] ~]# mount /dev/sdb1 /sdb1 #挂载
1、 下载相应内核源码包4.4
[[email protected]]# ls
linux-4.4.tar.xz
2、 确认系统具备编译软件的基本条件,即make、gcc、gcc-c++、ncurses-devel
[[email protected]]# cd
[[email protected]~]# rpm -qa | grep make
make-3.82-21.el7.x86_64
automake-1.13.4-3.el7.noarch
[[email protected]~]# 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
[[email protected]~]# rpm -qa | grep gcc-c++
gcc-c++-4.8.5-4.el7.x86_64
[[email protected]~]# rpm -qa | grep ncurses-devle
[[email protected]~]# #没有ncurses-devel,重新安装
[[email protected]~]# yum -y install ncurses-devel
3、 解压内核源码包
[[email protected]~]# cd /sdb1
[[email protected]]# ls
linux-4.4.tar.xz
[[email protected]]# xz -d linux-4.4.tar.xz
[[email protected]]# ls
linux-4.4.tar
[[email protected]]# tar -xf linux-4.4.tar
[[email protected]]# ls
linux-4.4 linux-4.4.tar
[[email protected]]# du -sh linux-4.4
702M linux-4.4
//
[[email protected]]# free -m
total used free shared buff/cache available
Mem: 2993 371 721 9 1901 2398
Swap: 2047 0 2047
[[email protected]]# echo 3 > /proc/sys/vm/drop_caches
[[email protected]]# free -m
total used free shared buff/cache available
Mem: 2993 333 2512 9 148 2507
Swap: 2047 0 2047
4、 配置内核编译参数
[[email protected]]# pwd
/sdb1/linux-4.4
[[email protected] linux-4.4]# make menuconfig
[[email protected] linux-4.4]# vim .config
系统自带的是不支持的
[[email protected] linux-4.4]# vim /boot/config-3.10.0-327.el7.x86_64
[[email protected] 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
[[email protected] linux-4.4]#
[[email protected] linux-4.4]# make menuconfig
[[email protected] linux-4.4]# vim ./.config
5、 编译内核
//生成内核
[[email protected] 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
[[email protected] linux-4.4]#
//解决
[[email protected] linux-4.4]# yum -y install openssl-devel
//重新生成内核
[[email protected] linux-4.4]# make bzImage #半小时
6、 生成新内核的驱动模块
[[email protected] linux-4.4]# make modules #1小时
//清空缓存
[[email protected] linux-4.4]# sync
[[email protected] linux-4.4]# free –m
7、 安装编译好的内核与模块
1) 安装模块
[[email protected] linux-4.4]# make modules_install
2)[[email protected] ~]# cd /sdb1/linux-4.4/
[[email protected] linux-4.4]# make install
8、 查看或修改GRUB菜单(为了确认是不是把内核安装好了)
[[email protected] ~]#vim /boot/grub2/grub.cfg
9、 重启系统,测试新内核工作情况
重启选择
查看新内核
切记,在公司编译内核一定要在虚拟机上实验之后再搬到真机上去编译哦
小手一抖,轻松转走,欢迎你转载给更多需要学习技术的人。
辛舒展: 专注大数据领域,现有技能Python,Linux,
爱好:写程序,写文章,旅游,妹子