6,534
edits
Changes
Fixed kernel download URLs, added <code> tag pairs, some rewording
This FAQ will help you in case you want to apply some patches to the kernel on your own or rebuild it from sources.
On RPM based distros such as RedHat Enterprise Linux/CentOS, Fedora Core or SUSE one can simpy rebuild kernel from SRPM,.for For other distros it is required to install sources, build and install kernel manually. The below are given the details for both cases.
== Rebuilding kernel from SRPM ==
=== Download ===
Source RPM RPMS for different OpenVZ kernel branches can be download downloaded from the official downloads at http://openvz.org/download/kernel/.Beta versions of kernels for different OS distributions You can be also found at access http://download.openvz.org/kernel/ directly, or use one of the [[download/beta/mirrors|mirrors]].
=== Installation ===
Install the downloaded SRC RPM with the following command:
<pre>
# rpm -ihv ovzkernel-2.6.16-026test012026test014.14.src.rpm
</pre>
After successfull installation , you can usually find kernel sources in <code>/usr/src/<distro>/SOURCES/</code>and kernel spec file (<code>kernel-ovz.spec</code>) in <code>/usr/src/<distro>/SPECS</code>, where <code><distro></code> is your distribution-specific directory.For example, for RedHat Red Hat based distros it is '<code>redhat'</code>, for SUSE it is '<code>packages'</code>.
=== Adding your own patches ===
To modify the kernel one needs just to add specific patches to the kernel spec file and put this patch into <code>SOURCES </code> directory.
Put your patch into SOURCES directory with the following command:
<pre>
</pre>
Then open spec file <code>/usr/src/<distro>/SPECS/kernel-ovz.spec </code> in the editor and add the following lines:
<pre>
Patch10000: <patch-name>
=== Building RPMs ===
Before rebuilding the kernel make sure that you adjusted the kernel version in <code>kernel-ovz.spec</code>.
This will help you to distinguish binaries then from already existing kernels
(or from the official OpenVZ kernels). To do so, edit the <code>/usr/src/<distro>/SPECS/kernel-ovz.spec </code> file and replace the following line:
<pre>
%define ksubrelease 1
</pre>
withsomething like
<pre>
%define ksubrelease 1-my.kernel.v1
To rebuild the kernel , type the following commands then:
<pre>
# cd /usr/src/<distro>/SPECS
</pre>
After successfull kernel compilation binary RPMs can be found at <code>/usr/src/<distro>/RPMS/i686</code>.
== Rebuilding kernel from sources ==
Linux kernel can be found at [http://www.kernel.org/ kernel.org], e.g. 2.6.16 kernel can be downloaded from [http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.16.tar.bz2 linux-2.6.16.tar.bz2].
Appropriate OpenVZ patches for this kernel version can be found at http://openvz.org/download/kernel/. For example, e.g. at the moment there is a patch [http://download.openvz.org/beta/kernel/026test012026test014.14/patches/patch-026test012026test014-combined.gz patch-026test012026test014-combined.gz] available.
Kernel configs are also available at OpenVZ download site. Most usually frequently SMP config is used, so let's download [http://download.openvz.org/beta/kernel/026test012026test014.14/configs/kernel-2.6.16-026test012026test014-i686-smp.config.ovz kernel-2.6.16-026test012026test014-i686-smp.config.ovz]
for this example.
Apply OpenVZ patches to the kernel:
<pre>
# gzip -dc patch-026test012026test014-combined.gz | patch -p1
</pre>
Now we need to place the config and build the kernel:
<pre>
# cp kernel-2.6.16-026test012026test014-i686-smp.config.ovz .config
# make oldconfig
# make