<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chl</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Chl"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Chl"/>
	<updated>2026-04-11T06:15:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Chl&amp;diff=22583</id>
		<title>User:Chl</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Chl&amp;diff=22583"/>
		<updated>2017-03-22T12:24:17Z</updated>

		<summary type="html">&lt;p&gt;Chl: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Simple OpenVZ &amp;amp; Container enthusiast (hum, that should count as 4-5 words, I need something to fill the &amp;quot;at least 20 words&amp;quot; biography in order to complete my account request. Well... Lorem ipsum dolor sit amet)&lt;/div&gt;</summary>
		<author><name>Chl</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Building_external_kernel_modules&amp;diff=22582</id>
		<title>Building external kernel modules</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Building_external_kernel_modules&amp;diff=22582"/>
		<updated>2017-03-22T12:20:57Z</updated>

		<summary type="html">&lt;p&gt;Chl: /* Building a kernel module using Dynamic Kernel Module Support (DKMS) */ small and simplistic example of using DKMS with Virtuozzo 7.0.1&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Virtuozzo}}&lt;br /&gt;
&lt;br /&gt;
This article describes how to build a kernel module which is not included into the stock Virtuozzo kernel.&amp;lt;br&amp;gt;&lt;br /&gt;
(This article applies to Virtuozzo 7)&lt;br /&gt;
&lt;br /&gt;
== Building a kernel module (*.ko) ==&lt;br /&gt;
&lt;br /&gt;
Here is an example how to build &amp;quot;via-rhine&amp;quot; kernel module which is in the Virtuozzo kernel source tree, but not enabled in kernel config by default.&lt;br /&gt;
&lt;br /&gt;
 // You need to install some dev packages in advance (the list here may be incomplete).&lt;br /&gt;
 '''# yum install rpm-build gcc xmlto asciidoc hmaccalc python-devel newt-devel pesign'''&lt;br /&gt;
&lt;br /&gt;
 // If you are going to build a kernel module against some kernel, you need kernel headers for that kernel.&lt;br /&gt;
 // Assume you want to build a kernel module against currently running kernel.&lt;br /&gt;
 '''# yum install vzkernel-devel.x86_64'''&lt;br /&gt;
&lt;br /&gt;
 // Get sources of the module you'd like to build,&lt;br /&gt;
 // in this particular example the easiest way i believe is just to download the kernel src.rpm.&lt;br /&gt;
 '''# cd /tmp'''&lt;br /&gt;
 '''# wget https://download.openvz.org/virtuozzo/factory/source/SRPMS/v/vzkernel-3.10.0-327.3.1.vz7.10.10.src.rpm'''&lt;br /&gt;
 '''# rpm -ihv vzkernel-3.10.0-327.3.1.vz7.10.10.src.rpm'''&lt;br /&gt;
 &lt;br /&gt;
 // &amp;quot;Prepare&amp;quot; source tree, it's not enough just to take the archive stored in it,&lt;br /&gt;
 // you need to apply additional patch(es), rpmbuild does this for us.&lt;br /&gt;
 '''# rpmbuild -bp /root/rpmbuild/SPECS/kernel.spec --nodeps'''&lt;br /&gt;
&lt;br /&gt;
 // Go to the module source directory.&lt;br /&gt;
 '''# 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'''&lt;br /&gt;
&lt;br /&gt;
 // Edit the Makefile so you get the required kernel module compiled.&lt;br /&gt;
 // In this particular example the via-rhine compiles in-kernel by default, so we need to force it to be built as a module.&lt;br /&gt;
 '''# sed -ie 's/$(CONFIG_VIA_RHINE)/m/' Makefile'''&lt;br /&gt;
&lt;br /&gt;
 // Build and install the module.&lt;br /&gt;
 '''# make -C /lib/modules/`uname -r`/build M=$PWD'''&lt;br /&gt;
 '''# make -C /lib/modules/`uname -r`/build M=$PWD modules_install'''&lt;br /&gt;
&lt;br /&gt;
 // Check the module has been really copied and load it.&lt;br /&gt;
 '''# find /lib/modules -name \*rhine\*'''&lt;br /&gt;
 /lib/modules/3.10.0-327.3.1.vz7.10.10/extra/via-rhine.ko&lt;br /&gt;
 &lt;br /&gt;
 '''# modprobe via-rhine'''&lt;br /&gt;
 '''# lsmod |grep rhine'''&lt;br /&gt;
 via_rhine 32501 0&lt;br /&gt;
 mii 13934 1 via_rhine&lt;br /&gt;
&lt;br /&gt;
Here you are!&lt;br /&gt;
&lt;br /&gt;
{{Note|Your case is a bit more complicated? Read [https://www.kernel.org/doc/Documentation/kbuild/modules.txt Building External Modules]}}&lt;br /&gt;
&lt;br /&gt;
== Building a kernel module using Dynamic Kernel Module Support (DKMS) ==&lt;br /&gt;
(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)&lt;br /&gt;
&lt;br /&gt;
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 : &amp;lt;tt&amp;gt;3c59x.c&amp;lt;/tt&amp;gt; from https://src.openvz.org/projects/OVZ/repos/vzkernel/browse/drivers/net/ethernet/3com (beware of branch and/or tag).&lt;br /&gt;
&lt;br /&gt;
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 :&lt;br /&gt;
 cpp-4.8.5-11.vl7.x86_64&lt;br /&gt;
 dkms-2.3-2.20161202gitde1dca9.vl7.noarch&lt;br /&gt;
 gcc-4.8.5-11.vl7.x86_64&lt;br /&gt;
 U glibc-2.17-157.vl7.2.x86_64&lt;br /&gt;
 U glibc-common-2.17-157.vl7.2.x86_64&lt;br /&gt;
 glibc-devel-2.17-157.vl7.2.x86_64&lt;br /&gt;
 glibc-headers-2.17-157.vl7.2.x86_64&lt;br /&gt;
 U libgcc-4.8.5-11.vl7.x86_64&lt;br /&gt;
 U libgomp-4.8.5-11.vl7.x86_64&lt;br /&gt;
 libmpc-1.0.1-3.vl7.x86_64&lt;br /&gt;
 mpfr-3.1.1-4.vl7.x86_64&lt;br /&gt;
 vzkernel-devel-3.10.0-327.36.1.vz7.18.7.x86_64&lt;br /&gt;
 vzkernel-headers-3.10.0-327.36.1.vz7.18.7.x86_64&lt;br /&gt;
 &lt;br /&gt;
 (U = already present but seems to require an update)&lt;br /&gt;
&lt;br /&gt;
The rest of this doc is heavily inspired from https://wiki.centos.org/HowTos/BuildingKernelModules&lt;br /&gt;
&lt;br /&gt;
Install dkms and vzkernel-devel.&lt;br /&gt;
&lt;br /&gt;
Create a &amp;lt;tt&amp;gt;/usr/src&amp;lt;/tt&amp;gt; subdirectory named like this &amp;lt;tt&amp;gt;modulename-buildversion&amp;lt;/tt&amp;gt; and place your file(s) there :&lt;br /&gt;
 mkdir /usr/src/3c59x-0.1&lt;br /&gt;
 cd /usr/src/3c59x-0.1&lt;br /&gt;
 cp 3c59x.c /usr/src/3c59x-0.1&lt;br /&gt;
 echo &amp;quot;obj-m += 3c59x.o&amp;quot; &amp;gt;/usr/src/3c59x-0.1/Makefile&lt;br /&gt;
&lt;br /&gt;
Create the /usr/src/3c59x-0.1/dkms.conf file :&lt;br /&gt;
 PACKAGE_NAME=&amp;quot;3c59x&amp;quot;&lt;br /&gt;
 PACKAGE_VERSION=&amp;quot;0.1&amp;quot;&lt;br /&gt;
 BUILT_MODULE_NAME[0]=&amp;quot;3c59x&amp;quot;&lt;br /&gt;
 DEST_MODULE_LOCATION[0]=&amp;quot;/kernel/drivers/net/ethernet/3com/&amp;quot;&lt;br /&gt;
 AUTOINSTALL=&amp;quot;yes&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then add dkms support :&lt;br /&gt;
 dkms add -m 3c59x -v 0.1&lt;br /&gt;
 dkms build -m 3c59x -v 0.1&lt;br /&gt;
 dkms install -m 3c59x -v 0.1&lt;br /&gt;
&lt;br /&gt;
For each kernel update, dkms should rebuild the module for you.&lt;br /&gt;
There is an option in dkms to build a RPM and maybe allow to do all that work remotely, but not tested, sorry.&lt;br /&gt;
&lt;br /&gt;
== Building a kernel module rpm package (kmod) ==&lt;br /&gt;
TBD, you are welcome to put the description here. :)&lt;br /&gt;
&lt;br /&gt;
--[[User:Finist|Finist]] ([[User talk:Finist|talk]]) 05:07, 6 February 2016 (EST)&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Kernel]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>Chl</name></author>
		
	</entry>
</feed>