S
S
Stanislav Timoshko2020-09-29 23:37:12
linux
Stanislav Timoshko, 2020-09-29 23:37:12

Why do Linux boot options from initrd use the root option?

I don’t understand why the kernel is loaded with the initrd and root parameters in any bootloader. As it is written everywhere, initrd is a virtual file system that is loaded by the kernel into memory and mounted to the root at the initial boot stage. Then a script is executed there, which mounts the real root partition. As I understand it, all information about the "real" root should be in this script, then for what purpose is the root section specified in the boot parameters? This information is needed by the kernel, in fact, only when initrd is not used and the root is mounted using modules.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
CityCat4, 2020-09-30
@MooTs

for what purpose in any bootloader the kernel is loaded with the initrd and root parameters.

Try to boot to FreeBSD on non-standard hardware - you will remember what all the devils are called, because before that you need to create a kernel config with a description of the devices and rebuild the kernel according to this config, and until you do this - what will work for you.
Here is the initrd download and solves such problems. First, a certain "equipment detector" is loaded, which checks what is stuck in a wheelbarrow and loads the corresponding firewood. And only then does change root and starts executing real start scripts.

P
planc, 2020-09-30
@planc

https://wiki.gentoo.org/wiki/Initramfs/Guide/en

K
Karpion, 2020-09-30
@Karpion

To be honest, I don't understand why you have to make it so difficult at all. For mounting an initrd is no easier than mounting a disk root system, because in any case you need to mount it. And it is also unclear why the script is so - and, accordingly, its interpreter.
The command "mount read-only root partition" - can be issued from the bootloader, it will also pass all the parameters, i.e. will do the work that the mount program normally does.
Keeping two instances of the root system on disk (one for loading into RAM, one for normal operation) is not a good idea.

V
Vitsliputsli, 2020-09-30
@Vitsliputsli

It is possible not to use initrd, this is quite normal when you work on the same hardware. But, if you need to run on any hardware, then you will have to put all the modules of all possible variants of the hardware from which you need to boot into the kernel, it makes no sense to keep such a large kernel in memory, which is why an intermediate stage was created when loading, when all these modules are placed in initrd. .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question