1

My understanding is that the initrd/initramfs set up a file system in the RAM to help the kernel initialization. I have got following doubts;

(1) Is the initrd/initramfs is setup by bootloader(eg: GRUB 2)?

(2) Does this initrd/initramfs setting up happen before Page table initialization by kernel?

(3) Is this temporary? What will happen to this file system after the successful initialization of the kernel?

2 Answers 2

1

(1) In an initramfs, usually, kernel and initial file system exist in the same file. so if the bootloader has to know where the kernel file is, it also knows where the initramfs is. And vice-versa. If the initramfs is a separate file, then it must be referenced by the bootloader and passed on to the kernel as a parameter;

The bootloader passes control to the kernel, which at the end of initialising all it needs to prepare, extracts initramfs and passes control to init (within the initramfs).

(2) initramfs is extracted after the kernel prepares the virtual memory subsystem fully;

(3) normally after initramfs does its job (which is to mount the system's root file system), a set of delicate steps are taken to "move" to the newly mounted root file system and the contents of initramfs are deleted from RAM (explicitly by running 'rm');

I suggest reading this: https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt

1

The initrd is set up by a userspace program and copied as one file (in cpio format) to the disk. The bootloader is told about the file in its configuration, copies the file to RAM (without further setup) and tells the kernel the RAM address.

The kernel sets up its RAM disk and uncompresses the initrd into it. If you want to call that setup... I do not know the time relation to the creation of page tables but as the kernel starts a userland process from the initrd for which it needs page tables I guess that has already happened then.

This RAM disk is used as / filesystem until the real root FS is mounted and PID 1 makes a chroot to it.

I do not know whether this RAM disk is kept (with all its contents) until shutdown for the chroot out of the root FS for unmounting it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .