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 ?
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 lspci
/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.
/dev/sd*
. So you will want to specify a uuid. And you need an initrd that contains the script that mounts the root volume by uuid, the kernel can't do it.
Commented
Aug 10, 2012 at 21:16
PARTUUID=
and rootwait
. See kernel-parameters.txt and Why can't I specify my root fs with a UUID? and What's the point of rootwait/rootdelay?
planning to add default drivers
Then start with make defconfig && make
, as a related answer laconically suggests. Well first just the default (x86_64?) .config
.
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.
While the 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.
After 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 Kconfig
.
With the modified .config
ready:
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.