PatchKernel
Info
Patch the kernel
- Mainly to include new hardware drivers (eg 3ware controller)
- prepare
- download kernel source rpms and install them
- then (maybe check also if there are no different versions of the kernel source on the machine, so you are sure this spec file is the one you need!)
cd /usr/src/redhat/SPECS cp kernel-2.6.spec kernel-2.6.spec-orig rpmbuild -bp kernel-2.6.spec
- now you have the OS patched kernel in
/usr/src/redhat/BUILD/
- patch
- 3ware
- get the drivers you need for your kernel release
- untar files
- make a copy of the kernel tree
cd /usr/src/redhat/BUILD/kernel-<version> cp -R linux-<version> linux2-<version>
- copy the new 3w-9xxx.c and 3w-9xxx.h files to /usr/src/redhat/BUILD/kernel-<version>/linux2-<version>/drivers/scsi
- goto /usr/src/redhat/BUILD/kernel-<version> and make the patch with (the order is diff old new
diff -ur linux-<version> linux2-<version> > 3w-<driver version>-<kernel version>.patch
- copy the 3ware patch file to /usr/src/redhat/SOURCES
- goto /usr/src/redhat/SPECS and open the kernel-2.6.spec file
- you need to change the name of the kernel by modifying some version number
- for centos plus kernels, you can add your own identfer to the %define dist field.
- locate the last patch in the spec file. Look for the last line which starts with Patch<digits>: <some filename>
- create a new Patch entry pointing to the 3w patch file you made. the path is relative to /usr/src/redhat/SOURCE
- don't use any of the Patch999XX ranges, use something lower.
- locate the equivalent last %patch<digits> entry and insert your new patch %patch<the patchnumber you choose> -p1
- as an example, for centos 5.1 x86_64, the changes were
[root@fireman SPECS]# diff -u kernel-2.6.spec-orig kernel-2.6.spec --- kernel-2.6.spec-orig 2008-01-17 12:20:42.000000000 +0100 +++ kernel-2.6.spec 2008-01-17 12:48:06.000000000 +0100 @@ -49,7 +49,7 @@ # After branching, please hardcode these values as the # %dist and %rhel tags are not reliable yet # For example dist -> .el5 and rhel -> 5 -%define dist .el5.centos.plus +%define dist .el5.centos.plus.iihe %define rhel 5 # Values used for RHEL version info in version.h @@ -1601,6 +1601,8 @@ Patch21841: linux-2.6-ppc-system-cpus-stuck-in-h_join-after-migrating.patch Patch21842: linux-2.6-fs-missing-dput-in-do_lookup-error-leaks-dentries.patch Patch21843: linux-2.6-net-tg3-fix-performance-regression-on-5705.patch + +Patch30000: 3w-9.5.0-2.6.18.patch # adds rhel version info to version.h Patch99990: linux-2.6-rhel-version-h.patch # empty final patch file to facilitate testing of kernel patches @@ -3191,6 +3193,8 @@ %patch21841 -p1 %patch21842 -p1 %patch21843 -p1 +%patch30000 -p1 + # correction of SUBLEVEL/EXTRAVERSION in top-level source tree Makefile # patch the Makefile to include rhel version info %patch99990 -p1
- you are now ready to rebuild the kernel rpms
- to build all releases, run
rpmbuild -bb kernel-2.6.spec >& out
- this might take a while, you can later check the output file if your patch didn't cause any issues during the build.
- you can follow the state with
- this might take a while, you can later check the output file if your patch didn't cause any issues during the build.
tail -f out
- be aware of the following message (it can stop/delay the process).
Not enough random bytes available. Please do some other work to give the OS a chance to collect more entropy!
Post config
- since you build a new kernel release, it might be necessary to rebuild depending kernel modules, like XFS
- install the devel-rpms from your new kernel
- use rpm -i to keep the current kernel rpms on the box.
- get and install the source rpms for your modules
- goto /usr/src/redhat/SPECS and run
rpmbuild --define "kversion <the complete new kernel version>" module.spec
- eg for centos 5.1 example above with the XFS module
rpmbuild -bb --define "kversion 2.6.18-53.1.4.el5.centos.plus.iihe" kmod-xfs.spec