Initrd Explanation and Setup
-
- Member
- Posts: 61
- Joined: Tue Sep 13, 2022 9:29 pm
- Libera.chat IRC: FunnyGuy9796
Initrd Explanation and Setup
I am curious what the initrd is and what it is specifically used for. I have searched the internet but could not really find anything related to the initrd in terms of operating system development. Basically, what is the purpose of it and how would it be set up? I know that the layout of an initrd is different for everyone because everyone's projects are different. However, I am wondering what a "template" initrd would look like. Thanks in advance!
Re: Initrd Explanation and Setup
Here are a few quick resources.
https://developer.ibm.com/articles/l-initrd/
https://docs.kernel.org/admin-guide/initrd.html
https://en.wikipedia.org/wiki/Initial_ramdisk
That answers the question "how would it be set up?"
For the question "what is the purpose of it?" maybe you don't need more of an explanation, but I'll take a stab at it anyway -
Linux used to not need an initial ramdisk. (Technically you can still boot without one.) So it's interesting to think about what happens immediately after the kernel is done and has handed off control to the first process, typically named "init" but really it's whatever the kernel has been given.
Side note: if the kernel doesn't have an initial ramdisk, it'll load "/sbin/init" from the root device.
That is why an initial ramdisk came into being. If the root device is a USB flash drive, it may not have shown up yet. USB flash drives can take a looong time to become ready. There is the "rootwait" parameter which just has the kernel hang silently forever for the root to be ready.
The initial ramdisk wasn't common at first, but PXE boot, bootable USB drives, iSCSI and SAN were some places where an initial ramdisk were very much needed.
The initial ramdisk means that instead of specifying a root device (/dev/sda or something) the kernel can hand off control to code which can do whatever you want in terms of finding the root drive, or mounting a bunch of things before running /sbin/init, or whatever you need.
Typically the initial ramdisk will load kernel modules needed to get to a working system. As linux distros started including more and more modules, they adopted the initial ramdisk and it became commonly used.
https://developer.ibm.com/articles/l-initrd/
https://docs.kernel.org/admin-guide/initrd.html
https://en.wikipedia.org/wiki/Initial_ramdisk
That answers the question "how would it be set up?"
For the question "what is the purpose of it?" maybe you don't need more of an explanation, but I'll take a stab at it anyway -
Linux used to not need an initial ramdisk. (Technically you can still boot without one.) So it's interesting to think about what happens immediately after the kernel is done and has handed off control to the first process, typically named "init" but really it's whatever the kernel has been given.
Side note: if the kernel doesn't have an initial ramdisk, it'll load "/sbin/init" from the root device.
That is why an initial ramdisk came into being. If the root device is a USB flash drive, it may not have shown up yet. USB flash drives can take a looong time to become ready. There is the "rootwait" parameter which just has the kernel hang silently forever for the root to be ready.
The initial ramdisk wasn't common at first, but PXE boot, bootable USB drives, iSCSI and SAN were some places where an initial ramdisk were very much needed.
The initial ramdisk means that instead of specifying a root device (/dev/sda or something) the kernel can hand off control to code which can do whatever you want in terms of finding the root drive, or mounting a bunch of things before running /sbin/init, or whatever you need.
Typically the initial ramdisk will load kernel modules needed to get to a working system. As linux distros started including more and more modules, they adopted the initial ramdisk and it became commonly used.
-
- Member
- Posts: 61
- Joined: Tue Sep 13, 2022 9:29 pm
- Libera.chat IRC: FunnyGuy9796
Re: Initrd Explanation and Setup
Thank you so much for the reply! This is exactly what I was looking for!
Re: Initrd Explanation and Setup
I have the masochistic tendency to customize the kernel in every Linux installation I do on my own computers so that I don't need neither Grub (by getting the UEFI to directly boot the kernel, but I still add a Grub entry to the UEFI for emergency purposes) nor an initrd, by recompiling the kernel with all the specific modules for my system. It does shave a few seconds off boot time.sounds wrote:Linux used to not need an initial ramdisk. (Technically you can still boot without one.) So it's interesting to think about what happens immediately after the kernel is done and has handed off control to the first process, typically named "init" but really it's whatever the kernel has been given.
Writing a bootloader in under 15 minutes: https://www.youtube.com/watch?v=0E0FKjvTA0M
- bellezzasolo
- Member
- Posts: 110
- Joined: Sun Feb 20, 2011 2:01 pm
Re: Initrd Explanation and Setup
The UEFI loader for my OS stores core system modules on the EFI system partition. Some key modules are hardcoded, and an INI file states what drivers to load from the filesystem. Primitive, but functional, it avoids the need for an initrd.BigBuda wrote:I have the masochistic tendency to customize the kernel in every Linux installation I do on my own computers so that I don't need neither Grub (by getting the UEFI to directly boot the kernel, but I still add a Grub entry to the UEFI for emergency purposes) nor an initrd, by recompiling the kernel with all the specific modules for my system. It does shave a few seconds off boot time.sounds wrote:Linux used to not need an initial ramdisk. (Technically you can still boot without one.) So it's interesting to think about what happens immediately after the kernel is done and has handed off control to the first process, typically named "init" but really it's whatever the kernel has been given.
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
https://github.com/ChaiSoft/ChaiOS