Why Linux requires 4MB of RAM no matter of kernel size?
Hi
I have old 386SX with 2MB of ram hanging around and I wonder:
- Why Linux requires 4MB of RAM no matter of kernel size?
- Why prior to Linux 1.3(?) I was able to use Linux with just 2MB of RAM (Slackware 2.1)
- Is it possible to modify "modern" kernel(let's say 2.4) (apart from lack of support for 386 anymore) to remove such artificial limit?
6 comments
[ 2.6 ms ] story [ 26.6 ms ] threadThe file size of the kernel will get bigger over time as more drivers are added for newer hardware. Only the drivers required for your hardware get loaded and thus the memory usage is independent of the kernels file size. If you custom build your kernel, you can strip out all of the drivers not required for your hardware if you had a need to do so. A legit need would be IoT devices that have limited persistent storage. Another use case would be if you were bored and wanted a learning exercise on building kernels or wanted to harden your kernel against specific threats or to add support for hardware without requiring a dynamically loaded module.
If you would like to get back towards a lower usage, some things you could potentially tinker with would be blacklisting drivers you do not need loaded and adjusting sysctl settings, pam limits, systemd unit file limits (does not apply to your 2.4 kernel) for more conservative memory limits based on your needs. Adjusting these things too low can cause problems or performance issues. Use care when blacklisting modules, as some modules depend on other modules and it is not always obvious why. The output of lsmod will show you some examples of the dependencies.
I'm asking about the artificial HARDCODED limit despite the size of kernel or modules. This is hardcoded at boot process - no matter how big or small your kernel is.
For example my 1.1 bare-bones uncompressed kernel [just basic modules] can work at 2MB of RAM, at size of ~700kb.
Almost the same uncompressed bare-bone kernel [just basic modules] from let's say 2.4 line requires 4MB of RAM - despite very similar size (~780kb).
My question is:
- Why there is such artificial and hard-coded limit in kernel source code?
- Why it was changed from 2MB to 4MB?
- Is it possible to change it back? In kernel source this is literally just simple "if ram < 4MB then error" - without any real kernel size check.
You could also change back to 2mb and see what explodes :)