I read from arch wiki:

In case your root filesystem is on LVM, you will need to enable the appropriate mkinitcpio hooks, otherwise your system might not boot.

However, both my initrd and initramfs are on my root filesystem. How does the kernel loads these files if it does not have the modules to read from lvm? Isn't it a chicken and egg problem? Also, does the kernel use both the initrd and initramfs schemes, or only one? If both, how do these work together?

  • You only use one - see en.wikipedia.org/wiki/Initial_ramdisk for more? Anyway, that initial ramdisk needs to have all drivers you need to mount the root fs. – Aaron D. Marasco Apr 29 at 23:51
  • Yes but how does initrd gets its drivers? The initrd file is read from my root fs, which is not yet mounted. If it is not mounted, it can't be read, right? – Luke Kong Apr 30 at 0:14
  • Modern Boot loader will load the initramfs and the kenerl – 炸鱼薯条德里克 Apr 30 at 0:22

Isn't it a chicken and egg problem?

In a way, sure.

How does the kernel loads these files

It doesn't. A (fully modular) kernel is indeed incapable of doing so, in fact unable to access any disk at all, until you load the appropriate modules (ahci, scsi, etc.)

You could also ask how the kernel loads the kernel... this is not possible, so there has to be something else.

Like the bootloader, which loads both kernel and initrd/initramfs for you (if applicable - it's possible to put both into one file.)

  • So a bootloader can access my lvm? – Luke Kong Apr 30 at 0:23
  • I'm a little bit curious, how to put them in one file? Is it possible to compile Linux kernel with a built-in initramfs? – 炸鱼薯条德里克 Apr 30 at 0:24
  • @LukeKong that depends on the bootloader, grub has this feature, other bootloaders you'll have to provide with an easier to reach copy of your kernel. It's also possible to boot over the network, so it doesn't even have to be stored on your local disks at all. – frostschutz Apr 30 at 8:27
  • @炸鱼薯条德里克 yes for example like this wiki.gentoo.org/wiki/Custom_Initramfs#Embedding_into_the_Kernel – frostschutz Apr 30 at 8:28

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.