I want to embed an initramfs into my kernel at build time, but to create the rootfs image I need access to a number of modules for the kernel I'm about to build.

What is the proper way to resolve this apparent chicken/egg problem of building the modules, then the initramfs, and then finally the kernel proper?

I can't seem to find much documentation on this particular workflow. One option I am considering (since this is an embedded device with a known hardware config) is to just forego modules for any boot-time required code.


I guess a better question is in order. Here's some additional info:

This is running on the Raspberry Pi which has it's own closed-source bootloader which can be configured via a couple text files in the boot partition.

The main impetus of this question is to ease updates in the nearterm (being able to just ship the kernel/initramfs in a single package without fiddling with bootloader configs that don't support logic for calculating addr offsets), to ease future migration to a secure boot chain (most likely through an interposed uboot loader; more files, more signatures, more pain), and to keep our OS build process simple (doesn't currently use a discrete bootloader).

The more I look at it, the more I'm leaning towards just spending a day and getting uboot integrated into our build pipeline and not looking back. It just seems the whole Linux boot process is overly complex--especially for a fixed hardware spec system--and I'm trying to find ways to simplify through degeneralization.

  • Are you compiling your own kernel? What version? What embedded device are you using? Most of the, no some of the modules you will need will be in the kernel source for your device and you can select what modules to build at compile time. – jc__ Sep 20 '16 at 13:28
  • @jc__ Yes, and I may end up going the built-in route instead of using modules for boot-time features. I added some additional info to the question. It felt like having module support for boot-time modules would make our roadmap a bit easier to execute. – joshperry Sep 20 '16 at 15:40
  • What chicken and egg problem? The simple approach is to build the modules at the same time as the kernel. You don't need to have the rootfs image to build the modules. – Gilles Sep 20 '16 at 22:30
  • @Gilles But I do need to have the initramfs image if I want to embed it in the kernel at kernel build time, unless I'm misunderstanding you. – joshperry Sep 20 '16 at 22:52
  • @joshperry But you don't need that to build the modules. Just call make modules. – Gilles Sep 20 '16 at 22:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.