Editing Building external kernel modules

Jump to: navigation, search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
{{Virtuozzo}}
+
This article describes how to build an kernel module which is not included into the stock Virtuozzo kernel.<br>
 
 
This article describes how to build a kernel module which is not included into the stock Virtuozzo kernel.<br>
 
 
(This article applies to Virtuozzo 7)
 
(This article applies to Virtuozzo 7)
  
Line 50: Line 48:
  
 
== Building a kernel module using Dynamic Kernel Module Support (DKMS) ==
 
== Building a kernel module using Dynamic Kernel Module Support (DKMS) ==
(draft : this is a small example of adding back the support of an old network card just after the installation of Virtuozzo 7.0.1 on a bare metal server)
+
TBD, you are welcome to put the description here. :)
 
 
First, you need to figure out which kernel source files are needed to build your modules. Here, what we needed wasn't in the source package https://download.openvz.org/virtuozzo/releases/openvz-7.0.1-554/source/SRPMS/v/vzkernel-3.10.0-327.36.1.vz7.18.7.src.rpm but we were lucky and needed only one file : <tt>3c59x.c</tt> from https://src.openvz.org/projects/OVZ/repos/vzkernel/browse/drivers/net/ethernet/3com (beware of branch and/or tag).
 
 
 
Note : if network is unavailable on the target host, download these packets (lookup /etc/yum.repos.d/ for the EPEL and Virtuozzo URL). Adapt the version numbers to your release :
 
cpp-4.8.5-11.vl7.x86_64
 
dkms-2.3-2.20161202gitde1dca9.vl7.noarch
 
gcc-4.8.5-11.vl7.x86_64
 
U glibc-2.17-157.vl7.2.x86_64
 
U glibc-common-2.17-157.vl7.2.x86_64
 
glibc-devel-2.17-157.vl7.2.x86_64
 
glibc-headers-2.17-157.vl7.2.x86_64
 
U libgcc-4.8.5-11.vl7.x86_64
 
U libgomp-4.8.5-11.vl7.x86_64
 
libmpc-1.0.1-3.vl7.x86_64
 
mpfr-3.1.1-4.vl7.x86_64
 
vzkernel-devel-3.10.0-327.36.1.vz7.18.7.x86_64
 
vzkernel-headers-3.10.0-327.36.1.vz7.18.7.x86_64
 
 
(U = already present but seems to require an update)
 
 
 
The rest of this doc is heavily inspired from https://wiki.centos.org/HowTos/BuildingKernelModules
 
 
 
Install dkms and vzkernel-devel.
 
 
 
Create a <tt>/usr/src</tt> subdirectory named like this <tt>modulename-buildversion</tt> and place your file(s) there :
 
mkdir /usr/src/3c59x-0.1
 
cd /usr/src/3c59x-0.1
 
cp 3c59x.c /usr/src/3c59x-0.1
 
echo "obj-m += 3c59x.o" >/usr/src/3c59x-0.1/Makefile
 
 
 
Create the /usr/src/3c59x-0.1/dkms.conf file :
 
PACKAGE_NAME="3c59x"
 
PACKAGE_VERSION="0.1"
 
BUILT_MODULE_NAME[0]="3c59x"
 
DEST_MODULE_LOCATION[0]="/kernel/drivers/net/ethernet/3com/"
 
AUTOINSTALL="yes"
 
 
 
Then add dkms support :
 
dkms add -m 3c59x -v 0.1
 
dkms build -m 3c59x -v 0.1
 
dkms install -m 3c59x -v 0.1
 
 
 
For each kernel update, dkms should rebuild the module for you.
 
There is an option in dkms to build a RPM and maybe allow to do all that work remotely, but not tested, sorry.
 
  
 
== Building a kernel module rpm package (kmod) ==
 
== Building a kernel module rpm package (kmod) ==

Please note that all contributions to OpenVZ Virtuozzo Containers Wiki may be edited, altered, or removed by other contributors. If you don't want your writing to be edited mercilessly, then don't submit it here.
If you are going to add external links to an article, read the External links policy first!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)

Templates used on this page: