2

I’ve got a chicken and egg type conundrum I’m trying to figure out:

First point:

If one of the purposes of initramfs is to load the main file system by providing some necessary drivers (RAID for instance), and initramfs lives on said filesystem, how does that work exactly?

Second point:

Some sources seem to say that the kernel is the one that loads initramfs. In this case, how would the kernel first be accessed if it’s residing on the filesystem that initramfs is supposed to provide access to in the first place?

1

On Linux, the initramfs is loaded into memory by the boot loader, not the kernel; the boot loader also loads the kernel, and tells it where the initramfs is, so that when the kernel boots, it can find the initramfs in memory and use it to boot the system. (This follows the multiboot specification.)

The boot loader, GRUB on many systems, includes drivers which allow it to access the file system containing the initramfs (and the kernel). This includes RAID modules, file system drivers, LVM modules, decryption modules etc. (Some simpler boot loaders don’t provide such wide-ranging support, and thus limit the storage possibilities for the kernel and initramfs.)

  • If Grub has the necessary drivers to load the kernel and initramfs directly off the hard drive, one might wonder why initramfs is needed at all. But I'm assuming that other scenarios exist, and this is probably the simplest of them all. – joueffy Sep 11 '17 at 12:54
  • The initramfs is needed so that the kernel can access the file systems needed to boot. – Stephen Kitt Sep 11 '17 at 13:09
  • An initramfs is needed for two reasons on Linux: 1. Because Linux does not support loading modules directly from memory.. 2. Because a lot of storage stacks require userspace components and configuration to assemble before they can be used by the kernel to mount filesystems. – Austin Hemmelgarn Sep 11 '17 at 19:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.