8

I'm looking at a rather old Linux (v2.4) that has custom device drivers built into the kernel. Now I wonder since when that was done. I suppose it most be an old technique, was this the way device drivers were added to Linux already in version 1?

Niklas Rosencrantz
  • 1,111
  • 8
  • 22

2 Answers2

14

Kernel modules have been available since version 1.1.85 in January 1995 (see the introduction of README.modules in the 1.1.85 patch). At first, few drivers were actually available as modules, but within a few years everything that made sense as a module was available as a module.

When developing a new driver for the kernel, it’s easier to work on it as a module than a built-in driver: instead of rebooting when you make changes to the driver, you can unload the old module and load the new one in its place. In most cases though drivers are made available in both forms (built-in and in a module) before release, assuming they’re part of the main kernel source code. Drivers which are provided outside the main kernel source code can really only be made available as modules, unless the kernel itself is forked (which does happen).

Stephen Kitt
  • 121,835
  • 17
  • 505
  • 462
  • If I recall correctly modules also made the kernel blob smaller which was important at one point. – Thorbjørn Ravn Andersen Nov 24 '22 at 08:06
  • @Thorbjørn yes, that’s one of the advantages given in the “Module HOWTO”: “LKMs can save you memory, because you have to have them loaded only when you're actually using them. All parts of the base kernel stay loaded all the time. And in real storage, not just virtual storage.” Not only is the initial kernel blob smaller, but modules can be unloaded when they’re no longer necessary, which was important in small systems (e.g. for a removable hard drive: you could unload the FAT, USB etc. modules when the drive was unplugged). – Stephen Kitt Nov 24 '22 at 08:27
2

Before common use of initrd on hard disks, you compiled all drivers needed at boot time into the kernel. Initrd is quite old now, but use of it on hard disks is reasonably new.

Joshua
  • 1,829
  • 14
  • 22
  • Citation needed... Initrd has been used on hard disks for a very long time, e.g. in Debian since at least 2002. You’re right about compiling drivers necessary to boot the system into the kernel. – Stephen Kitt Jul 26 '17 at 21:09
  • @StephenKitt: Red Hat sure didn't and I've got the OS install intact to prove it (pre-internet computer). Slackware didn't either. – Joshua Jul 26 '17 at 21:51
  • 2
    Red Hat Linux 3.9 introduced modules instead of monolithic kernels in 1996. That’s not “reasonably new” in my book (at least, not as far as Linux history goes!). – Stephen Kitt Jul 26 '17 at 22:18
  • (See section 5.2 of the Red Hat Linux 4.0 user’s guide for details of initrd support.) – Stephen Kitt Jul 26 '17 at 22:30
  • 1
    Regarding initrd, I believe that was a new feature introduced in the 1.3.x line (circa 1997 I guess). It certainly wasn't used in my 1.2.13 based system in 1996, but when I upgraded to 2.0 I'm pretty sure the new system used it. – Jules Jul 28 '17 at 19:53
  • 1
    @StephenKitt definitely my first few Linux systems didn't use an initrd... if you were using a stock kernel you used the "IDE kernel" if your / was on an IDE disk or the "SCSI kernel" if it was on SCSI, the root fs was mounted directly, and the first process the kernel ran was the real init. IIRC the substantial changeover happened around the same time as 2.6 and udev. It was available before then, no doubt, but it wasn't the obvious or common thing. – hobbs Aug 04 '17 at 05:01
  • @hobbs I’m not claiming everyone used initrd, or even the majority; but I am saying that initrd has been used on hard drives for a very long time (it was an option with Red Hat Linux 3.9 in 1996). My recollection is similar to yours, with a big change around 2.6 and udev, but even that was long ago: udev and the 2.6 kernel were released in 2003... We’ve had them for over half of Linux’s lifetime. – Stephen Kitt Aug 05 '17 at 21:24
  • @StephenKitt alright, no argument with any of that :) – hobbs Aug 05 '17 at 21:27