0

I am little confused about initramfs and initrd, if they are the same thing. Does initramfs loads into the memory first and then kernel is loaded into memory and then kernel loads the drivers from the initramfs image file including the systemd process.

or both grub loads both initramfs and kernel into memory simultaneously. then kernel extract the contents on initramfs to proceed further to systemd startup

Contents of my /boot :

enter image description here

munish
  • 1,013

1 Answers1

2

I am little confused about initramfs and initrd, if they are the same thing.

They are not "the same thing". That's why they have different names.
However they can serve the same purpose, i.e. an initial root filesystem.
They differ in the method of implementation, i.e. how they exist in memory.

An initrd is an initial ramdisk. A ramdisk is a block device that exists in memory, typically allocated out of main memory, as opposed to a block device that uses mass storage. Use of initrd in Linux is deprecated in favor of initramfs.

An initramfs is an initial ramfs. A ramfs utilizes the existing filesystem cache as the storage medium. The ramfs can store as much data as there is available memory.

Does initramfs loads into the memory first and then kernel is loaded into memory and then kernel loads the drivers from the initramfs image file including the systemd process.

No, since your description makes no sense (e.g. "initramfs loads into the memory").
The boot program (e.g. Grub, U-Boot) must load the kernel into main memory from the boot device.
If there's an initrd, then the boot program must also load an image file of that.

or both grub loads both initramfs and kernel into memory simultaneously. then kernel extract the contents on initramfs to proceed further to systemd startup

Close.
If there's an initramfs instead of initrd, a cpio archive would be linked into the kernel image. During boot the kernel creates an empty initramfs. The attached cpio archive is then extracted to populate the initial ramfs.


The official Linux documentation is here with more details.

sawdust
  • 17,804
  • do you advise any book to read for understanding these concepts or any online resource – munish May 13 '18 at 09:02
  • Despite them not being the same, the former name stuck, and even nowadays, to add a bit of confusion, many distributions call initramfs archives initrd (eg: Debian) – A.B May 13 '18 at 09:16
  • 2
    While a kernel may have a built-in initramfs in all cases, this doesn’t matter. In the real world, if a initramfs is used, it’s almost always an external file. This file is loaded the same way the legacy initrd was. – Daniel B May 13 '18 at 10:23
  • @Daniel Yes, that is true. I have initramfs file other than the kernel file vmlinuz..Does that mean that kernel does not mean that kernel does not create the empty initramfs instead it uses the external file – munish May 13 '18 at 10:54
  • No, that description is correct. It’s described in a very understandable way in the document linked at the end of the answer. – Daniel B May 13 '18 at 12:01