# How do I patch the kernel?

## shgadwa

I have several moblin patches which are supposed to greatly reduce boot time... how can I apply them to a zen-sources 2.6.32-zen3 kernel?

----------

## drescherjm

The problem with patches is there is a high likelyhood of a failed patch if the code that you are patching was updated since whatever kernel the patch was generated from. With that said the simplest way to test is.

```
cd /usr/src/linux

patch -p0 < somepatchfile.patch

```

You may have to adjust the p# or cd further into the kernel source for this to work.

----------

## shgadwa

Oh wow! Its that easy?

Anyhow, can I copy /usr/src/linux-2.6.32-zen3 to something like /usr/src/linux-2.6.32-zen3.backup and then boot off that if the patch goes bad?

----------

## drescherjm

Yes you can copy the source/ build tree. However for the boot one would overwrite the other when you install since they have the same version. To get around this Go to general setup and then enable "Automatically append version information to the version string" and then put a string in the local version box then build and install the kernel.

----------

## shgadwa

I tried to patch the kernel, and I got this:

```
atlantis linux-2.6.32-zen3 # patch -p0 < /home/shawn/kernel_fastboot/0001-moblin-add-a-EDID-cache.patch

can't find file to patch at input line 17

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:

--------------------------

|From 74e4754af37ca4d942bfed51abb67dee64dd2eec Mon Sep 17 00:00:00 2001

|From: Andy Whitcroft <apw@canonical.com>

|Date: Fri, 6 Nov 2009 14:16:42 +0000

|Subject: [PATCH 1/8] moblin: add a EDID cache

|

|Signed-off-by: Andy Whitcroft <apw@canonical.com>

|---

| drivers/gpu/drm/i915/intel_drv.h   |    1 +

| drivers/gpu/drm/i915/intel_lvds.c  |    2 ++

| drivers/gpu/drm/i915/intel_modes.c |    9 ++++++++-

| 3 files changed, 11 insertions(+), 1 deletions(-)

|

|diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h

|index 26a6227..7a6ea50 100644

|--- a/drivers/gpu/drm/i915/intel_drv.h

|+++ b/drivers/gpu/drm/i915/intel_drv.h

--------------------------

File to patch: 

```

Any ideas?

----------

## drescherjm

try 

```
patch -p1 < /home/shawn/kernel_fastboot/0001-moblin-add-a-EDID-cache.patch 
```

----------

## shgadwa

Ok thanks a lot... that worked.

----------

## drescherjm

BTW, I got that from the following in your output:

--- a/drivers/gpu/drm/i915/intel_drv.h

+++ b/drivers/gpu/drm/i915/intel_drv.h 

From this I see that if you are in /usr/src/linux you need to chop off 1 level to get the patch to know to patch

drivers/gpu/drm/i915/intel_drv.h

----------

