LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   When do you use modules? (http://www.linuxquestions.org/questions/linux-kernel-70/when-do-you-use-modules-728180/)

hosler 05-24-2009 12:08 PM

When do you use modules?
 
I read somewhere that building a module is better than just building it in the kernel because that makes the kernel load faster. Is this true? Anyway, I would like to know which things should always be built straight into the kernel and which would be fine for building as modules.

jschiwal 05-24-2009 12:31 PM

If you are running a desktop, then building off the default options of your distro would be OK. If you don't have a device that a kernel module uses, it won't be loaded.

One time where you might want to build a flat kernel is if you run a server on the internet. Servers tend to not need to support as many devices as a desktop might, so you can strip out a lot of support that you don't need. You can build a kernel with custom options that only support what your server has, and no more. Then a flat kernel won't be as large. Further, by building a flat kernel and removing support for LKMs, a cracker will have a harder time since most rootkits tend to work by replacing an LKM with their own version.

hosler 05-24-2009 06:00 PM

I run a laptop. So I will be putting a bunch of devices into a usb port and other slots. Maybe I should build a lot of modules for these devices I may be using in the future, or should I not even bother? I would like for linux to recognize these devices when I plug them in (eg. Some random digital camera a friend of mine owns and wants to upload to my comp).
Also, in regards to my previous question, what needs to be built into the kernel so I don't get a kernel panic when I boot? Usually just run
Code:

make defconfig
and just add all the drivers my laptop needs into the kernel and build it. I'm too scared to try and optimize the kernel for I might break it.
I have been using linux for years and built over 100 kernels, but I still feel like a complete noob when I do it because I don't know what half the stuff in the kernel is or does.
Maybe someone could just send me a nice internet link that explains all of this instead of having to answer this tedious post.

jschiwal 05-25-2009 09:35 AM

The option you probably want to use is "make oldconfig" instead of "make defconfig". This will use the same config settings as your running kernel. If there are new options in a newer kernel, you will be prompted whether to select them.

One thing to keep in mind is that some distro's patch the kernel. There are some things that you may loose if you start with a generic kernel you downloaded. For example, if you build a kernel for the eeepc, the generic kernel source doesn't have support for unionfs. It is considered experimental (unless my knowledge is too old) and you would need to apply a patch to install it unless you work with your distro's patched source.

Also keep your old kernel. Backing up /boot would be a good idea as well. If you are re-building the same kernel version, you might also want to backup /lib/modules/$(uname -r) and /etc/modprobe.conf & /etc/modprobe.d/.

Good Luck!

hosler 05-25-2009 11:02 AM

Is it a good idea to make every USB input device driver into a module? I guess thats what i'm really asking. Don't know why I had to write so much.


All times are GMT -5. The time now is 04:07 AM.