LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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-29-2008, 08:40 PM   #1
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Rep: Reputation: 30
Question How to load modules to kernel at boot


1) How can I load modules to a kernel at boot?

2) Where can I find a list that will show me the CONFIG options for the kernel version and the modules that result from adding that CONFIG option?

3) How can I find out if the module is built for that version of the kernel? What command can I use and what output will it give?

4) Where can I find the right source file for a module, and how can I build just that module? What GCC command options need to be used?
 
Old 04-30-2008, 01:05 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
1) How can I load modules to a kernel at boot?
... you are ulikely to need to do this as the kernel loads modules dynamically as needed. However - you can use your distro equivalent to modprobe.conf

2) Where can I find a list that will show me the CONFIG options for the kernel version and the modules that result from adding that CONFIG option?
... from the kernel source tree would be the most complete. Though you can just boot and then enter "lsmod" in a terminal. All loaded modules will appear there.

3) How can I find out if the module is built for that version of the kernel? What command can I use and what output will it give?
... you've lost me there. Any module in the kernel is built for that version. For third party modules, you'll have to consult the maintainer.

4) Where can I find the right source file for a module, and how can I build just that module? What GCC command options need to be used?
... again - consult the module maintainer. Most free modules are part of the kernel source and get built with the kernel. Third-party modules usually come with a makefile and instructions. In relation to gcc commands - a module is the plain old object-code output.

Probably you are trying to solve a particular problem - so state specifics.
 
Old 04-30-2008, 02:21 AM   #3
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
Question modules

Thank you for your comment, Simon.

I have been trying to figure out how to get a Linux kernel to boot, and had some errors from /sbin/modprobe in the boot. There are other posts about that. This post was to find out how I can add some modules to the built kernel and get the kernel to boot, if it was missing some.

1) This Linux boot is new to me. If I modify modules.conf at what point in the boot process will it start to put those modules in?

2) "Where can I find a list that will show me the CONFIG options for the kernel version and the modules that result from adding that CONFIG option?
... from the kernel source tree would be the most complete. Though you can just boot and then enter "lsmod" in a terminal. All loaded modules will appear there." - I am not able to boot the kernel, so I can not do an lsmod on this kernel. I am asking about configuring the kernel, and how I can find out what different configuration options create what different modules. Again, where can I find a list that will show me the CONFIG options for the kernel version and the modules that result from adding that CONFIG option. Such as CONFIG_USB=y will add what module? I want to find the list that will show me all the CONFIG options and what modules they will cause the build process to create.

3) "... you've lost me there." If I find a module file, and I want to find out what kernel it was built for, how can I do that? Such as usbcore.o, what kernel version is it built for? Is there a command that I can use to tell me what kernel version this file such as "usbcore.o" was built for?

4) "... again - consult the module maintainer." I am not talking about third party modules. I am only talking about Vanilla kernels. I want to find out how I build a module. Such as usbcore.o. How can I build it form the source file usbcore.c? If I am in the kernel source tree for that file, what would I need to do to build it into a module? The make builds them automatically. I want to build it a file at a time.

____________________________
I gave Linux a try because of M$crosoft. My M$crosoft ME started to huff and puff and told me to get Vista. I tried to recompile my M$crosoft ME, but I did not know where to start. Now, I have been compiling Linux. It compiles. I just got to get it to boot.
 
Old 04-30-2008, 08:28 AM   #4
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
1. Usually ... when they are needed. Read the man page, look at the existing one.
2. Yes - but you have access to the kernel source. Look in the source tree.

If you want to guarantee that a module is available the second the kernel is first loaded, then compile it into the kernel instead of leaving it as a module.

The actual configuration gets scattered among the directories in /proc/sys (mostly) the list of what each option actually does is kept in the kernel documentation in the source tree.

3. Usually, where you found the driver is a clue. To use your example:

~$ locate usbcore
/lib/modules/2.6.22-14-generic/kernel/drivers/usb/core/usbcore.ko

"usbcore" is a module supplied with the kernel. It is compiled with the "make modules" command and installed, with "make modules install", to the appropriate kernel's modules directory - in this case: 2.6.22-14-generic ... which is the kernel it was compiled against.

If you suspect that someone has been inserting random modules into this tree, you can probably check by comparing the timestamps (as all the legitimate modules will have been built together).

4. You did not specify where the modules came from in your original post - and I try not to assume less I end up making an ass out of u and me.

If you want to build a module already supplied in the kernel source, you must first enable it in the kernel configuration, the build it, then install it. From your comments, you have compiled a kernel, at least once, already. You just do the module building steps. IIRC:

make gconfig
... locate the module in the tree, read it's documentation, enable it.

make modules
make modules install

Now try booting the kernel.

(Naturally, gconfig can be xconfig or qconfig depending on your environment.)

If you need a module to be available in order to access the kernel you want to run, and you are unwilling to include it in the kernel itself, then you need to play with the initrd, and initramfs. Read their man pages - this is a huge subject all by itself.
 
Old 04-30-2008, 07:57 PM   #5
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
Question moduleA

Thank you for the comment.

I have been able to build the kernel, and I know that in that build process that it will build modules and install them. The question that I am asking, is that if I just want to build ONE module, from a single source file such as usb_core.c, how would I do that? If I use the "make modules" command it will use the Makefile and try to build all of the modules. I just want to build one module at a time.

The build for one module will be fast. When I tried to "make modules" on a 2.6.X kernel, it takes a bit of time, something like half an hour. That will make me get old trying to learn Linux.

To ask the question again in a different way, if I have the kernel sources for a 2.6.20 kernel in the directory /build/kernel/2.6.20 and I already have built that kernel and some of the modules, and want to build "moduleA" and only build "moduleA", how can I build it?

To ask the other question again, if I am booting the kernel that I built, the 2.6.20 kernel, and I now have this new module called "moduleA" that I just built but before it was not built when I built the kernel, how can I link it to the kernel so that it will be linked before it tries to start the login window screen?
 
Old 04-30-2008, 10:37 PM   #6
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
Quote:
The question that I am asking, is that if I just want to build ONE module, from a single source file such as usb_core.c, how would I do that?
And I told you how.

Quote:
I just want to build one module at a time.
So enable one module at a time.

Quote:
The build for one module will be fast. When I tried to "make modules" on a 2.6.X kernel, it takes a bit of time, something like half an hour. That will make me get old trying to learn Linux.
That's why you read the documentation first. There is no way around this.

The kernel is big, really big. You won't believe how vastly, hugely, mind-bogglingly big it is. You may think it's a long way down the street to the chemist, but that's peanuts to the kernel. By the time you have learned about it at the kind of detail you are going for, you will be old.

But... Oh all right <relents>.

I understand/stood what you are/were asking - just the one module - you have to specify it, with it's CONFIG_FOO options on the make line.

# make CONFIG_FOO=m M=rel-path/to/module

... from the source tree root.
There will be more than one CONFIG_ option, the Qconf Graphical Kernel Configuration Tool will tell you what they are.

make xconfig

Look up the module you want.

Before you finish, clean up:

# make M=rel-path/to/module clean

Here's a nice overview of the initramfs, from the gentoo perspective but don't let that put you off.

Last edited by Simon Bridge; 04-30-2008 at 10:42 PM.
 
Old 04-30-2008, 10:48 PM   #7
newtovanilla
Member
 
Registered: Apr 2008
Posts: 267

Original Poster
Rep: Reputation: 30
build

Thank you for your comment.

This make stuff is all new to me. I could build the kernels from the instructions, but I have no idea what it is doing. I see a ton of stuff scroll on the screen, sometimes for an hour or more. Is there an option to make that will be faster than if it displays all of that text? It is too fast for me to read it anyway.

A forum member, Smedley, gave me this link to get a Linux kernel book from Oreilly for free. www.kroah.com/lkn

In the book on page 27 of the chapter 4 Advanced Building Options it tells you how to build just one module. I think that this is what I was trying to find.

"To build only a specific file in the kernel tree, just pass it as the argument to make.
For example, if you wish to build only the drivers/usb/serial/visor.ko kernel
module, enter:
$ make drivers/usb/serial/visor.ko
The build system will build all needed files for the visor.ko kernel module, and do
the final link to create the module."
 
  


Reply



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
Kernel Modules, to load or not to load VampireL0rd Linux - Software 3 07-24-2007 09:20 PM
load modules at boot coldsalmon Linux - Newbie 4 04-21-2005 04:36 PM
Load modules at boot martincho Linux - Networking 2 11-27-2004 10:12 AM
Modules don't seem to load on boot ViNsAniTy Linux - Newbie 4 04-21-2004 12:40 PM
Making custom kernel..but drivers and modules wont load on boot skoal Linux - General 10 12-06-2001 06:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:26 AM.

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
Open Source Consulting | Domain Registration