From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261260AbVFLWdd (ORCPT ); Sun, 12 Jun 2005 18:33:33 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261259AbVFLWdd (ORCPT ); Sun, 12 Jun 2005 18:33:33 -0400 Received: from mail4.worldserver.net ([217.13.200.24]:5335 "EHLO mail4.worldserver.net") by vger.kernel.org with ESMTP id S261260AbVFLWbu (ORCPT ); Sun, 12 Jun 2005 18:31:50 -0400 Date: Mon, 13 Jun 2005 00:31:50 +0200 From: Christian Leber To: linux-kernel@vger.kernel.org Cc: akpm@osdl.org Subject: Re: [PATCH 2/2] lzma support: lzma compressed kernel image Message-ID: <20050612223150.GA26370@core.home> References: <20050607214128.GB2645@core.home> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050607214128.GB2645@core.home> X-Accept-Language: de en X-Location: Europe, Germany, Mannheim X-Operating-System: Debian GNU/Linux (sid) User-Agent: Mutt/1.5.9i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 07, 2005 at 11:41:28PM +0200, Christian Leber wrote: Also refined. And btw. it is together with PATCH 1/2 allready used by a rescue distribution :-) This patch is against 2.6.12-rc6. Makes it possible on i386 to select lzma compression instead of gzip compression, this is especially usefull for embedded systems or when there are special size restrictions, like a kernel on a floppy image. Other architectures aren't affected, obviously. I also want to mention that the misc_lzma.c is much cleaner than the orginal misc.c :-) The memory requirements are only a little big higher than with gzip, namely low_buffer_size or even lower when !high_loaded. Size example: -rw-r--r-- 1 ijuz ijuz 1233099 Jun 7 20:12 bzImage.gz -rw-r--r-- 1 ijuz ijuz 1041267 Jun 7 20:12 bzImage.lzma (download them from here to try them out: http://debian.christian-leber.de/kernel_lzma/) To build a kernel with lzma compression you have to go to: Executable file formats -> Kernel compression format Building the lzma tool cut and paste style: mkdir build-lzma wget http://www.7-zip.org/dl/lzma417.tar.bz2 tar xjf lzma417.tar.bz2 cd SRC/7zip/Compress/LZMA_Alone/ make cp lzma ../../../../../ cd ../../../../../ Signed-off-by: Christian Leber --- linux-2.6.12-rc6.orig/arch/i386/Kconfig 2005-06-06 17:22:29.000000000 +0200 +++ linux-2.6.12-rc6/arch/i386/Kconfig 2005-06-07 21:33:40.000000000 +0200 @@ -1236,6 +1236,34 @@ source "fs/Kconfig.binfmt" +choice + prompt "Kernel compression format" + depends on EXPERIMENTAL + default KERNEL_GZIP + +config KERNEL_GZIP + bool "Compress kernel image using gzip" + help + The linux kernel is a self-extracting executable. + + Choosing Gzip here, makes the kernel image beeing compressed + using Gzip. + + Gzip is the standard compression method for the kernel image. + If you do not know what to say, take gzip. + + +config KERNEL_LZMA + bool "Compress kernel image using lzma (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + The linux kernel is a self-extracting executable. + + Choosing lzma here, makes the kernel beeing compressed using + lzma. + +endchoice + endmenu source "drivers/Kconfig" --- linux-2.6.12-rc6.orig/arch/i386/boot/compressed/Makefile 2005-06-06 17:22:29.000000000 +0200 +++ linux-2.6.12-rc6/arch/i386/boot/compressed/Makefile 2005-06-07 22:49:31.000000000 +0200 @@ -4,22 +4,41 @@ # create a compressed vmlinux image from the original vmlinux # -targets := vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o +targets := vmlinux vmlinux.bin head.o piggy.o EXTRA_AFLAGS := -traditional LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup_32 -$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE - $(call if_changed,ld) - @: +LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T $(obj)/vmlinux.bin: vmlinux FORCE $(call if_changed,objcopy) +ifeq ($(CONFIG_KERNEL_GZIP),y) +targets += vmlinux.bin.gz misc.o + +$(obj)/vmlinux: $(obj)/head.o $(obj)/misc.o $(obj)/piggy.o FORCE + $(call if_changed,ld) + @: + $(obj)/vmlinux.bin.gz: $(obj)/vmlinux.bin FORCE $(call if_changed,gzip) -LDFLAGS_piggy.o := -r --format binary --oformat elf32-i386 -T - $(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.gz FORCE $(call if_changed,ld) +endif + +ifeq ($(CONFIG_KERNEL_LZMA),y) +targets += vmlinux.bin.lzma misc_lzma.o + +$(obj)/vmlinux: $(obj)/head.o $(obj)/misc_lzma.o $(obj)/piggy.o FORCE + $(call if_changed,ld) + @: + +$(obj)/vmlinux.bin.lzma: $(obj)/vmlinux.bin FORCE + lzma e $(obj)/vmlinux.bin $(obj)/vmlinux.bin.lzma + +$(obj)/piggy.o: $(obj)/vmlinux.scr $(obj)/vmlinux.bin.lzma FORCE + $(call if_changed,ld) +endif + --- linux-2.6.12-rc6.orig/arch/i386/boot/compressed/misc_lzma.c 1970-01-01 01:00:00.000000000 +0100 +++ linux-2.6.12-rc6/arch/i386/boot/compressed/misc_lzma.c 2005-06-12 21:03:51.000000000 +0200 @@ -0,0 +1,351 @@ +/* + * misc.c + * + * This code uses LzmaDecode.c and LzmaDecode.h to decompress the lzma + * compressed Linux kernel + * + * malloc by Hannu Savolainen 1993 and Matthias Urlichs 1994 + * puts by Nick Holloway 1993, better puts by Martin Mares 1995 + * High loaded stuff by Hans Lermen & Werner Almesberger, Feb. 1996 + * lzma decompression support by Christian Leber, June 2005 + */ + +#include +#include +#include +#include