I really don't pay much attention to the development of Linux kernel. I took the time to differentiate the concepts of initrd and initramfs early this morning. I finally got a little eye off and did not dare to enjoy it exclusively.
We all know that Linux has the concept of a RAM disk. It has been around for a long time, at least 2.4 of the time, and I don't know it any longer. So initrd, like his name, initial RAM disk, is very understandable, just for root FS.
Initramfs is nothing more than its name, initial RAM file system. This concept was introduced only after 2.6, and is now the mainstream. That is to say, initrd is outdated and nobody can use it. This is a thing in the "fashion" field. You must understand it, at least this fashion trend.
This situation of initramfs defeating initrd's replacement is inevitable, because there is a reason that initramfs is much more advanced than initrd. At the same time, to maintain compatibility, even if the kernel enables both initrd and initramfs, the kernel can automatically determine the format and content of the archive file and automatically process it well.
Both of them produce archive files, which are called ramdisk.cpio.gz, but the content and production process are quite different.
First look at the advanced initramfs, just a command
(Cd "$1"; find. | cpio-o-h NEWC | gzip)> "$2"
But for initrd, steps 8 and 9 are at least because it involves loopback device and ext2 File System (at the same time, the initrd creation process does not use cpio ), I will not detail it here.
From the production process, we can see a little problem. Initrd emphasizes the last disk, and initramfs emphasizes file system. However, the disk also needs to be mounted, and the file system is still involved during the mount, while initramfs directly skips the disk, which is file system, this is the most direct reason why initramfs is more advanced than initrd.
Because initrd is a disk, You need to loop back the device during creation, format it as a file system, and mount it to your host system, copy the required file.
Initramfs is directly file system, which can be done with a cpio.
Of course, from a professional perspective, you can go to the official website. They will tell you that initramfs avoids the replication from memory to disk cache, and does not occupy fixed memory.
However, I think it is enough to view my documents.