Editing Kernel build
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: | ||
− | |||
− | |||
This FAQ will help you in case you want to apply some patches to the kernel on your own or rebuild it from sources. | 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. | 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. | 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 == | + | == Rebuilding kernel from SRPM == |
− | + | '''Note''': some of the paths below include $TOPDIR, which is distribution-dependent and can be further redefined by user. To find out the proper location on your system, issue this command: | |
− | '''Note''': | ||
− | + | <pre>rpm --eval "%{_topdir}"</pre> | |
− | |||
− | === Download === | + | === 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]]. | 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 === | + | === Installation === |
Install the downloaded SRC RPM with the following command: | Install the downloaded SRC RPM with the following command: | ||
+ | <pre> | ||
+ | # rpm -ihv ovzkernel-2.6.18-028test015.1.src.rpm | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
After successfull installation, you can usually find kernel sources in <code>$TOPDIR/SOURCES/</code> | 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>. | and kernel spec file (<code>kernel-ovz.spec</code>) in <code>$TOPDIR/SPECS</code>. | ||
− | === Adding your own patches === | + | === 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. | 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: | Put your patch into SOURCES directory with the following command: | ||
− | + | <pre> | |
− | |||
# cp <patch> $TOPDIR/SOURCES/ | # cp <patch> $TOPDIR/SOURCES/ | ||
+ | </pre> | ||
− | |||
Then open spec file <code>$TOPDIR/SPECS/kernel-ovz.spec</code> in the editor and add the following lines: | Then open spec file <code>$TOPDIR/SPECS/kernel-ovz.spec</code> in the editor and add the following lines: | ||
− | + | <pre> | |
− | |||
Patch100000: <patch-name> | Patch100000: <patch-name> | ||
− | + | </pre> | |
− | < | ||
and | and | ||
− | + | <pre> | |
− | |||
%patch100000 -p1 | %patch100000 -p1 | ||
− | + | </pre> | |
− | < | ||
in appropriate places where similar text lines are. | in appropriate places where similar text lines are. | ||
− | === Adjust kernel version === | + | === Adjust kernel version === |
Before rebuilding the kernel make sure that you adjusted the kernel version in <code>kernel-ovz.spec</code>. | 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 | 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: | (or from the official OpenVZ kernels). To do so, edit the <code>$TOPDIR/SPECS/kernel-ovz.spec</code> file and replace the following line: | ||
− | + | <pre> | |
− | |||
%define ksubrelease 1 | %define ksubrelease 1 | ||
− | + | </pre> | |
− | < | ||
with something like | with something like | ||
− | + | <pre> | |
− | |||
%define ksubrelease 1my.kernel.v1 | %define ksubrelease 1my.kernel.v1 | ||
+ | </pre> | ||
− | === Modifying configs === | + | === Modifying configs === |
− | If you want to modify the kernel config, you need to do the following before you continue with | + | If you want to modify the kernel config, you need to do the following before you continue with the next step "Building RPMs". |
− | + | <pre> | |
− | |||
# cd $TOPDIR/SPECS | # cd $TOPDIR/SPECS | ||
− | + | # rpmbuild -bp kernel-ovz.spec | |
− | + | # cd $TOPDIR/BUILD/kernel-2.6.18/linux-2.6.18 | |
+ | </pre> | ||
+ | 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-2.6.18/linux-2.6.18/.config</code>. Then you can do a make menuconfig or something similar to adjust the kernel configuration. Afterwards copy | ||
+ | <code>$TOPDIR/BUILD/kernel-2.6.18/linux-2.6.18/.config</code> to the <code>$TOPDIR/SOURCES</code> directory, but use the corresponding file name in the target directory. | ||
+ | Some background information on this procedure can be found in the following thread: http://www.arcknowledge.com/gmane.comp.audio.planetccrma.general/2004-11/msg00018.html | ||
− | + | === Building RPMs === | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === Building RPMs === | ||
To rebuild the kernel, type the following commands: | To rebuild the kernel, type the following commands: | ||
− | + | <pre> | |
− | |||
# cd $TOPDIR/SPECS | # cd $TOPDIR/SPECS | ||
− | + | # rpmbuild -ba --target=i686 kernel-ovz.spec | |
+ | </pre> | ||
− | |||
After successfull kernel compilation binary RPMs can be found at <code>$TOPDIR/RPMS/i686</code>. | After successfull kernel compilation binary RPMs can be found at <code>$TOPDIR/RPMS/i686</code>. | ||
− | == Rebuilding kernel from sources == | + | == Rebuilding kernel from sources == |
− | === Download === | + | === Download === |
To compile OpenVZ linux kernel one need to download the original linux kernel sources and OpenVZ patches for it. | 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. 2.6.18 kernel can be downloaded from [http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.bz2 linux-2.6.18.tar.bz2]. | |
− | Linux kernel can be found at [http://www.kernel.org/ kernel.org], e.g. | ||
− | + | Appropriate OpenVZ patches for this kernel version can be found at http://openvz.org/download/kernel/<version>/patches/. For example, at the moment there is a patch [http://download.openvz.org/kernel/devel/028test015.1/patches/patch-ovz028test015.1-combined.gz patch-ovz028test015.1-combined.gz] available. | |
− | Appropriate OpenVZ patches for this kernel version can be found at | ||
− | + | Kernel configs are also available at OpenVZ download site. Most frequently SMP config is used, so let's download [http://download.openvz.org/kernel/devel/028test015.1/configs/kernel-2.6.18-i686-smp.config.ovz kernel-2.6.18-i686-smp.config.ovz] | |
− | Kernel configs are also available at OpenVZ download site. Most frequently SMP config is used, so let's download [http://download.openvz.org/kernel/ | ||
for this example. | for this example. | ||
− | === | + | === Building === |
First, extract the kernel sources from archive: | First, extract the kernel sources from archive: | ||
+ | <pre> | ||
+ | # tar vjxf linux-2.6.18.tar.bz2 | ||
+ | # cd linux-2.6.18 | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Apply OpenVZ patches to the kernel: | Apply OpenVZ patches to the kernel: | ||
+ | <pre> | ||
+ | # gzip -dc patch-ovz028test015.1-combined.gz | patch -p1 | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
Now we need to place the config and build the kernel: | Now we need to place the config and build the kernel: | ||
+ | <pre> | ||
+ | # cp kernel-2.6.18-i686-smp.config.ovz .config | ||
+ | # make oldconfig | ||
+ | # make | ||
+ | # make modules | ||
+ | </pre> | ||
− | + | === Installation === | |
− | + | After successfull build of kernel it can be installed on the machine with the following commands run under '''root''' user: | |
− | + | <pre> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | === Installation === | ||
− | After | ||
− | |||
− | |||
# make install | # make install | ||
− | + | # make modules_install | |
+ | </pre> | ||
− | |||
Also you need to edit your GRUB or LILO config to make your kernel available for boot. | Also you need to edit your GRUB or LILO config to make your kernel available for boot. | ||
− | |||
− | [[Category: HOWTO]] | + | [[Category:HOWTO]] |
− | [[Category: Kernel | + | [[Category:Kernel]] |
− |