[CentOS-devel] Recompiling the Kernel for CentOS 6.5

Fri Mar 28 18:49:01 UTC 2014
Shatil Rafiullah <srafiullah at twopensource.com>

Saket,

Building a kernel via an SRPM is different from building a kernel from
source. The end result from the former process is an RPM or set of
RPMs, whereas the latter just no different from compiling most other
open source projects from source.

Ideally you should be doing this in a Mock environment (building RPMs
with Mock).

If you're looking to rebuild the kernel SRPM with a few modifications,
you'll need to the following:

# Install the build dependencies
yum install bash bzip2 coreutils cpio diffutils epel-release findutils
gawk gcc gcc-c++ grep gzip info make patch redhat-rpm-config rpm-build
rpmdevtools sed shadow-utils tar unzip util-linux-ng which xz
yum-utils

# Install the specific dependencies for your SRPM
yum-builddep /path/to/your.src.rpm

I'd first rebuild the SRPM to make sure it actually works and doesn't
require anything additional (note that this can take forever on slower
machines):

rpmbuild --rebuild /path/to/your.src.rpm

If that works, you'll find in your home directory a directory called
rpmbuild; inside it will be several other directories. Inside the
SOURCES directory, there will be a few config-* files; find the one
that matches your architecture, e.g., x86_64. You can edit that to
provide the appropriate configuration for your kernel.

Afterward, go into the SPECS folder and do this to increment the
release tag to help differentiate your kernel from upstream:

rpmdev-bumpspec -s "s" kernel.spec

Then build your custom kernel:

rpmbuild -ba kernel.spec

Assuming it build without issues result will be several RPMs in the
RPMS directory inside ~/rpmbuild; install the ones you need (either
use yum to install them or rpm -ivh--the kernel itself should never be
installed with -Uvh) and reboot.
Shatil (@shatil)


On Fri, Mar 28, 2014 at 11:03 AM, Akemi Yagi <amyagi at gmail.com> wrote:
> On Fri, Mar 28, 2014 at 10:46 AM, Saket Sinha <saket.sinha89 at gmail.com> wrote:
>> Hi,
>>
>> I am working on CentOS 6.5 which has 2.6.32-431 kernel.
>>
>> I have a problem with my driver and I need to enable Kernel-Memory
>> leak in the kernel for which I will have to recompile the kernel.
>>
>> I get the kernel source tree from the the source rpm for my running
>> kernel from below link-
>>
>> http://vault.centos.org/6.5/updates/Source/SPackages/kernel-2.6.32-431.11.2.el6.src.rpm
>>
>>  and I try to build the kernel according to the below link on CentOS Wiki -
>>
>> http://www.centos.org/docs/rhel-sag-en-3/s1-custom-kernel-modularized.html
>>
>> according to which it tells me , after make menuconfig( and
>> customizing my configuration), I need to follow the following steps-
>>
>> 1.  make bzImage
>> 2.  make modules
>> 3.  make modules_install
>> 4.  make install
>>
>>
>> but I get errors in the first step only-(make bzImage)
>>
>> Kindly suggest me as to what I am doing wrong.
>
> First off, for a question like this, it's best to use the CentOS main
> list (not -devel) or the forums to get assistance.
>
> Second, the doc link you showed is the one written for RHEL-3. The
> correct wiki page to read is:
>
> http://wiki.centos.org/HowTos/Custom_Kernel
>
> Third, you can file a request at bugs.centos.org to enable the option
> in the centosplus kernel. This way, you would do not have to recompile
> your own kernel.
>
> Hope this helps,
>
> Akemi
> _______________________________________________
> CentOS-devel mailing list
> CentOS-devel at centos.org
> http://lists.centos.org/mailman/listinfo/centos-devel