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. | |
− | == Rebuilding kernel from SRPM == | + | == Rebuilding kernel from SRPM == |
− | === | + | === Download === |
− | + | Source RPM for OpenVZ kernel can be download from the official downloads at http://openvz.org/download/kernel/. | |
+ | Beta versions of kernels for different OS distributions can be also found at http://openvz.org/download/beta/. | ||
− | + | === 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.16-026test012.1.src.rpm | ||
+ | </pre> | ||
− | + | After successfull installation you can find kernel sources in /usr/src/<distro>/SOURCES/ | |
− | + | and kernel spec file (kernel-ovz.spec) in /usr/src/<distro>/SPECS, where <distro> is your distribution-specific directory. | |
− | + | For example, for RedHat based distros it is 'redhat', for SUSE it is 'packages'. | |
− | |||
− | After successfull installation | ||
− | and kernel spec file ( | ||
− | === 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 | + | To modify the kernel one needs just to add specific patches to the kernel spec file and put this patch into SOURCES directory. |
− | |||
− | |||
Put your patch into SOURCES directory with the following command: | Put your patch into SOURCES directory with the following command: | ||
+ | <pre> | ||
+ | # cp <patch> /usr/src/<distro>/SOURCES/ | ||
+ | </pre> | ||
− | + | Then open spec file /usr/src/<distro>/SPECS/kernel-ovz.spec in the editor and add the following lines: | |
− | + | <pre> | |
− | + | Patch10000: <patch-name> | |
− | + | </pre> | |
− | Then open spec file < | ||
− | |||
− | |||
− | |||
− | |||
− | < | ||
and | and | ||
− | + | <pre> | |
− | + | %patch10000 -p1 | |
− | % | + | </pre> |
− | |||
− | < | ||
in appropriate places where similar text lines are. | in appropriate places where similar text lines are. | ||
− | === | + | === Building RPMs === |
− | Before rebuilding the kernel make sure that you adjusted the kernel version in | + | Before rebuilding the kernel make sure that you adjusted the kernel version in kernel-ovz.spec. |
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 | + | (or from official OpenVZ kernels). To do so, edit /usr/src/<distro>/SPECS/kernel-ovz.spec file and replace the following line: |
− | + | <pre> | |
− | |||
%define ksubrelease 1 | %define ksubrelease 1 | ||
+ | </pre> | ||
+ | with | ||
+ | <pre> | ||
+ | %define ksubrelease 1-my.kernel.v1 | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | To rebuild the kernel type the following commands then: | |
− | + | <pre> | |
+ | # cd /usr/src/<distro>/SPECS | ||
+ | # rpmbuild -ba --target=i686 kernel-ovz.spec | ||
+ | </pre> | ||
− | + | After successfull kernel compilation binary RPMs can be found at /usr/src/<distro>/RPMS/i686 | |
− | |||
− | |||
− | |||
− | + | == 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/, 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 kernel can be found at | ||
− | + | Appropriate OpenVZ patches for this kernel version can be found at http://openvz.org/download/, e.g. at the moment there is a patch [http://download.openvz.org/beta/kernel/026test012.1/patches/patch-026test012-combined.gz patch-026test012-combined.gz] available. | |
− | Appropriate OpenVZ patches for this kernel version can be found at | + | Kernel configs are also avaialble at OpenVZ download site. Most usually SMP config is used, so lets download [http://download.openvz.org/beta/kernel/026test012.1/configs/kernel-2.6.16-026test012-i686-smp.config.ovz kernel-2.6.16-026test012-i686-smp.config.ovz] |
− | |||
− | |||
− | Kernel configs are also | ||
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.16.tar.bz2 | ||
+ | # cd linux-2.6.16 | ||
+ | </pre> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
Apply OpenVZ patches to the kernel: | Apply OpenVZ patches to the kernel: | ||
+ | <pre> | ||
+ | # gzip -d patch-026test012-combined.gz | ||
+ | # patch -p1 < patch-026test012-combined | ||
+ | </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.16-026test012-i686-smp.config.ovz .config | ||
+ | # make oldconfig | ||
+ | # make | ||
+ | </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 | ||
− | + | </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]] |
− |