4 ms·
The Linux kernel does not require an initramfs. You can build a kernel with everything compiled in; with no modules needed at all. Initramfs is used for gener
by ta8645 2y ago
The Linux kernel does not require an initramfs. You can build a kernel with everything compiled in; with no modules needed at all. Initramfs is used for generic kernels where you don't know beforehand which features will be required. This allows you to avoid wasting RAM on features you don't use. But it is optional.
- Muromec 2y agoI think the idea is, since modules map to device ids statically, bootloader could have enough information to read them from the filestem one by one. I don’t see the point of doing so however.
- jolmg 2y ago> Initramfs is used for generic kernels where you don't know beforehand which features will be required. And also for e.g. cases where you've got some custom stack of block devices that you need to set up before the root FS and other devices can be mounted. It's not just about loading kernel modules.
- drewg123 2y agoI realize that. But every distro I've used uses an initramfs, so unless you want to build your own kernels, you're stuck with it, and the painfully slow initramfs updates when you update packages, and dkms (or similar) updates the initramfs with the newer version of your out-of-tree modules.
- kbolino 2y agoGiven the reason why "out-of-tree modules" exist, there's really no way to eliminate initramfs or something like it entirely in the general case. It might be possible to speed up the process of building the image (as long as the results are not "redistributed"), but this is a licensing and legal problem, not a technical one. FreeBSD is under a much more permissive non-copyleft license and so can legally bundle things that Linux cannot.
- medstrom 2y agoYou're talking about something like ZFS, and I get that they can't just compile it in, but a distro can still ship the module, if I'm not mistaken. ...But to load it at boot time it absolutely must be done through an initramfs. Is that right?
- aaronmdjones 2y ago> But to load it at boot time it absolutely must be done through an initramfs. Is that right? Yes, because it cannot be part of the kernel image, or it would be illegal (a violation of the GPL license) to distribute that kernel. Therefore, it must be a module, and that module has to live somewhere and be loaded by something. If root is on ZFS, this must therefore live in an initramfs and be loaded by it so that the initramfs can mount the real root filesystem on the kernel's behalf.
- megous 2y agoIt doesn't have to be a module if you're building the kernel for yourself. No violation in that.
- deleted 2y ago[deleted]
- aaronmdjones 2y agoGP was talking about distribution kernels.
- anticensor 2y agoThat would run afoul of Turkish copyright vignette laws, that have an exemption for stuff everyone can use and redistribute royalty-free but no exemption for stuff that you can use royalty free but not redistribute.
- lmm 2y agoOne could have the equivalent of DKMS build the modules into the kernel image instead of building the initramfs. I don't know how much practical overhead there is to the initramfs and pivot_root dance, but it feels far uglier than it should need to be to just load some modules.
- markhahn 2y agowhy would initramfs updates be slow? do you mean that most initramfses are large? how much time are we talking about?
- nextaccountic 2y agoOn Arch Linux, mkinitcpio is slow. I don't know why is that
- linsomniac 2y agoIs anyone really wanting to get back into the business of building their own kernels? I started using Linux heavily in '92, and I've built a lot of kernels, and am quite happy to not be building them anymore.
- ssl-3 2y agoI kind of liked compiling my own kernels. I felt I was better-connected to the state of things, and it was fun to see it all evolve from the vantage point of "make menuconfig". But initramfs isn't so bad, and it allows things like ZFS root to have a modicum of smoothness and integration.
- megous 2y agoIt's easy (2-3 commands), takes like a minute on a modern machine with trimmed down kernel configuration, and you can customize the kernel to your liking (write/patch drivers, embed firmware blobs, fix things that are broken or missing). What's to hate? :) Though I only do it for my ARM based devices currently. And if you're not throwing away build artifacts after each build, then getting stable updates is just a `git pull` and incremental make, which is usually very quick.
- teo_zero 2y agoI build my own kernel. I did invest some time to select the right configuration, but now it's just a question of copying over the old .config and running "make". What's annoying about that?
- adamomada 2y agohttps://www.funtoo.org/Support_Matrix#Kernels https://www.funtoo.org/Support_Matrix#Kernels
- prmoustache 2y agokernel compilation is easily automated. I don't want to do that and like the initramfs approach mostly because I like the fact I can take a hard drive out of a computer and boot the system on another one in case of a hardware failure. That is a lot faster than recovering from a backup.
- arp242 2y agoWhat's the reason it doesn't load those modules from the regular filesystem? That's what FreeBSD does, and seems to work well enough?
- ta8645 2y agoBecause there are a lot of different types of filesystems supported. And you'd have to compile them all into the kernel. Which of course you can do, that is supported by the build system today. But Distros typically prefer to keep their kernels small, and not waste the RAM that would be taken up by compiling it all into the kernel.
- mixmastamyk 2y agoIt must already have vfat and the ESP, so why not just copy a basic set of modules to a subfolder there?