安装环境是CentOS 7,内核版本为:3.10.0-693.el7.x86_64
安装
UNAME=$(uname -r)
yum install gcc kernel-devel-${UNAME%.*} elfutils elfutils-devel
yum install rpmdevtools pesign yum-utils zlib-devel \
binutils-devel newt-devel python-devel perl-ExtUtils-Embed \
audit-libs audit-libs-devel numactl-devel pciutils-devel bison
# enable CentOS 7 debug repo
yum-config-manager --enable debug
yum-builddep kernel-${UNAME%.*}
debuginfo-install kernel-${UNAME%.*}
以下为选择安装:
# optional, but highly recommended - enable EPEL 7
yum install ccache
ccache --max-size=5G
# optional, for kpatch-test
yum install patchutils
以上基础工具安装完成之后,下载kpatch,编译,安装:
git clone https://github.com/dynup/kpatch.git
cd kpatch
make
make install
make过程中,若出现:make: * /lib/modules/3.10.0-693.el7.x86_64/build: 没有那个文件或目录
解决方案参见:http://blog.csdn.net/u012343297/article/details/79141878
其他linux distribution中kpatch安装,详见https://github.com/dynup/kpatch
测试
使用kpatch自带的testmod测试:
cd testmod
make
可以看见已经生成ko文件
kpatch install testmod.ko
kpatch list
从kpatch list中我们可以看见已经安装的patch module
测试完成,卸载testmod
kpatch uninstall testmod.ko