<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl" -->

---
title: Quick hack: Patching kernel modules using DKMS | daily.dev
description: DKMS (Dynamic Kernel Module Support) can be used not just to build external kernel modules, but also to patch existing kernel modules. This walkthrough...
canonical: https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Quick hack: Patching kernel modules using DKMS | daily.dev
og:description: DKMS (Dynamic Kernel Module Support) can be used not just to build external kernel modules, but also to patch existing kernel modules. This walkthrough...
og:url: https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl
og:image: https://api.daily.dev/og/posts/2gMM3bkCL.png
og:image:alt: Quick hack: Patching kernel modules using DKMS
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Quick hack: Patching kernel modules using DKMS

**[Collabora Blog](https://daily.dev/sources/collabora)** · 6 min read · 0 upvotes · 0 comments

## Summary

DKMS (Dynamic Kernel Module Support) can be used not just to build external kernel modules, but also to patch existing kernel modules. This walkthrough demonstrates the technique by applying a Bluetooth USB fix (for kernels 5.8–5.10.17) that enables mSBC codec support with non-Intel USB Bluetooth chipsets. The guide covers creating the DKMS config directory, writing a dkms.conf, downloading and tweaking the upstream kernel patch, and writing a dkms-patchmodule.sh script that downloads the kernel source, extracts the relevant module, bumps the module version, and applies the patch — all so users on non-LTS kernels like Ubuntu 20.04 with kernel 5.8 can benefit from fixes already backported to LTS kernels.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.collabora.com/news-and-blog/blog/2021/05/05/quick-hack-patching-kernel-module-using-dkms>

## Questions this post answers

### How do I apply a kernel patch to an existing module without recompiling the whole kernel using DKMS?

Create a directory at /usr/src/<module>-<version>, add a dkms.conf specifying PACKAGE_NAME, PACKAGE_VERSION, BUILT_MODULE_NAME, DEST_MODULE_LOCATION, AUTOINSTALL, REMAKE_INITRD, and a PRE_BUILD script. The PRE_BUILD script downloads the upstream kernel source tarball, extracts only the relevant driver directory, bumps the module version string (so DKMS's sanity check allows replacement), applies the patch, then run sudo dkms install <module>/<version>.

_Developers maintaining Linux systems on non-LTS kernels track fixes like these on daily.dev._

### Why does DKMS refuse to replace an already-installed kernel module with my newly built one?

DKMS performs a module version sanity check and will not replace a module if the built version is not greater than the installed one. The fix is to increment the version string inside the module source before building — for example, using sed to bump the #define VERSION string in the .c file — so the new build is recognized as a newer version.

_Engineers patching kernel modules for production systems find relevant Linux internals coverage on daily.dev._

## Similar posts on daily.dev

- [Linux Fu: The Bluetooth Regression](https://daily.dev/posts/linux-fu-the-bluetooth-regression-fhotrbnxb) · Hackaday · 1 upvotes · 0 comments
- [Linux 7.3 Lands More Audio Workarounds For Laptops & Other Devices](https://daily.dev/posts/linux-7-3-lands-more-audio-workarounds-for-laptops-other-devices-dwf0hnack) · Phoronix · 0 upvotes · 0 comments
- [How to Write a Linux Kernel Module That Actually Builds](https://daily.dev/posts/how-to-write-a-linux-kernel-module-that-actually-builds-zoyt3jduk) · freeCodeCamp · 0 upvotes · 0 comments
- [My First Contribution to Linux](https://daily.dev/posts/my-first-contribution-to-linux-zsqhvkia5) · Lobsters · 2 upvotes · 0 comments
- [Linux 6.19 Merges "klp-build" As New Livepatch Module Generation Solution](https://daily.dev/posts/linux-6-19-merges-klp-build-as-new-livepatch-module-generation-solution-qdjqvvznq) · Phoronix · 0 upvotes · 0 comments

---

Tags: [#linux](https://daily.dev/tags/linux), [#ubuntu](https://daily.dev/tags/ubuntu), [#bluetooth](https://daily.dev/tags/bluetooth)

[View this post on daily.dev](https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Quick hack: Patching kernel modules using DKMS","url":"https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl"},"datePublished":"2026-08-11T08:53:32.177Z","dateModified":"2026-08-11T09:11:59.985Z","description":"DKMS (Dynamic Kernel Module Support) can be used not just to build external kernel modules, but also to patch existing kernel modules. This walkthrough...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7cc8a346799dbfea4aca8141012f5c05?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/7cc8a346799dbfea4aca8141012f5c05?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Collabora Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Collabora Blog","logo":"https://media.daily.dev/image/upload/s--ZGZ0FjqS--/f_auto,q_auto/v1786438306/logos/collabora?_a=BAMAMicg0","url":"https://daily.dev/sources/collabora"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"linux,ubuntu,bluetooth","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Collabora Blog","item":"https://daily.dev/sources/collabora"},{"@type":"ListItem","position":3,"name":"Quick hack: Patching kernel modules using DKMS"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/quick-hack-patching-kernel-modules-using-dkms-2gmm3bkcl#faq","mainEntity":[{"@type":"Question","name":"How do I apply a kernel patch to an existing module without recompiling the whole kernel using DKMS?","acceptedAnswer":{"@type":"Answer","text":"Create a directory at /usr/src/<module>-<version>, add a dkms.conf specifying PACKAGE_NAME, PACKAGE_VERSION, BUILT_MODULE_NAME, DEST_MODULE_LOCATION, AUTOINSTALL, REMAKE_INITRD, and a PRE_BUILD script. The PRE_BUILD script downloads the upstream kernel source tarball, extracts only the relevant driver directory, bumps the module version string (so DKMS's sanity check allows replacement), applies the patch, then run sudo dkms install <module>/<version>. Developers maintaining Linux systems on non-LTS kernels track fixes like these on daily.dev."}},{"@type":"Question","name":"Why does DKMS refuse to replace an already-installed kernel module with my newly built one?","acceptedAnswer":{"@type":"Answer","text":"DKMS performs a module version sanity check and will not replace a module if the built version is not greater than the installed one. The fix is to increment the version string inside the module source before building — for example, using sed to bump the #define VERSION string in the .c file — so the new build is recognized as a newer version. Engineers patching kernel modules for production systems find relevant Linux internals coverage on daily.dev."}}]}
```

