<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/index.php?action=history&amp;feed=atom&amp;title=Kernel_build%2Fen</id>
	<title>Kernel build/en - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/index.php?action=history&amp;feed=atom&amp;title=Kernel_build%2Fen"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Kernel_build/en&amp;action=history"/>
	<updated>2026-06-13T18:11:26Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Kernel_build/en&amp;diff=19635&amp;oldid=prev</id>
		<title>FuzzyBot: Importing a new version from external source</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Kernel_build/en&amp;diff=19635&amp;oldid=prev"/>
		<updated>2016-06-05T23:19:35Z</updated>

		<summary type="html">&lt;p&gt;Importing a new version from external source&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This FAQ will help you in case you want to apply some patches to the kernel on your own or rebuild it from sources.&lt;br /&gt;
On RPM based distros such as RedHat Enterprise Linux/CentOS, Fedora Core or SUSE one can simpy rebuild kernel from SRPM.&lt;br /&gt;
For other distros it is required to install sources, build and install kernel manually. The below are given the details for both cases.&lt;br /&gt;
&lt;br /&gt;
== Rebuilding kernel from SRPM ==&lt;br /&gt;
&lt;br /&gt;
=== Find out $TOPDIR ===&lt;br /&gt;
'''Note''': paths in some of the commands below include $TOPDIR, which is distribution-dependent and can be further redefined by user. To find out the proper location of $TOPDIR on your system, issue this command:&lt;br /&gt;
&lt;br /&gt;
 TOPDIR=$(rpm --eval &amp;quot;%{_topdir}&amp;quot;); echo $TOPDIR&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
Source RPMS for different OpenVZ kernel branches can be downloaded from http://openvz.org/download/kernel/. You can also access http://download.openvz.org/kernel/ directly, or use one of the [[download mirrors|mirrors]].&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
Install the downloaded SRC RPM with the following command:&lt;br /&gt;
&lt;br /&gt;
 # rpm -ihv ovzkernel-{{kver}}-{{krel}}.src.rpm&lt;br /&gt;
&lt;br /&gt;
After successfull installation, you can usually find kernel sources in &amp;lt;code&amp;gt;$TOPDIR/SOURCES/&amp;lt;/code&amp;gt;&lt;br /&gt;
and kernel spec file (&amp;lt;code&amp;gt;kernel-ovz.spec&amp;lt;/code&amp;gt;) in &amp;lt;code&amp;gt;$TOPDIR/SPECS&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Adding your own patches ===&lt;br /&gt;
To modify the kernel one needs just to add specific patches to the kernel spec file and put this patch into &amp;lt;code&amp;gt;$TOPDIR/SOURCES&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
Put your patch into SOURCES directory with the following command:&lt;br /&gt;
&lt;br /&gt;
 # cp &amp;lt;patch&amp;gt; $TOPDIR/SOURCES/&lt;br /&gt;
&lt;br /&gt;
Then open spec file &amp;lt;code&amp;gt;$TOPDIR/SPECS/kernel-ovz.spec&amp;lt;/code&amp;gt; in the editor and add the following lines:&lt;br /&gt;
&lt;br /&gt;
 Patch100000: &amp;lt;patch-name&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and&lt;br /&gt;
&lt;br /&gt;
 %patch100000 -p1&lt;br /&gt;
&lt;br /&gt;
in appropriate places where similar text lines are.&lt;br /&gt;
&lt;br /&gt;
=== Adjust kernel version ===&lt;br /&gt;
Before rebuilding the kernel make sure that you adjusted the kernel version in &amp;lt;code&amp;gt;kernel-ovz.spec&amp;lt;/code&amp;gt;.&lt;br /&gt;
This will help you to distinguish binaries then from already existing kernels&lt;br /&gt;
(or from the official OpenVZ kernels). To do so, edit the &amp;lt;code&amp;gt;$TOPDIR/SPECS/kernel-ovz.spec&amp;lt;/code&amp;gt; file and replace the following line:&lt;br /&gt;
&lt;br /&gt;
 %define ksubrelease 1&lt;br /&gt;
&lt;br /&gt;
with something like&lt;br /&gt;
&lt;br /&gt;
 %define ksubrelease 1my.kernel.v1&lt;br /&gt;
&lt;br /&gt;
=== Modifying configs ===&lt;br /&gt;
If you want to modify the kernel config, you need to do the following before you continue with [[#Building RPMs|the next step]].&lt;br /&gt;
&lt;br /&gt;
 # cd $TOPDIR/SPECS&lt;br /&gt;
 # rpmbuild -bp kernel-ovz.spec&lt;br /&gt;
 # cd $TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}&lt;br /&gt;
&lt;br /&gt;
'''Note''': Make sure all OpenVZ related options are set. See [[kernel configuration]]&lt;br /&gt;
&lt;br /&gt;
There you will find the configuration files in the subdirectory &amp;lt;code&amp;gt;config/*.config&amp;lt;/code&amp;gt;. Copy the one you want to modifiy to &amp;lt;code&amp;gt;$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config&amp;lt;/code&amp;gt;. Then you can do a make menuconfig or something similar to adjust the kernel configuration. Note that some kernel configuration issues are described at [[kernel configuration]].&lt;br /&gt;
&lt;br /&gt;
Next, copy &amp;lt;code&amp;gt;$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config&amp;lt;/code&amp;gt; to the &amp;lt;code&amp;gt;$TOPDIR/SOURCES&amp;lt;/code&amp;gt; directory, but use the corresponding file name in the target directory.&lt;br /&gt;
&lt;br /&gt;
=== Building RPMs ===&lt;br /&gt;
To rebuild the kernel, type the following commands:&lt;br /&gt;
&lt;br /&gt;
 # cd $TOPDIR/SPECS&lt;br /&gt;
 # rpmbuild -ba --target=i686 kernel-ovz.spec&lt;br /&gt;
&lt;br /&gt;
After successfull kernel compilation binary RPMs can be found at &amp;lt;code&amp;gt;$TOPDIR/RPMS/i686&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Rebuilding kernel from sources ==&lt;br /&gt;
&lt;br /&gt;
=== Download ===&lt;br /&gt;
To compile OpenVZ linux kernel one need to download the original linux kernel sources and OpenVZ patches for it.&lt;br /&gt;
&lt;br /&gt;
Linux kernel can be found at [http://www.kernel.org/ kernel.org], e.g. {{kver}} kernel can be downloaded [http://www.kernel.org/pub/linux/kernel/v2.6/linux-{{kver}}.tar.bz2 from here].&lt;br /&gt;
&lt;br /&gt;
Appropriate OpenVZ patches for this kernel version can be found at &amp;lt;nowiki&amp;gt;http://openvz.org/download/kernel/branches/&amp;lt;branch&amp;gt;/&amp;lt;version&amp;gt;/patches/&amp;lt;/nowiki&amp;gt;. For example, at the moment there is a patch [http://download.openvz.org/kernel/branches/{{kver}}/{{krel}}/patches/patch-ovz{{krel}}-combined.gz patch-ovz{{krel}}-combined.gz] available.&lt;br /&gt;
&lt;br /&gt;
Kernel configs are also available at OpenVZ download site. Most frequently SMP config is used, so let's download [http://download.openvz.org/kernel/branches/{{kver}}/{{krel}}/configs/kernel-{{kver}}-i686-smp.config.ovz kernel-{{kver}}-i686-smp.config.ovz]&lt;br /&gt;
for this example.&lt;br /&gt;
&lt;br /&gt;
=== Prepare ===&lt;br /&gt;
First, extract the kernel sources from archive:&lt;br /&gt;
&lt;br /&gt;
 # tar vjxf linux-{{kver}}.tar.bz2&lt;br /&gt;
 # cd linux-{{kver}}&lt;br /&gt;
&lt;br /&gt;
Apply OpenVZ patches to the kernel:&lt;br /&gt;
&lt;br /&gt;
 # gzip -dc patch-ovz{{krel}}-combined.gz | patch -p1&lt;br /&gt;
&lt;br /&gt;
=== Configure ===&lt;br /&gt;
Now we need to place the config and build the kernel:&lt;br /&gt;
&lt;br /&gt;
 # cp kernel-{{kver}}-i686-smp.config.ovz .config&lt;br /&gt;
 # make oldconfig&lt;br /&gt;
&lt;br /&gt;
On this stage, you can modify your kernel configuration to better suit your needs. &lt;br /&gt;
&lt;br /&gt;
{{Note|Make sure all OpenVZ related options are set. See [[kernel configuration]].}}&lt;br /&gt;
&lt;br /&gt;
=== Build ===&lt;br /&gt;
 # make&lt;br /&gt;
 # make modules&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
After a successful build of the kernel it can be installed on the machine with the following commands run under '''root''' user:&lt;br /&gt;
&lt;br /&gt;
 # make install&lt;br /&gt;
 # make modules_install&lt;br /&gt;
&lt;br /&gt;
Also you need to edit your GRUB or LILO config to make your kernel available for boot.&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Kernel]]&lt;br /&gt;
[[Category: Installation]]&lt;/div&gt;</summary>
		<author><name>FuzzyBot</name></author>
		
	</entry>
</feed>