0

Why and how is the Linux kernel image compressed? Isn't it pointless to compress it, when the image is and must be (as far as I know) uncompressed in RAM? How can it even be compressed? How can the CPU execute it when instead of binary machine instructions there is a compressed mess in memory?

Another thing, why is a compressed image faster than an uncompressed one? I read/understood something like this, is it true or not?

2
  • Mostly a duplicate of your earlier question. Only additional question is about keeping a compressed image in memory but this is not done - the kernel is uncompressed when booted. Commented Nov 28, 2022 at 15:56
  • 1
    Oops, the title really implies this, but there is a difference. Another one was like "why [allegedly] the kernel should be compressed and this webpage is wrong, right?" while this one is "what is the purpose of kernel packing, benefits and how is it technically possible". Commented Nov 28, 2022 at 16:07

1 Answer 1

1

The kernel image is compressed to workaround restrictions in some architectures, i386 for example.

Specifically making the kernel fit into the amount of memory available during early boot.

These days, such things are not "needed" (due to UEFI and 64 bit addressing) but, yes you are correct, they can increase the speed of booting. My compressed kernel image is around 11MB and uncompressed it would be much larger (possibly even 20MB+) and would take longer to load. Decompression is faster than drive speed, generally. However even that is less true today with PCIe 4.0 NVME drives.

Some more details that answer both of your questions are available here

As for the how, the kernel can use many different compression algorithms, good old gzip is one, but it also supports XZ, LZ4, and Zstd. There are probably more, but that's the list of the top of my head.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.