LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2004, 06:36 PM   #1
nixel
Member
 
Registered: Apr 2004
Location: USA
Distribution: Slackware 9.1
Posts: 71

Rep: Reputation: 15
kernel/module concept explanation?


ive been reading on what modules are, how to install them, and how does it relate to the kernel. however, all the explanations that ive read or heard have been written or said assuming that a person is computer savvy/familiar with linux. anyone care to explain in newbie terms:

1. what exactly they are, and how does it effect the kernel?

2. when installing a module whats the process from start to finish? how do you know what to modprobe and what not to? what files do i need to edit so the kernel/system recognizes these new modules to be installed?

3. how to get it to start at boot?

4. the benefits of having things compiled as modules rather than compiled inside the kernel? the downsides?

ive searched around on module install but all i get are answers and not explanations. im having a hard time grasping the concept. if any one can help explain id appreciate it. thanks in advance guys....and gals.

-nixel
 
Old 04-25-2004, 08:23 PM   #2
PenguinPwrdBox
Member
 
Registered: Oct 2003
Posts: 568

Rep: Reputation: 30
A module is a bit of code, compiled into a file, that gives the kernel added functionality. This can be the ability to read a specific filesystem, the ability to address, and use a device, such as a soundcard, anything, really.

Kernels, as they usually are in standalone installs, are what is known as bare. They contain only what it needs to start, and run on your hardware. specifically, your motherboard.

It is up to the installer of your particular distribution, to detect your hardware, and edit your config files for you so that the proper modules load when the machine starts, thus, allowing you to use your devices. (Soundcard, vid card, USB devices, CD-DVD drives, etc.)

Modprobing is an advanced version of insmod. Modprobe inserts modules in the same way that insmod does, only, it allows far greater control. They can be inserted with parameters, such as IO addys, DMA's, IRQ's, and you can even allow it to insert the entire contents of a directory, provided, of course, that the directory contains only modules to be loaded. You will need to use modprobe, when loading the module for your soundcard, for example, because you must specify the resources that the card can use.

To get a modules to start at boot, add it to /etc/modules.conf.

The benefit of having your modules compiled into your kernel, is that you no longer need to load them at or after boot, as the kernel will support it nativley. This can be great, however, there are a number of reasons why a monlithic kernel is not a good idea. (A monolithic kernel is a kernel that is setup to run everything module free.) Monolith means "standalone" and that exactly what this is. This can be bad, due to the fact that the kernel size is usually much larger than that of a modular kernel (modular means "changable" ). Modular kernels are preferable, for the simple fact that if something goes wrong, you have the power to change your config to suit your needs right now, without recompilling. For instance, let's say that your NIC goes bad. Well, not only would you have to replace it, but, instead of just removine the old NIC's module, and loading your new one, you would have to recompile your kernel to remove and insert. Not fun. Hope this helps.
 
Old 04-26-2004, 01:22 AM   #3
nixel
Member
 
Registered: Apr 2004
Location: USA
Distribution: Slackware 9.1
Posts: 71

Original Poster
Rep: Reputation: 15
thanks for taking the time to explain things in such detail. it helped.

but lets say i needed to add a module for my soundcard. how would one know what to probe? in my case:

modprobe snd-via82xx

at least i think. how am i supposed to know i was supposed to modprobe that? im a bit confused about what to probe and what you dont have to. after this is completed i assume the module is part of the kernel now right? is there nothing else to do?

as far as loading the modules on boot you say to edit the modules.conf. does that mean put the "modprobe snd-via82xx" inside modules.conf? or are there other things to add?

the concept of kernels and modules was explained really well and it makes sense to me now. but the process in installing modules gets me stumped. modules.dep? depmod? are only a few things ive been hearing in this forum. can someone give me the process in installing one? what to check? what files to edit and make sure that the module stays there? i know these questions are basic, but hey, im a newbie and just trying to learn. thanks in advance for the responses.
 
Old 04-26-2004, 10:22 AM   #4
PenguinPwrdBox
Member
 
Registered: Oct 2003
Posts: 568

Rep: Reputation: 30
Well, just from your questions, I can tell that you are a bit confused. You don't "install" a module. You load it. This does not become part of the kernel, but merely allows the kernel to interact with the module to interact with the hardware.

You will need to modprobe your sound card, yes.

You add the whole command, just like you asked, into modules.conf.

Using your example, and the defaults for most sound cards, here is the complete modprobe command as you would probably enter it.=:

Code:
modprobe snd-via82xx io=0x220 dma=5 irq=1
This tells the kernel that we are using snd-via82xx as a module to interact with your soundcard, and that the soundcard has an IO address of 0x220, it's DMA channel is 5, and the Inturrupt that it will use to tap the processor is 1. These parameters are used mainly for loading HW modules, almost never for software, unless required. (If you don't know, you don't need it. Mainly for those fine folks out there building stuff for us that need to test it first.)

So, for instance, if you wanted to add NTFS support to your kernel by loading a module, the following would do just fine:

Code:
insmod ntfs.o
The relationship of kernels and modules are as follows:

A kernel begins life as what is known as source code. You have probably seen this before on some of the linux sites, just about all of them, really. Source code is the human-readable/editable format that software is written in. In order for this to be more than a glorified text document, it has to be compiled. A software compiler, in most cases for us in the linux world, is known as GCC (GNU C Compiler).
Compilers take this human readable format, and turn it into machine language, that is to say, software that can be used and understood by your machine.
All kernels must be compiled, whether you do it, or it is done for you by your distro's creators.
If you download the source code for a kernel, you have tons of files, that after compiled, will make up a kernel image that can be used to run your machine.
The cool thing about a kernel, though, is that there are options before you compile. You can tell the kernel exactly what you want the file image to be able to do.
This is done by changing the options. I won't get into detail, as there are 1001 posts here on how to compile your kernel, but, the quick and dirty is like this.
You can go into the kernel, and for every availible option (there are hundreds - most having to do with supporting a specific feature - networking, file sharing, encryption, hardware support, etc) you have three choices. You can do nothing, you can compile it as a module, or, you can add it to your kernel image.

Doing nothing - the results are obvious.

Compiling as a module, when you compile the kernel, you give it an extra command "make modules" which will build the actual module files for the options that you chose to build that way. This means that the module files on your computer are built by and for the same process that built your kernel. This means that they are totally compatable. This process creates the modules for you to load later. This is why it is not necc. to edit anything to let the kernel "know" that you "installed" a module. The kernel knows that they are there, they were born at the same time, as kinda second cousins.

The third option, is to compile it into the kernel, and the kernel image that you build, will have support for your chosen option without loading a file. Very simply put, it takes the code from the module file, and inserts it neatly into it's own code, so that they become one.

This is great for somethings, but maybe not for all. As I said before, since they basically become "one" - this means that for every option that you compile into your kernel, the larger the image will be, and depending on your machine, it might not be able to handle a kernel that is too large. So, you have some flexibility.

That is the whole point of linux. Flexibility. It was made to do just about anything on just about anything, and is entirely customizable. This is the beauty of it.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
what is kernel, shell? can help me understand the concept as compared to microsoft wi zhuzhu Debian 2 11-16-2005 08:16 PM
does the G95 or Gfortran support the concept of "module" in fortran95 ztdep Programming 1 09-08-2005 03:32 PM
grub / explanation of the kernel (vmlinuz) parameters picticpic Linux - Software 1 08-26-2005 06:55 AM
Kernel Explanation FatLinux Mandriva 4 02-18-2004 07:37 PM
kernel module ignorant newbie looking for any one with kernel module knowledge cpoet Slackware 4 11-24-2003 10:37 PM


All times are GMT -5. The time now is 02:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration