1,433
edits
Changes
Importing a new version from external source
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 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 ==
=== Find out $TOPDIR ===
'''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:
TOPDIR=$(rpm --eval "%{_topdir}"); echo $TOPDIR
=== Download ===
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]].
=== Installation ===
Install the downloaded SRC RPM with the following command:
# rpm -ihv ovzkernel-{{kver}}-{{krel}}.src.rpm
After successfull installation, you can usually find kernel sources in <code>$TOPDIR/SOURCES/</code>
and kernel spec file (<code>kernel-ovz.spec</code>) in <code>$TOPDIR/SPECS</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>$TOPDIR/SOURCES</code> directory.
Put your patch into SOURCES directory with the following command:
# cp <patch> $TOPDIR/SOURCES/
Then open spec file <code>$TOPDIR/SPECS/kernel-ovz.spec</code> in the editor and add the following lines:
Patch100000: <patch-name>
and
%patch100000 -p1
in appropriate places where similar text lines are.
=== Adjust kernel version ===
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>$TOPDIR/SPECS/kernel-ovz.spec</code> file and replace the following line:
%define ksubrelease 1
with something like
%define ksubrelease 1my.kernel.v1
=== Modifying configs ===
If you want to modify the kernel config, you need to do the following before you continue with [[#Building RPMs|the next step]].
# cd $TOPDIR/SPECS
# rpmbuild -bp kernel-ovz.spec
# cd $TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}
'''Note''': Make sure all OpenVZ related options are set. See [[kernel configuration]]
There you will find the configuration files in the subdirectory <code>config/*.config</code>. Copy the one you want to modifiy to <code>$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config</code>. 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]].
Next, copy <code>$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config</code> to the <code>$TOPDIR/SOURCES</code> directory, but use the corresponding file name in the target directory.
=== Building RPMs ===
To rebuild the kernel, type the following commands:
# cd $TOPDIR/SPECS
# rpmbuild -ba --target=i686 kernel-ovz.spec
After successfull kernel compilation binary RPMs can be found at <code>$TOPDIR/RPMS/i686</code>.
== Rebuilding kernel from sources ==
=== Download ===
To compile OpenVZ linux kernel one need to download the original linux kernel sources and OpenVZ patches for it.
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].
Appropriate OpenVZ patches for this kernel version can be found at <nowiki>http://openvz.org/download/kernel/branches/<branch>/<version>/patches/</nowiki>. 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.
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]
for this example.
=== Prepare ===
First, extract the kernel sources from archive:
# tar vjxf linux-{{kver}}.tar.bz2
# cd linux-{{kver}}
Apply OpenVZ patches to the kernel:
# gzip -dc patch-ovz{{krel}}-combined.gz | patch -p1
=== Configure ===
Now we need to place the config and build the kernel:
# cp kernel-{{kver}}-i686-smp.config.ovz .config
# make oldconfig
On this stage, you can modify your kernel configuration to better suit your needs.
{{Note|Make sure all OpenVZ related options are set. See [[kernel configuration]].}}
=== Build ===
# make
# make modules
=== Installation ===
After a successful build of the kernel it can be installed on the machine with the following commands run under '''root''' user:
# make install
# make modules_install
Also you need to edit your GRUB or LILO config to make your kernel available for boot.
[[Category: HOWTO]]
[[Category: Kernel]]
[[Category: Installation]]
On RPM based distros such as RedHat Enterprise Linux/CentOS, Fedora Core or SUSE one can simpy rebuild kernel from SRPM.
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 ==
=== Find out $TOPDIR ===
'''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:
TOPDIR=$(rpm --eval "%{_topdir}"); echo $TOPDIR
=== Download ===
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]].
=== Installation ===
Install the downloaded SRC RPM with the following command:
# rpm -ihv ovzkernel-{{kver}}-{{krel}}.src.rpm
After successfull installation, you can usually find kernel sources in <code>$TOPDIR/SOURCES/</code>
and kernel spec file (<code>kernel-ovz.spec</code>) in <code>$TOPDIR/SPECS</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>$TOPDIR/SOURCES</code> directory.
Put your patch into SOURCES directory with the following command:
# cp <patch> $TOPDIR/SOURCES/
Then open spec file <code>$TOPDIR/SPECS/kernel-ovz.spec</code> in the editor and add the following lines:
Patch100000: <patch-name>
and
%patch100000 -p1
in appropriate places where similar text lines are.
=== Adjust kernel version ===
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>$TOPDIR/SPECS/kernel-ovz.spec</code> file and replace the following line:
%define ksubrelease 1
with something like
%define ksubrelease 1my.kernel.v1
=== Modifying configs ===
If you want to modify the kernel config, you need to do the following before you continue with [[#Building RPMs|the next step]].
# cd $TOPDIR/SPECS
# rpmbuild -bp kernel-ovz.spec
# cd $TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}
'''Note''': Make sure all OpenVZ related options are set. See [[kernel configuration]]
There you will find the configuration files in the subdirectory <code>config/*.config</code>. Copy the one you want to modifiy to <code>$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config</code>. 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]].
Next, copy <code>$TOPDIR/BUILD/kernel-{{kver}}/linux-{{kver}}/.config</code> to the <code>$TOPDIR/SOURCES</code> directory, but use the corresponding file name in the target directory.
=== Building RPMs ===
To rebuild the kernel, type the following commands:
# cd $TOPDIR/SPECS
# rpmbuild -ba --target=i686 kernel-ovz.spec
After successfull kernel compilation binary RPMs can be found at <code>$TOPDIR/RPMS/i686</code>.
== Rebuilding kernel from sources ==
=== Download ===
To compile OpenVZ linux kernel one need to download the original linux kernel sources and OpenVZ patches for it.
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].
Appropriate OpenVZ patches for this kernel version can be found at <nowiki>http://openvz.org/download/kernel/branches/<branch>/<version>/patches/</nowiki>. 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.
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]
for this example.
=== Prepare ===
First, extract the kernel sources from archive:
# tar vjxf linux-{{kver}}.tar.bz2
# cd linux-{{kver}}
Apply OpenVZ patches to the kernel:
# gzip -dc patch-ovz{{krel}}-combined.gz | patch -p1
=== Configure ===
Now we need to place the config and build the kernel:
# cp kernel-{{kver}}-i686-smp.config.ovz .config
# make oldconfig
On this stage, you can modify your kernel configuration to better suit your needs.
{{Note|Make sure all OpenVZ related options are set. See [[kernel configuration]].}}
=== Build ===
# make
# make modules
=== Installation ===
After a successful build of the kernel it can be installed on the machine with the following commands run under '''root''' user:
# make install
# make modules_install
Also you need to edit your GRUB or LILO config to make your kernel available for boot.
[[Category: HOWTO]]
[[Category: Kernel]]
[[Category: Installation]]