LWM-Linux/11 - Linux Kernel and Modules/Kernel Upgrades and Patching.md

1.3 KiB

Kernel Upgrades and Patching

1. Preparation:

  • Backup your system
  • Ensure you have enough disk space
  • Install necessary tools:
    sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
    

2. Download the kernel source:

  • Visit kernel.org
  • Download the desired version (e.g., linux-5.x.y.tar.xz)
  • Extract the archive:
    tar xvf linux-5.x.y.tar.xz
    cd linux-5.x.y
    

3. Apply patches (if needed):

  • Download the patch file
  • Apply the patch:
    patch -p1 < /path/to/patch/file
    

4. Configure the kernel:

  • Copy your current config:
    cp /boot/config-$(uname -r) .config
    
  • Make necessary changes:
    make menuconfig
    
  • Update the config for the new version:
    make oldconfig
    

5. Build the kernel:

make -j$(nproc)

6. Build and install modules:

sudo make modules_install

7. Install the kernel:

sudo make install

8. Update boot loader (e.g., GRUB):

sudo update-grub

9. Reboot and select the new kernel

10. Verify the new kernel:

uname -r