Sean’s Obsessions

Sean Walberg’s blog

Make bzImage vs Make zImage

What’s the difference between the bzImage and zImage targets when compiling a kernel?

If you said that the former used bzip2 compression while the latter used gzip, then read on for the real reason.

I ran into this one a few years ago when I was digging into RPM and some custom kernels. A couple of years later I noticed a column that made mention of the compression angle. (Note that this is otherwise a superb column, and was probably the largest influence on my writing over the past few years… I was deeply saddened when the magazine went under). I’m also currently looking through some LPI material that mentions the same reasoning, and have heard that it may even appear on the exam the wrong way!

I then asked a coworker who has a brilliant Linux mind, and he got it wrong, too.

So, let’s stop the bzImage == bzip2 compression myth! :)

Take a look at
/usr/src/linux-2.4/arch/i386/boot/setup.S:

# Now we move the system to its rightful place ... but we check if we have a
# big-kernel. In that case we *must* not move it ...
testb $LOADED_HIGH, %cs:loadflags
jz do_move0 # .. then we have a normal low
# loaded zImage
# .. or else we have a high
# loaded bzImage
jmp end_move # ... and we skip moving

Basically, a “b” kernel is loaded into high memory, a regular kernel into low memory. All compressed kernels are compressed with gzip -9.

This document provides some eye watering detail on the whole bootup process. Or just take it from me, a bz kernel is a “big” kernel, and gets loaded into high memory.

Comments

I’m trying something new here. Talk to me on Twitter with the button above, please.