@@ -24,6 +24,8 @@ This is especially useful if your kmod image contains several kernel modules and
2424another.
2525To generate dependencies and map files for a specific kernel version, run ` depmod -b /opt ${KERNEL_FULL_VERSION} ` .
2626
27+ If you use a multi-stage Dockerfile, run ` depmod ` at the end of the last stage.
28+
2729## Example ` Dockerfile `
2830
2931The example below builds a test kernel module from the KMM repository.
@@ -172,16 +174,15 @@ RUN depmod -b /opt ${KERNEL_FULL_VERSION}
172174# ## Depending on in-tree kernel modules
173175
174176Some kernel modules depend on other kernel modules shipped with the node's distribution.
175- To avoid copying those dependencies into the kmod image, KMM mounts `/usr/lib/modules` into both the build and the
176- worker Pod's filesystems.
177- By creating a symlink from `/opt/usr/lib/modules/[kernel-version]/[symlink-name]` to
178- ` /usr/lib/modules/[kernel-version]` , `depmod` can use the in-tree kmods on the building node's filesystem to resolve
179- dependencies.
177+ To avoid copying those dependencies into the kmod image, KMM mounts `/lib/modules` directories of the host into the
178+ worker Pod's filesystem.
179+ By creating a symlink from `/opt/lib/modules/[kernel-version]/[symlink-name]` to
180+ ` /lib/modules/[kernel-version]` , `depmod` can resolve dependencies using in-tree modules from the DTK image at build time.
180181At runtime, the worker Pod extracts the entire image, including the `[symlink-name]` symbolic link.
181- That link points to `/usr/ lib/modules/[kernel-version]` in the worker Pod, which is mounted from the node's filesystem.
182+ That link points to `/lib/modules/[kernel-version]` in the worker Pod, which is mounted from the node's filesystem.
182183` modprobe` can then follow that link and load the in-tree dependencies as needed.
183184
184- In the example below, we use `host` as the symbolic link name under `/opt/usr/ lib/modules/[kernel-version]` :
185+ In the example below, we use `host` as the symbolic link name under `/opt/lib/modules/[kernel-version]` :
185186
186187` ` ` dockerfile
187188ARG DTK_AUTO
@@ -198,6 +199,8 @@ ARG KERNEL_FULL_VERSION
198199
199200RUN dnf update && dnf install -y kmod
200201
202+ COPY --from=builder /lib/modules/${KERNEL_FULL_VERSION} /lib/modules/${KERNEL_FULL_VERSION}
203+
201204COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_a.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
202205COPY --from=builder /usr/src/kernel-module-management/ci/kmm-kmod/kmm_ci_b.ko /opt/lib/modules/${KERNEL_FULL_VERSION}/
203206
@@ -208,8 +211,7 @@ RUN depmod -b /opt ${KERNEL_FULL_VERSION}
208211` ` `
209212
210213!!! warning
211- ` depmod` will generate dependency files based on the kernel modules present on the node that runs the kmod image
212- build.
214+ ` depmod` will generate dependency files based on the kernel modules present in the DTK image used during the build.
213215 On the node on which KMM loads the kernel modules, `modprobe` will expect the files to be present under
214- ` /usr/ lib/modules/[kernel-version]` , and the same filesystem layout.
216+ ` /lib/modules/[kernel-version]` , and the same filesystem layout.
215217 It is highly recommended that the build and the target nodes share the same distribution and release.
0 commit comments