CentOS Linux release 7.2.1511 (Core)
[root@pizhi-kernel boot]# pwd
/boot
[root@pizhi-kernel boot]# cp config-3.10.0-229.el7.x86_64 /home/pizhi/linux-4.6.4/.config
make rpm
yum install ./*.rpm
yum install kernel-devel
hello.c:
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void) {
printk(KERN_WARNING"Hello, pikachu kernel!\n");
return 0;
}
static void hello_exit(void) {
printk(KERN_INFO"Goodbye, pikachu kernel!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
Makefile:
ifneq ($(KERNELRELEASE),)
obj-m := hello.o
else
KDIR := /lib/modules/&#x60;uname -r&#x60;/build
all :
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
endif
make -C /lib/modules/&#x60;uname -r&#x60;/build M=/root/code_kernel/hello modules
make: *** /lib/modules/3.10.0-327.el7.x86_64/build: No such file or directory. Stop.
make: *** [all] Error 2
[root@localhost 3.10.0-327.el7.x86_64]# pwd
/lib/modules/3.10.0-327.el7.x86_64
[root@localhost 3.10.0-327.el7.x86_64]# rm build
[root@localhost 3.10.0-327.el7.x86_64]# ln -sv /usr/src/kernels/3.10.0-514.2.2.el7.x86_64/ build
yum-builddep kernel-3.10.0-327.el7.src.rpm
rpm -ivh kernel-3.10.0-327.el7.src.rpm
yum-builddep /root/rpmbuild/SPECS/kernel.spec
rpmbuild -bp /root/rpmbuild/SPECS/kernel.spec
/root/rpmbuild/BUILD/kernel-3.10.0-327.el7
/root/rpmbuild/BUILD/kernel-3.10.0-327.el7/linux-3.10.0-327.el7.x86_64
make -j8 -C &#x60;pwd&#x60; M=&#x60;pwd&#x60;/arch/x86/kvm modules
[root@pizhi-kernel ~]# lsmod | grep kvm
kvm_intel 162153 0
kvm 525259 1 kvm_intel
modprobe -r kvm_intel
cd /root/rpmbuild/BUILD/kernel-3.10.0-327.el7/linux-3.10.0-327.el7.x86_64/arch/x86/kvm
insmod kvm.ko
insmod kvm-intel.ko
欢迎光临 51学通信论坛2017新版 (http://bbs.51xuetongxin.com/) | Powered by Discuz! X3 |