LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
Search this Thread
Old 06-13-2009, 02:46 PM   #1
jhyland87
LQ Newbie
 
Registered: Dec 2008
Posts: 25

Rep: Reputation: 15
Patching a kernel?


Hey guys, so I am running a RHEL 4 server, with a cPanel install.

Current kernel:
Quote:
root@svr1 [~]# uname -a
Linux svr1.#########.com 2.6.9-78.0.8.ELsmp #1 SMP Wed Nov 5 07:10:44 EST 2008 i686 i686 i386 GNU/Linux
I have been working with linux for less than a year, but im a quick learner, I have learned everything hands on, my desktop is ubuntu, my server is RedHat, and I work for Crystaltech, so I use centOS every day as well.

Though I have been using linux for a year, I don't know if I know enough to patcha kernel. I would like to test it on a different server. Because I dont have a RHEL4 server with cPanel laying around, ill buy one from ThePlanet for a month, and test it on that, I dont want to test it on a production server... I want to patch the kernel, 1 reboot, bam.. its done.

Down to the question.... How in the world do I patch a kernel? I am willing to pay someone if they know what they are doing, and feel they can teach me...

Here is exactly what im trying to do: http://www.mattheaton.com/?p=188

If anyone has any input that may help the situation that would be great..

Thanks!
 
Old 06-13-2009, 04:04 PM   #2
hasienda
Member
 
Registered: May 2009
Location: Saxony, Germany
Distribution: Debian/GNU Linux
Posts: 36

Rep: Reputation: 18
What patch does

Quote:
Originally Posted by jhyland87 View Post
[...] Though I have been using linux for a year, I don't know if I know enough to patcha kernel. I would like to test it on a different server. Because I dont have a RHEL4 server with cPanel laying around, ill buy one from ThePlanet for a month, and test it on that, I dont want to test it on a production server... I want to patch the kernel, 1 reboot, bam.. its done.
Bad things may happen, if you change a running system. Bad things _will_ happen (and you'll have to pay for it), if you can't recover the system on your own (sort of Murphy's law). I'd only test on a system I could switch off and reboot, swap hard disk, boot with live (rescue) OS from CD or DVD. A root server for rent seems not ideally in this respect as long as you don't work or have relatives in the data center of the hosting company.

Quote:
Originally Posted by jhyland87 View Post
Down to the question.... How in the world do I patch a kernel? I am willing to pay someone if they know what they are doing, and feel they can teach me...

Here is exactly what im trying to do: [snip]
You sound like you're expecting to learn magic here. :-)

However patch is a simple tool in the Unix tradition doing only one thing, but doing it well. This one thing is changing (text) files in a well defined way - defined by a patch file.

You may want to see a patch file as a kind of receipt. I tells patch
a) what file to take
b) where to start inside of that file
c) how many rows to delete
d) what to add there in exchange or somewhere else
A patch may hold information for just one little change in one file as well as a series of changes to multiple files across the several directories.

You know diff, yet another little tool? Well that one is able to create such patch files by reporting the differences between two files or directories.

Now, patching the Linux kernel means you're working on the source code (text) files modifying one/some of them before compiling a new kernel. From opening and reading a patch file in the editor of your choice you'll learn what is the base directory (i.e. / or /usr/src/linux-source_xxx/) you'll need to jump to before trying to apply a patch (file).

In general, please read man pages, to get familiar with a tools command line options. For patch I'd recommend to read some patch files and create some on your own with diff before using the patch tool. Always include the '--dry-run' option in patch calls to investigate, what patch is about to do to your systems data. Be suspicious. Try to not use it as root or nothing will save you from modifying important data within a second.

One more word about replacing the systems kernel: It's vital to have a fall-back strategy in case something is going nasty with the new kernel. The boot loader of your choice should be configured to boot the new or the old kernel, ideally at first the new one, in case of failure or simply the next time the old kernel again. I.e. while LILO is quite limited in this respect GRUB does all this and even let you change arguments on the fly in case you have a mistake in the configuration that you don't notice before the reboot. And build a kernel from clean, unpached sources before building from patched ones.
 
Old 06-13-2009, 05:49 PM   #3
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,103

Rep: Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982Reputation: 982
Patching is trivial - there is a document under ../Documentation in the source tree that explains it pretty well.
It's when something doesn't fit that things get interesting. Also making it work with the specific distro packaging mentality is sometimes awkward.
I'm sure RH will have a doco somewhere on how to patch their (modified) kernels.
 
Old 06-13-2009, 06:05 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,988
Blog Entries: 54

Rep: Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743Reputation: 2743
RH I don't know about but here's How To Compile A Kernel - The CentOS Way (HowtoForge).

@jhyland87: Offering rewards should never be necessary. And you won't learn from it like you would from doing it yourself. If you don't have a spare machine, see if virtualization (VMware, QEmu, Xen, Virtualbox) is more efficient and cost-effective than sinking time and money into one-offs like renting a server.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error while patching RTLinux 2.6.9 kernel using kernel linux-2.6.9 krishna_karne Linux - Software 1 11-16-2007 10:36 PM
patching Debian Stock Kernel with prepatch from kernel.org kushalkoolwal Debian 10 08-25-2007 01:05 PM
powerpc: kernel patching... but which kernel source? parent's_basement Ubuntu 2 01-15-2007 01:46 PM
error while patching Rtlinux 3.1 kernel using kernel linux-2.4.29 dolreich_c Linux - General 0 08-10-2006 03:33 AM
Patching a 2.6 kernel with a 2.4 kernel keyboard driver..possible? dxx Linux - Laptop and Netbook 3 11-18-2004 04:18 AM


All times are GMT -5. The time now is 12:47 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration