The question is pretty much summed up by the title - I've just built a kernel which has generated the vmlinux output file. How do I compress this into a vmlinuz image?
Compression is a compile-time option.
The process is quite tricky, as the resulting file will start with native code that decompresses the rest of the kernel and jumps there.
So there's no straightforward way, and nobody ever spent the time to implement recompression (at least as far as I know) as it's simple enough to recompile.
In conclusion, you'll have to use
According to the documentation you need to execute:
cp bzImage vmlinuz
to create the
From the Wikipedia article on vmlinux :
Traditionally, when creating a bootable kernel image, the kernel is also compressed using the zlib algorithm, or since Linux 2.6.30 using LZMA or BZIP2, which requires a very small decompression stub to be included in the resulting image. The stub decompresses the kernel code, on some systems printing dots to the console to indicate progress, and then continues the boot process.
The decompression routine is a negligible factor in boot time, and prior to the development of the bzImage, the size constraints of some architectures, notably i386, were extremely limiting, making compression a necessity.
On the SPARC architecture, the vmlinux file is compressed using simple gzip, because the SILO boot loader transparently decompresses gzipped images.
The filename of the bootable image is not important, but by convention it is called vmlinuz or zImage.
So depending on which architecture you are running on, and which Linux version, the answer will vary.
The best way is to let the kernel build process compress it for you.