1. git clone kpatch repo from https://github.com/dynup/kpatch.git
  2. config kernel src repo since we need src.rpm package
  3. install dependence package for kpatch yum install -y gcc kernel-devel elfutils elfutils-devel for kpatch-build
1
2
3
4
5
yum install -y rpmdevtools pesign yum-utils
yum-builddep kernel
debuginfo-install kernel
yum install -y elfutils-devel zlib-devel binutils-devel newt-devel
python-devel perl-ExtUtils-Embed audit-libs-devel numactl-devel pciutils-devel
  1. generate a patch exactly the same kernel with the one we will build. Kpatch could not adjust the patch even for a single line. So use 123.el7 to generate a patch if you want to build a module in 123.el7
  2. switch to kpatch folder and run make; make install
  3. kpatch-build your.patch
  4. kpatch load kpatch-your.ko
  5. done