3 ms·
What this article fails to mention is that having an initramfs is not required. It's only necessary if additional tools are needed to mount a particular filesys
by herpderperator 8y ago
What this article fails to mention is that having an initramfs is not required. It's only necessary if additional tools are needed to mount a particular filesystem, otherwise the kernel can run init directly from the root.
- textmode 8y agoTrue or false: An initrd (cf. initramfs) is still required, where "rd" stands for ramdisk. As a BSD user, I prefer to use a mfs root (ramdisk) for personal reasons, but AFAIK BSD has never required a ramdisk in order to boot. If I recall correctly Linux needed to use a ramdisk in its early days. Is this still true today?
- jschwartzi 8y agoNo, neither are required. initrd is obsolete and has been replaced by initramfs.
- kijiki 8y agoEarly on, Linux supported initrd, which was just a ramdisk with a FS image written to it and mounted. Later, initramfs came along, which is all anyone uses anymore. It is a cpio archive that is extracted onto a special form of tmpfs. One neat trick is that you can append multiple cpio archives, and the kernel will expand them one after another, so you can easily customize your distro-provided initramfs. Only the first one can be compressed, and you have to be careful about it getting overwritten by a kernel update, but it is handy for quick experiments. There is also pivot_root and switch_root, which have man pages if you're interested in the gory details. For all of initrd/initramfs's history, you've only needed one if your monolithic kernel couldn't mount the root filesystem. So if you needed a module, or had some special config that needed to happen that the kernel couldn't do internally.
- ajross 8y agoLinux has never needed a ramdisk. If it's built with drivers for the boot device and it probes in an unambiguous manner, you can pass root=/dev/whatever99. That's as true today as it was in 1992.
- deleted 8y ago[deleted]
- checkyoursudo 8y agoI pass root=PARTUUID=whatever to be safe, but yes this is how I boot an efi stub kernel directly with no rd/initramfs. Just need to, for example, build the block device driver for the root disk into the kernel instead of a module.
- exDM69 8y agoAn initramfs image is not required if you can mount root directly and don't have any drivers or firmware that need to be up before the real init. Some of these can also be bundled in the kernel image, but an initramfs makes things so much more flexible.
- textmode 8y agoIt is not necessary, but it is enabled by default. False?
- isostatic 8y agoI think that was the way for Linux when I were a lad - everything could be compiled into tw kernel to the point the normal / partition could be mounted. Assuming it was under 2gb? Is it still the case, with UEFI and systemd and other modern things that the damn kids do nowadays?
- jschwartzi 8y agoYes. I have a systemd-based embedded system that uses initramfs so that I can execute some things out of RAM when I need to erase the root filesystem. The old mechanism was initrd which was an ext2 filesystem that was baked into the kernel. The new system, initramfs uses a CPIO archive instead. But it's basically the same idea.
- voltagex_ 8y agoDoes anyone know why CPIO is used in particular? The commands for dealing with those archives are particularly arcane.
- JdeBP 8y agoFor dealing with cpio archives, just use pax. * http://netbsd.gw.com/cgi-bin/man-cgi?pax http://netbsd.gw.com/cgi-bin/man-cgi?pax * https://manpages.debian.org/unstable/pax/pax.1.en.html https://manpages.debian.org/unstable/pax/pax.1.en.html * http://pubs.opengroup.org/onlinepubs/9699919799/ http://pubs.opengroup.org/onlinepubs/9699919799/ The answer to Why? is given in the kernel doco itself, in Documentation/filesystems/ramfs-rootfs-initramfs.txt .
- vetinari 8y agoBecause it is simple, much simpler than tar, and has an universally agreed serialization format, without variants, unlike tar.