4 ms·
Though I take your point and mostly agree, is there any reason this couldn't be done with a static boot binary entirely in RAM? Since the kernel is modular anyw
by drvdevd 10y ago
Though I take your point and mostly agree, is there any reason this couldn't be done with a static boot binary entirely in RAM? Since the kernel is modular anyway, much of the special purpose cruft loaded by the initramfs could just be loaded and unloaded with a boot script of some kind right? I mean: it could all sit on the same filesystem without having a CPIO image on disk? Grub supports pretty much every filesystem already so loading this initial kernel image from the network or wherever could just start there.
- dfox 10y agoMounting root file system might nowadays conceivably involve some non-trivial userspace code that never even was implemented in kernel space. Few examples: - Searching for root filesystem based on it's contents (in simple case UUID, but mechanisms like "contains this file" are used sometimes) instead of "physical" location - Encrypted root filesystem (requires some kind of UI for entering the passphrase) - LVM2 (which is set of userspace utilities that configure more general kernel modules that know nothing about the actual on-disk format) - while there is slightly hackish kernel support for configuring network interfaces before having userspace and mounting rootfs from NFS, such thing cannot possibly deal with all variants of network configuration (eg. VLANs, 802.1x, ...) and possible network filesystems/block devices. - root on ramdisk, copy-on-write overlay filesystem or something like that. To summarize: it's entirely possible to have the system boot of PXE, authenticate via WPA-EAP on wifi and fetch it's own root filesystem into ramdisk via HTTPS while storing writes onto NFS somewhere. Implementing all which is required for that in kernel space is neither possible nor useful. By the way, the point of initramfs is that it is loaded into memory by bootloader using whatever means the bootloader has and the image does not have to be on rootfs accessible to kernel (for PXE it typically isn't).
- drvdevd 10y agoOk. That's a great summary and good point about non-trivial userspace bits. I hadn't considered how complex "booting" as a process has become...
- Sir_Cmpwn 10y agoMost initramfs designs are based on shell scripts and use tools like `mount -t ext4`, cryptsetup, etc - normal userspace tools, tied together by shell scripts. What you're suggesting is actually more special purpose than what we already have. Modern initramfs design is really great and not crufty at all.
- IshKebab 10y agoWait are you suggesting that something tied together with shell scripts is great?
- Sir_Cmpwn 10y agoOh yes. Bash is definitely not a good general purpose programming langauge, hell I'd hesitate to even call it a programming language. However, it's very much so the right tool for the job in an initramfs. How familiar are you with the early boot process on a modern Linux distro? Ever had to do it manually from an initramfs rescue shell? Well, if not, it basically just involes invoking a bunch of commands and minimal parsing. Most early boot configs like /etc/fstab are easily readable with awk and are well suited to handling with shell scripts. All you basically have is a stripped down userspace with coreutils plus the commands necessary to prepare the system for the full boot. Shell scripts are the natural choice for tying it all together. I actually really like bash in general, in the niches it's suited for it's very nice.