Decompressing vmlinuz kernel image

I want to learn that why I can not decompress compressed kernel image made with make bzImage. If we look at the vmlinuz with file, it gives following output:

$ file vmlinuz-4.0.0-1-amd64
vmlinuz-4.0.0-1-amd64: Linux kernel x86 boot executable bzImage, version 4.0.0-1-amd64 
([email protected]) #1 SMP Debian 4., RO-rootFS, swap_dev 0x3, Normal VGA

It seems it is not a regular bzip2 compressed file.

It is one of the most misunderstood things about kernel image.

The name bzImage not related with bzip algorithm, bzImage is a shorten form of big zimage.

A big zimage file consist of bootsect.o, setup.o, misc.o and piggy.o files. The original vmlinux kernel image compressed in piggy.o file.

Until the kernel version 2.6.30 only gzip algorithm can be used within big zimage file. After that new compression algorithms support added. Now you can select one of the algorithm from gzip, lzma, xz, lzo, lz4 and bzip2. So, you can choose bzip2 as compression method but it defines just the format of piggy.o file, not the bzImage file, it is more than this.

If you want to decompress kernel part from a bzImage file, you can use extract-vmlinux script which comes with kernel source code under scripts/ folder.