modprobed-db
modprobed-db is a useful utility for users wishing to build a minimal kernel via a make localmodconfig. In a nutshell, this make target creates a config based on the current config and a list of modules. It then disables any module option that is not needed thus not building hundreds/potentially thousands of extraneous modules. This results in a system-specific, streamlined kernel package and footprint as well as reduced compilation times.
Preparation
modprobed-db works best by using the distribution kernel for a month and have the utility run in the background to collect the data on your system of what modules it uses. An alternative (but not recommended) method would be to run the utility in the installcd's chroot environment and plug in every device and mount every drive with a different file system that user owns. This will not be perfect as the installcd disables some modules to make sure it works on all systems correctly so some manually editing will be required.
Installation
root #
emerge --ask sys-kernel/modprobed-db
Building kernels
To build a kernel with modprobed-db then first emerge sys-kernel/gentoo-sources or any Linux kernel source package.
root #
emerge --ask sys-kernel/gentoo-sources
To use modprobed-db with the sources then first run the tool with:
root #
modprobed-db store
This will store a database of all currently used modules in $HOME/.config/modprobed.db
Next, change directories to the kernel sources and configure make localmodconfig to use the database just created}}
root #
cd /usr/src/linux
root #
make LSMOD=$HOME/.config/modprobed.db localmodconfig
Normal steps to build a kernel now apply:
root #
make -j $nproc
root #
make modules_install
root #
make install
Auto update database
What makes modprobed-db a useful tool is it's ability to scan the system periodically and add new modules to the database when new hardware is added.
A kernel rebuild is still required for the modules to be added
Systemd
Systemd users can take advantage of the included user services which will update the database every 6 hours.
root #
systemctl --user enable modprobed-db
root #
systemctl --user start modprobed-db
OpenRC
OpenRC users will currently have to use cron to gain this feature.
0 */6 * * * /usr/bin/modprobed-db store &> /dev/null