On Mon, Sep 4, 2023 at 1:59 PM Theodore Ts'o <tytso@mit.edu> wrote:
On Mon, Sep 04, 2023 at 11:20:31AM -0600, Warner Losh wrote:
>
> Yea, it was an effort to move mounting of root out of the
> kernel. The earliest scripts just mounted the right disk and moved
> on, and didn't load any new drivers: they just had the logic to pick
> the desired root. But at the same time, there were a lot of people
> that were running on 4MB and 8MB systems that noticed they could put
> all the router software in the initramfs and never pivot to
> something else and they could have quite the product with that. And
> those were the first few bricks that paved the road to hell :)

The other reason why you might need something like an initial ramdisk
is if you don't yet *have* a root file system on the hardware, and you
are trying to install a system using TFTP boot.  At that point, you
have three choices:

(a) Use a NFS root

(b) Use a read-only network block device (for example, MIT Project
Athena had a read-only Remote Virtual Disk which was a network block
device that was used to provide a read-only system image used for
installation and update, as well as a read-only /usr image).

(c) Use a built-in ramdisk.  (And here's not just Linus which has
adopted this strategy; OpenBSD's installer does this as well.)

Yes. FreeBSD did this originally, and some installers still do that.
 
The other dynamic at play was that ramdisks were needed when you were
installing on a 386 PC with, say, 16 megs of memory, a 320 megabyte
hard disk, and a *single* 1.44MB floppy --- and no ethernet, because
this was for the home PC user, so the best that you had might be a
38kbps dialup link with PPP --- if you were lucky.

So putting the kernel on the first floppy disk, and putting a ramdisk
image on the second floppy disk, so you could then eject the floppy
disk and insert subsequent floppy disks so you could install rest of
the installation binaries (including the shell utilities, the C
compiler, X windows systems, etc.) and then reboot onto the HDD with a
fully set up system, was a pretty natural evolution.

Yes. FreeBSD 2.0 definitely did that, and I think FreeBSD 1.0 as well.
 
And since we had the ramdisk infrastructure, and most users didn't
want to configure their own kernel as part of the installation
process, that begat kernel modules and the initial ramdisk being used
to store the kernel modules.  In the very early days, this made Linux
*far* more user friendly for non-system programmers to install,
compared to say, FreeBSD during that era, which was still stuck in the
BSD 4.x days of a generic kernel, followed by a kernel configuration
step, etc.

GENERIC worked fine in the early days: it was small enough that the savings
from removing all the extra devices was small... but that's because the number
of devices supported was also relatively small. By the time it became an issue
FreeBSD did have dynamic loading of drivers, but retained the GENERIC
kernel for install (it should have gone to a minimal kernel, but hasn't yet
completed the migration: the savings wasn't big enough due to Moore's
Law growing machine memories faster than the kernel grew: FreeBSD's kernel
only doubled every 2 years...).

But yea, it was a bit of a kludge. And FreeBSD grew the ability to configure
the morass of ISA devices in the boot loader early on so you could at least
boot the generic kernel, and have the loader remember your choices.
 
These days, given that some enterprise setups what their servers to be
installed from a Fibre Channel Storage Area Network, or iSCSI, perhaps
using Kerberos to authenticate to the iSCSI target, it makes
absolutely a huge amount of sense to have an initial ramdisk as an
option.  That being said, for a long time, the initial ramdisk was an
*option*.  You didn't have to use it, if you were willing to have a
custom kernel and you are using a device which has a fixed and stable
boot-time enumeration.

Yea. FreeBSD can use it to this day (and many interesting use cases
use it), but generally the loader tells the kernel what root filesystem to
use. These smarts in the boot loader have also kept the pressure of the
vast majority of cases where initramfs makes sense in Linux land.
 
This tended to only be used by people who knew what they were doing,
but for example, my file system test appliance VM system doesn't use
an initial ramdisk at all.  It uses qemu, and has a built-in kernel
configuration and build system, and this works perfectly fine booting
into the latest Debian stable distribution, with no initial ramdisk
used at all:

https://github.com/tytso/xfstests-bld/blob/master/Documentation/kvm-quickstart.md

Ah, cool. Every single distro I've run in the past has had an initramfs. I thought
it had become no longer an option...

I do similar things for my VM setup with FreeBSD :)

Warner