In the complex ecosystem of the Linux operating system, drivers play a pivotal role in facilitating communication between hardware devices and the Kernel. Within the Linux Kernel, drivers can be incorporated in two primary ways. One method involves integrating them directly into the Kernel and making them an integral part of the vmlinux image. Another method is to build the drivers separately and dynamically loaded into the Kernel as needed. So, the driver which is loaded dynamically into the Kernel is known as the kernel module. Modules are convenient during the development phase. Let's discuss each one of them:
1. Built-in Drivers: Drivers can be compiled directly into the Kernel itself, becoming an integral part of the kernel image (vmlinux). These drivers are loaded and initialized along with the Kernel during boot time. This approach is suitable for drivers that are essential for basic system functionality or for hardware that is always present.
Example:
Ethernet Drivers: Built-in Ethernet drivers are essential for establishing network connectivity upon system boot. They enable communication between the Linux Kernel and Ethernet network adapters, facilitating data transfer over wired networks.
SATA Drivers: SATA drivers integrated into the Kernel are crucial for recognizing and accessing SATA storage devices, such as hard disk drives (HDDs) and solid-state drives (SSDs).
2. Kernel Modules: Drivers can also be built as separate modules that can be dynamically loaded into the Kernel at runtime. These dynamically loaded drivers are referred to as kernel modules. They are not part of the main kernel image (vmlinux), but instead exist as separate files (typically with a .ko extension). Kernel modules can be loaded and unloaded as needed, making them useful during development, and testing, and for supporting hardware that is not always present or is added after the system has booted.
Example:
Graphics Card Drivers: Kernel modules for graphics cards are often dynamically loaded to provide support for various GPU models.
USB Devices: Kernel modules for USB devices allow the Linux Kernel to recognize and interact with a wide range of peripherals, including keyboards, mice, printers, and storage devices.