Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why compressed kernel image is used in linux? [closed]

I have googled this question over the internet but couldn't find anything useful related to this question that "why compressed kernel image like bzImage or vmlinuz is used as initial kernel image",

Possible solutions which i could think of are:

Due to memory constraint?

But initially compressed kernel image is located at hard disk or some other storage media and during boot up time after second stage bootloader, kernel is first decompressed in main memory and then it is executed.

So, when at later stage kernel is to be decompressed in main memory then what is the need to compress it first. I mean if main memory could hold decompressed kernel image then what is the need for kernel compression?

like image 540
user2311046 Avatar asked Sep 27 '13 16:09

user2311046


People also ask

Why is Linux kernel compressed?

This is done for two major reasons: It saves space on the flash memory or other storage media holding the kernel, and memory is money. For example for the Gemini platform that I work on, the vmlinux uncompressed kernel is 11.8 MB while the compressed zImage is a mere 4.8 MB, we save more than 50%

How is Linux kernel compressed?

Compression. Traditionally, when creating a bootable kernel image, the kernel is also compressed using gzip, or, since Linux 2.6. 30, using LZMA or bzip2, which requires a very small decompression stub to be included in the resulting image.

What would happen if the kernel file gets deleted?

You will remove the name in the filesystem, that's all. Any open descriptors will remain valid until the last one is closed, the original file will stay intact as-is for any observer who obtained a handle earlier, and it will be "gone" for everyone trying to get at it later.

What is difference between uImage and zImage?

zImage: a compressed version of the Linux kernel image that is self-extracting. uImage: an image file that has a U-Boot wrapper (installed by the mkimage utility) that includes the OS type and loader information. A very common practice (e.g. the typical Linux kernel Makefile) is to use a zImage file.


1 Answers

Generally the processor can decompress faster than the I/O system can read. By having less for the I/O system to read, you reduce the time needed for boot.

This assumption doesn't hold for all hardware combinations, of course. But it frequently does.

An additional benefit for embedded systems is that the kernel image takes up less space on the non-volatile storage, which may allow using a smaller (and cheaper) flash chip. Many of these systems have ~ 32MB of system RAM and only ~ 4MB of flash.

like image 195
Ben Voigt Avatar answered Oct 06 '22 00:10

Ben Voigt