wiki/linux.modules-with-dkms.html

32 lines
11 KiB
HTML
Raw Normal View History

2022-07-29 15:41:17 +00:00
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Installing Linux kernel modules with DKMS</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
MathJax = {
tex: {
inlineMath: [ [&#x27;$&#x27;,&#x27;$&#x27;], [&#x27;\(&#x27;,&#x27;\)&#x27;] ],
displayMath: [ [&#x27;$$&#x27;,&#x27;$$&#x27;], [&#x27;[&#x27;,&#x27;]&#x27;] ]
},
options = {
processHtmlClass = &quot;math&quot;
}
}
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Installing Linux kernel modules with DKMS</h1><section class="post-metadata"><span>Date: <!-- -->2021-05-30 17:40:35 +08:00</span><span>Date modified: <!-- -->2021-07-22 18:07:36 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"></ol></nav><p><a href="https://github.com/dell/dkms">Dynamic kernel module support</a> (DKMS) is a feature that allows installation of kernel modules while reinstalling the kernel.
This is preferable if you don&#x27;t want to build and install kernel modules every kernel update.
</p><p>Oftentimes to build the kernel module, it is required to install Linux-related headers.
</p><p>Here&#x27;s an example scenario where I want to install <a href="https://github.com/jlam55555/veikk-linux-driver/issues/43">Veikk tablet driver</a> that is not available out-of-the-box.
The following list is the summarized version of what should happen.
</p><ul><li><p>Download the source code of the kernel module.
</p></li><li><p>Check if the Linux headers are available otherwise the kernel module cannot be built.
</p></li><li><p>Place the kernel module source into the kernel source tree (e.g., <code class="inline-verbatim">/usr/src</code>).
</p></li><li><p>Create <code class="inline-verbatim">dkms.conf</code> to tell where the module is to be built.
</p></li><li><p>Install the module with <code class="inline-code">dkms</code>.
</p></li></ul><p>The most difficult out of the steps is configuring with <code class="inline-verbatim">dkms.conf</code>.
You can see the format and the available options from <code class="inline-verbatim">dkms.8</code> manual page.
For now, let&#x27;s see the example configuration.
</p><pre class="src-block"><code class="language-shell">PACKAGE_NAME=&quot;input-veikk&quot;
PACKAGE_VERSION=&quot;git&quot;
BUILT_MODULE_NAME[0]=&quot;veikk&quot; # (ref:module-name)
DEST_MODULE_LOCATION[0]=&quot;/extra/&quot;
AUTOINSTALL=&quot;yes&quot;
</code></pre><p>This tells <code class="inline-code">dkms</code> to install the Veikk driver, packaged as <code class="inline-verbatim">input-veikk</code> with version <code class="inline-verbatim">git</code>, in <code class="inline-verbatim">extra/</code> (e.g., <code class="inline-verbatim">/lib/modules/@LINUX_KERNEL_VERSION@/extra</code>).
When installed, you should see a module named <a href="/wiki/(module-name)"><code class="inline-verbatim">veikk</code></a> — e.g., see the module list with <code class="inline-verbatim">lsmod</code>.
</p><p>With the setup complete, run <code class="inline-code">dkms install -m input-veikk -v git</code> and it should be effective immediately.
</p></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"\"2021-05-30 17:40:35 +08:00\"","date_modified":"\"2021-07-22 18:07:36 +08:00\"","language":"en","source":""},"title":"Installing Linux kernel modules with DKMS","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"element","tagName":"a","properties":{"href":"https://github.com/dell/dkms"},"children":[{"type":"text","value":"Dynamic kernel module support"}]},{"type":"text","value":" (DKMS) is a feature that allows installation of kernel modules while reinstalling the kernel.\nThis is preferable if you don't want to build and install kernel modules every kernel update.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Oftentimes to build the kernel module, it is required to install Linux-related headers.\n"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Here's an example scenario where I want to install "},{"type":"element","tagName":"a","properties":{"href":"https://github.com/jlam55555/veikk-linux-driver/issues/43"},"children":[{"type":"text","value":"Veikk tablet driver"}]},{"type":"text","value":" that is not available out-of-the-box.\nThe following list is the summarized version of what should happen.\n"}]},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Download the source code of the kernel module.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Check if the Linux headers are available otherwise the kernel module cannot be built.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Place the kernel module source into the kernel source tree (e.g., "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"/usr/src"}]},{"type":"text","value":").\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Create "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"dkms.conf"}]},{"type":"text","value":" to tell where the module is to be built.\n"}]}]},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Install the module with "},{"type":"element","tagName":"code","properties":{"className":["inline-code"]},"children":[{"type":"text","value":"dkms"}]},{"type":"text","value":".\n"}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The most difficult out of the steps is configuring with "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"dkms.conf"}]},{"type":"text","value":".\nYou can see the format and the available options from "},{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"dkms.8"}]},{"type":"text","value":" manual page.\nFor now, let's see the example configuration.\n"}]},{"type":"element","tagName":"pre","properties":{"className":["src-block"]},"children":[{"type":"element","tagName":"code","properties":{"className":["language-shell"]},"children":[{"type":"text","value":"PACKAGE_NAME=\"input-veikk\"\nPACKAGE_VERSION=\"git\"\nBUILT_MODULE_NAME[0]=\"veikk\" # (ref:module-name)\nDEST_MODULE_LOCATION[0]=\"/extra/\"\nAUTOINSTALL=\"yes\"\n"}]}]},{"type":"element",