centos7没有自带kmod-drbd84 rpm。
google并下载 drbd84-kmod-8.4.6-1.el7.elrepo.src.rpm,安装该rpm源码包,然后利用rpmbuild生成rpm。
# yum install kernel-devel
# rpmbuild -ba drbd84-kmod.spec
...
+ cd /root/rpmbuild/BUILD
+ cd drbd-8.4.4
+ KSRC=/usr/src/kernels/3.10.0-123.el7.x86_64
+ /usr/bin/make -j2 module KDIR=/usr/src/kernels/3.10.0-123.el7.x86_64
make: *** /usr/src/kernels/3.10.0-123.el7.x86_64: No such file or directory. Stop.
SORRY, kernel makefile not found.
You need to tell me a correct KDIR,
Or install the neccessary kernel source packages.
...
# uname -r
3.10.0-229.x86_64
显示内核版本不一致,需要指定。查看一下spec文件
drbd84-kmod.spec
5 # If kversion isn't defined on the rpmbuild line, define it here.
6 %{!?kversion: %define kversion 3.10.0-123.el7.%{_target_cpu}}
52 %build
53 KSRC=%{_usrsrc}/kernels/%{kversion}
54 %{__make} %{?_smp_mflags} module KDIR="${KSRC}"
可见,只要定义正确的kversion宏定义,就可以找到正确的内核源码位置。执行
# rpmbuild -D 'kversion 3.10.0-229.el7.x86_64' -ba drbd84-kmod.spec
成功生成kmod-drbd84-8.4.6-1.el7.centos.x86_64.rpm。