• Download kernel from kernel.org & extract tarball.

  • Set up and apply patches.

    mkdir patches
    # put the patch to patches/
    quilt new patches/file.patch
    quilt pop -a && quilt push -a
    
  • Put the config file and and update config.

    • Ubuntu configs.
    cp /boot/config-6.12.12-amd64 .config
    make olddefconfig
    
  • Disable dbgsym compilation.

    scripts/config --disable DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
    scripts/config --disable DEBUG_INFO_DWARF5
    # For old kernels:
    scripts/config --disable DEBUG_INFO
    
  • Disable Canonical certificates.

    scripts/config --set-str SYSTEM_TRUSTED_KEYS ""
    scripts/config --set-str SYSTEM_REVOCATION_KEYS ""
    
  • Compile with ccache.

    PATH=/usr/lib/ccache:${PATH} CCACHE_COMPRESS=true make bindeb-pkg -j$(nproc)