Is it possible to boot linux without a initrd.img ? I am planning to add default drivers as a part-of-kernel itself and avoid initrd completely.
What are the modules that should be made part-of-the-kernel instead of loadable modules ?
It is, unless your root volume is on an LVM, on a dmcrypt partition, or otherwise requires commands to be run before it can be accessed.
I haven't used an initrd on my server in years. You need at a minimum these modules built in:
the modules that run the filesystem mounted on it
It's also a very good idea to build in your network card drivers as well.
I've found that
lsmod can help you here from your currently running kernel, look at what's there and use the make menuconfig search option before compiling to find where to enable the modules.
planning to add default drivers
Then start with
make defconfig && make, as a related answer laconically suggests. Well first just the default (x86_64?)
That way you get a quite large kernel -- today 9 MB. The only as-modules are netfilter ones.
A more tailor-made config results in 4.5 MB kernel, and some more modules (notably the i915 module).
Some modules have to be built-in. See other answer. Ten years later, I should also explicitly add I/O devices: USB_HID for keyboard, FB (framebuffer) for integrated graphics card, depending on the system.
Devices, it seems, don't like to stay un-driven after power-up: graphic card module and network module, plus some bus helper reduce my Watts from 5.1 to 3.1. This is a bit counter-intuitive; explained by the drivers putting the devices into the correct suspend state, or otherwise calming them down.
e1000e module can be removed (and the 0.2 Watts or so don't seem to come back; and the network will be down), the
i915 cannot even be removed. So these "modules" behave very differently.
make defconfig, and equipped with
lsmod from a initrd/udevd installation/distro, you can
make nconfig or similar and start weed out (or even add something). Work with
With the modified
make -jx bzImage
This image can be installed (copied and given a KCL:
root=) and test booted. If it works, and you also want the modules:
make -jx modules
make INSTALL_MOD_PATH=/maybe/mnt/elseroot modules_install
Don't forget to save and name the
.config file before reconfiguring.
Some modules (netfilter, filesystem support) are nicely removable. Modules are compiled separately from bzImage, which can save kernel compile time if repeated. Otherwise the difference is not big, unless you care how
lsmod output looks.
Oh and then
systemd also has some requirements and expectations.