You are not logged in.

#1 2008-03-03 09:22:35

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

[kernel compile] Why build as module instead of static?

I have tried googling this subject a lot, but I can't seem to find a clear answer. I'm building a kernel for my system which only consists of the necesary code for my specific hardware. And if I am correct, if I compile everything static, there is no need for an initrd image. So what is the point of building stuff as modules? I really want to understand this but I am having a hard time getting it through my thick skull!

Offline

#2 2008-03-03 09:50:09

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [kernel compile] Why build as module instead of static?

The point of modules not compiled-in is for *distros* to offer modules without having a huge bloated kernel.

Module options needing to be in /boot/grub/menu.lst rather than /etc/modprobe.conf will confuse newbies smile

Some modules are convenient, e.g. ALSA (to be able to use the kernel's alsa, or overwrite them by compiling alsa-driver-1.0.16).

Offline

#3 2008-03-03 09:57:03

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: [kernel compile] Why build as module instead of static?

Okay, I think I can follow so far... So in my case specifically, am I better off just compiling everything static for my specific laptop hardware? And how can you know you need an initrd image or if you can skip it?

Offline

#4 2008-03-03 10:29:46

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: [kernel compile] Why build as module instead of static?

Thanks to modules I haven't had to recompile my kernel since 2002.
That's the whole point with modules.
I don't care if this comes at the cost of some extra initrd complexity.

If you have reiserfs as root filesystem and compile reiserfs as a module, you can't boot without an initrd, since the kernel wouldn't be able to read the module it needs in order to read the module itself.
If you have all the essential drivers you need at boot, you won't need an initrd.

Last edited by carlocci (2008-03-03 11:28:34)

Offline

#5 2008-03-03 10:51:22

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: [kernel compile] Why build as module instead of static?

Okay, so for example, if I use ext3 and ext2 all the time, I'm better off compiling it static then? And what about a USB device I sometimes attach to my laptop. Will compiling it static, make the booting slower? Will the kernel load that code, even though the device isn't connected, because I didn't build it as a module?

Thanks so far for the answers.

Offline

#6 2008-03-03 11:44:39

carlocci
Member
From: Padova - Italy
Registered: 2008-02-12
Posts: 368

Re: [kernel compile] Why build as module instead of static?

Maybe I miss the point: I don't understand if you hate having an initrd or if you hate having modules.
If you don't like having an initrd, you would compile statically all the drivers you can't do without at boot, which really depends on your computer and what you want to do with it. You would keep the features you add to a bare minimum, then add the rest as modules. So you wouldn't add your sound card, or your v4l driver for your webcam to your kernel, you would build them as modules: this way they wouldn't be loaded at boot time, but they could be loaded only when you need them, if you need them.

If you don't like modules at all, everything should be loaded at boot, why would you do that?!

Performance is more or less the same.

Offline

#7 2008-03-03 12:41:08

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: [kernel compile] Why build as module instead of static?

I don't hate any particular configuration, I'm just trying to understand it all. And if I can leave the initrd behind, that kind of simplifies the kernel compilation, right? So if I'm right these are some of the advantages and disadvantages of modules:

+ You can put in newer modules without recompiling the whole kernel
+ Modules that are not loaded at boot don't take up any RAM space, whereas static modules do?

- If you need modules at boot to access your root, you need an initrd

Please correct me if I'm wrong!

Offline

#8 2008-03-03 14:41:40

schivmeister
Developer/TU
From: Singapore
Registered: 2007-05-17
Posts: 971
Website

Re: [kernel compile] Why build as module instead of static?

Just know this:

Built-in = Glued

Modules = Not Glued

Built-in = Laptop

Modules = Desktop

Simple?

Dynamic is the future, why stick to the 80s?


I need real, proper pen and paper for this.

Offline

#9 2008-03-03 20:10:15

HyperBaton
Member
From: Belgium
Registered: 2008-01-18
Posts: 207

Re: [kernel compile] Why build as module instead of static?

But are the modules that are built-in always loaded? As in, do they use up RAM memory even when they aren't used? As opposed to modules?

Offline

#10 2008-03-03 20:22:02

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: [kernel compile] Why build as module instead of static?

Yes. But it's not important, for desktops that can quite feasibly contain several gigabytes of RAM these days.

The advantage is that udev can't mess things up (failing to load a needed module, or doing it slowly when there are lots of modules). But it's not like there's a huge advantage either way.

Offline

Board footer

Powered by FluxBB