[LC++]Loading kernel modules automatically at boot time

Paul Gearon gearon at ieee.org
Fri Jul 16 08:51:01 UTC 2004


Krishna Monian wrote:
> Hi,
> I have written a kernel module which is a char device.
> It works fine when I insert and remove it using insmod
> and ammod. 

You've really written to the wrong list here.  This isn't a C++ programming
question.  In fact, it's almost the opposite.  This is because writing a
kernel module in C++ is a REALLY bad idea, and takes some hacking to get right.

Lots of people have suggested rewriting the kernel in C++ or to allow for C++
modules.  Linus has very strong opinions about this.  Look in Google to see
what I mean.

> However, I want this module to load automatically at
> boot time. How should I go about doing this.

It's done with the startup scripts.  Every distribution does it differently.

On Debian you add the name of your module into /etc/modules and then
/etc/init.d/module-init-tools will modprobe it (this is turn is picked up when
the startup scripts find /etc/rcS.d/S20module-init-tools).  Your own
distribution will have something similar.

Regards,
Paul Gearon



More information about the tuxCPProgramming mailing list