The Linux Kernel: Patches

Discussion in 'Linux Kernel' started by DevynCJohnson, Jan 5, 2014.

  1. DevynCJohnson

    DevynCJohnson Well-Known Member Staff Member Staff Writer

    Messages:
    1,336
    Likes Received:
    1,074
    Trophy Points:
    113
    Series Index - http://www.linux.org/threads/linux-kernel-reading-guide.5384/

    Sometimes, the kernel developers may release a patch for a particular Linux kernel. It helps to know how to apply these patches which will usually fix bugs or enhance performance. Patches can be obtained from "kernel.org". Once a patch is downloaded to your local system, place it in the directory containing the folder of your kernel's source code. Ensure that the kernel and patch are compatible, meaning, they must be the same version. Patches are applied to the uncompressed source code before the kernel is configured.

    To apply a patch, type the following where "PATCH" is the patches file name. Also, use this command while the active directory is the kernel's source code.

    Code:
    patch -p1 < ../PATCH
    If a patch is accidentally applied or the user decides not use a patch, then the patch can be removed/undone in the following manner,

    Code:
    patch -R -p1 < ../PATCH
    The "-R" reverses the patches changes.

    Compressed patches can be applied using one of these commands depending on the compression type. Again, you must be in the directory with the kernel's code.

    Code:
    zcat ../PATCH.gz | patch -p1
    xzcat ../PATCH.xz | patch -p1
    bzcat ../PATCH.bz2 | patch -p1
    However, patches can be applied other ways. Ksplice is an administrator tool that allows users to apply minor security patches to the kernel that is currently running. To apply the security patches, type "uptrack-upgrade -y" in a terminal. "uptrack-show --available" displays available patches and "uptrack-remove --all" removes the patches. Ksplice functions like a package manager. Ksplice searches its repositories for patches and then installs the patches. However, unlike a package manager, Ksplice applies these patches to the kernel in memory. So, if the computer reboots, the updates will not exist.

    Kernel Names

    When using patches, it is important to understand the name of the kernel. For example, kernel v3.12.5 is not the same as v3.12.5-rc2 or v3.12.5-mm. "-rc#" means release candidate. These are kernels that will soon be released after some final testing. "-mm" indicates the kernel is experimental, so such kernels may be unstable and are not suitable for mainstream use. "-git" is found on the daily snapshots of the kernel from GitHub.


    Updating the Kernel

    For those of you that dislike compiling your own kernel or are happy with the configuration of other developers, there are some options for you in getting a newer kernel.

    The number one method of updating the system's kernel is via the package manager. Updating the kernel is just like updating any other software. Open your package manager and refresh the repository list to see the latest updates. If updates exist for your kernel, then select the updates and apply them. If you are using a command-line, then follow the normal procedures for applying updates.


    To Update or not to Update

    If you are unsure about whether an update is worth-while, ask yourself these question -

    Why do I want to upgrade?
    Does my system have a bug that I want fixed?
    Is there some hardware I want supported by my Linux system?
    Do I have hardware that is partially supported?
    What if the update goes wrong?
    What if the update introduces problems or new bugs?
    Would updating improve system security?
    Will the system continue to function well without the update?

    If you need help making a decision, read the changelog to see the changes in the newer version of the kernel. Go to Kernel.org to read the changelogs. Changelogs include detailed information on changes and improvements as well as bug fixes.


    Overall, only perform updates/upgrades on important computers when necessary. When working for a large company (or any company), try to refrain from updating the kernel unless the server is at risk to malware and bugs.

    Attached Files:

    Last edited: May 11, 2014
    Haider92 and Mario Caveda like this.

Share This Page