The Linux kernel interacts with a file system while it’s running. The kernel supports a wide variety of memory storage devices where the filesystem can be stored. Most storage devices are persistent, which means they remember their state when powered off. The Linux kernel can also run in volatile memory, such as RAM. Some reasons for doing this include speed, since volatile memory is usually much faster, and the ability to modify a persistent file system while it’s not in use. The Linux kernel can be configured to run from RAM by using the initramfs feature.
When using initramfs, a filesystem image is embedded into the kernel image. When the kernel boots, it extracts the filesystem image into RAM and runs an init script from there. The init script is usually a file called ‘init’ in the root of the ramfs filesystem, but this can be overridden by setting the ‘rdinit’ variable in the Linux command line from the boot loader. Configuring the Linux kernel to use initramfs is done through the menuconfig system. The option is “Initial RAM filesystem and RAM disk” in the General Setup section. The configuration requires the filename of the filesystem image to embed in the kernel. Creating the ramfs filesystem image must be done separately from building the kernel.