6.3 Kernel Modules

In Chapter 5, we built the kernel modules and installed them in a temporary directory, ${PRJROOT}/images. We are now ready to copy these modules to their final destination in the target's /lib directory.

Since you may have compiled many kernels to test for your target, you will need to select which set of kernel modules to copy to the root filesystem. In the case of my control module, for example, I chose a 2.4.18 kernel for my target. The following command copies that kernel's entire modules directory to the root filesystem:

$ cp -a ${PRJROOT}/images/modules-2.4.18/* ${PRJROOT}/rootfs

We the use cp's -a option here to copy the files and directories in archive mode. This has the effect of preserving file attributes and links, and copying directories recursively. Note that there is no need to explicitly append the /lib/modules path to ${PRJROOT}/rootfs in the above command because of the way we installed the modules in the ${PRJROOT}/images/modules-2.4.18 directory in Chapter 5.

That's it; the kernel modules are now ready for use on your target. You may also want to add a /etc/modules.conf file to automate the loading of the modules during system operation. See Chapter 11 in Linux Device Drivers for more details regarding module management and the use of the /etc/modules.conf file.