# Switching static kernel to modules mostly/only?

## Martux

I have long been thinking about how I could just switch my existing running kernel to module loading instead of statically compiled in. I read that's the most recommended and fast way.

Does it make sense and how could I achieve it?

----------

## Hu

Where did you read such a thing?  Module loading is more complicated at runtime than building all the required functionality into the kernel.  In most cases, it will be faster and more efficient to use a monolithic kernel, assuming that the monolith is customized to include only the functionality that you will use.  The main advantage to a modular kernel is that you can avoid loading functionality you do not need.  This is a bonus for distribution kernels since they can build a small core and modules for everything the user might use.  For Gentoo, where you build your own kernel, this is usually not needed.

----------

## Martux

I think I saw some discussions about it here. Hm, I see your point. Anyways, being a more or less computer literate person (a hobbyist), I might have plenty of stuff statically enabled that's not really needed. Plus being a person that  always copies over kernel configs and doing make oldconfig (for years), there might be a lot of cruft loaded. Those were my main concerns for this post.

----------

## Hu

You might have seen someone say that here.  Unfortunately, some people say things that are wrong, or are correct only under limited circumstances that may not apply to your situation.  Yes, a kernel with no tuning may have things you do not need.  If this concerns you, you would be better off removing those features entirely, rather than converting them to modules.  Some forum users may be able to help you identify options that are irrelevant to you, if you provide enough information about the computer and what functionality you expect to use.  Start with lspci -k and grep -e '^[^#]' .config.

----------

## Martux

Thanks for the reply Hu. Having this Skylake laptop running really nicely lately, with all the energy saving features working as it seems, I might just use it as is and someday start over with a fresh kernel config on another machine  :Wink: 

----------

## albright

sometimes hardware acts funny and a rmmod / modprobe sequence

saves the day ... without a reboot

----------

## toralf

For iptables it is nifty to simple add a missing module, recompile it and use it w/o a reboot.

----------

## Martux

I heard it is even possible to hotswap the kernel without rebooting?

----------

## Hu

 *toralf wrote:*   

> For iptables it is nifty to simple add a missing module, recompile it and use it w/o a reboot.

 Indeed, in those cases where it works, that is nice.  However, some options require not just building the module, but also building additional support in the core kernel (such as added fields in data structures or even whole extra data structures), which the module will need to access for it to work properly.  The core kernel features added that way need to be present in the running kernel or you cannot use the module.  Thus, there are cases where building a kernel, changing the configuration, building new modules, and then loading the modules will not work.  It is nice when it does work, but it cannot be relied on in the general case.

----------

