Difference between revisions of "Building external kernel modules"
Line 52: | Line 52: | ||
== Building a kernel module rpm package (kmod) == | == Building a kernel module rpm package (kmod) == | ||
TBD, you are welcome to put the description here. :) | TBD, you are welcome to put the description here. :) | ||
+ | |||
+ | --[[User:Finist|Finist]] ([[User talk:Finist|talk]]) 05:07, 6 February 2016 (EST) | ||
[[Category: HOWTO]] | [[Category: HOWTO]] | ||
[[Category: Kernel]] | [[Category: Kernel]] | ||
[[Category: Installation]] | [[Category: Installation]] |
Revision as of 10:07, 6 February 2016
This article describes how to build an kernel module which is not included into the stock Virtuozzo kernel. (This article applies to Virtuozzo 7.)
Building a kernel module (*.ko)
Here is an example how to build "via-rhine" kernel module which is in the Virtuozzo kernel source tree, but not enabled in kernel config by default.
// You need to install some dev packages in advance (the list here may be incomplete). # yum install rpm-build gcc xmlto asciidoc hmaccalc python-devel newt-devel pesign
// If you are going to build a kernel module against some kernel, you need kernel headers for that kernel. // Assume you want to build a kernel module against currently running kernel. # yum install vzkernel-devel.x86_64
// Get sources of the module you'd like to build, // in this particular example the easiest way i believe is just to download the kernel src.rpm. # cd /tmp # wget https://download.openvz.org/virtuozzo/factory/source/SRPMS/v/vzkernel-3.10.0-327.3.1.vz7.10.10.src.rpm # rpm -ihv vzkernel-3.10.0-327.3.1.vz7.10.10.src.rpm // "Prepare" source tree, it's not enough just to take the archive stored in it, // you need to apply additional patch(es), rpmbuild does this for us. # rpmbuild -bp /root/rpmbuild/SPECS/kernel.spec --nodeps
// Go to the module source directory. # cd /root/rpmbuild/BUILD/kernel-3.10.0-327.3.1.el7/linux-3.10.0-327.3.1.vz7.10.10/drivers/net/ethernet/via
// Edit the Makefile so you get the required kernel module compiled. // In this particular example the via-rhine compiles in-kernel by default, so we need to force it to be built as a module. # sed -ie 's/$(CONFIG_VIA_RHINE)/m/' Makefile
// Build and install the module. # make -C /lib/modules/`uname -r`/build M=$PWD # make -C /lib/modules/`uname -r`/build M=$PWD modules_install
// Check the module has been really copied and load it. # find /lib/modules -name \*rhine\* /lib/modules/3.10.0-327.3.1.vz7.10.10/extra/via-rhine.ko # modprobe via-rhine # lsmod |grep rhine via_rhine 32501 0 mii 13934 1 via_rhine
Here you are!
Note: Your case is a bit more complicated? Read Building External Modules |
Building a kernel module using Dynamic Kernel Module Support (DKMS)
TBD, you are welcome to put the description here. :)
Building a kernel module rpm package (kmod)
TBD, you are welcome to put the description here. :)