Commit ab76f3d771590d5c89faa3219559c5d3fc0ce0c2

Authored by Alain Knaff
Committed by H. Peter Anvin
1 parent ab59d3b70f

bzip2/lzma: make internal initramfs compression configurable

Impact: Avoids silent environment dependency

Make builtin initramfs compression an explicit configurable.  The
previous version would pick a compression based on the binaries which
were installed on the system, which could lead to unexpected results.
It is now explicitly configured, and not having the appropriate
binaries installed on the build host is simply an error.

Signed-off-by: Alain Knaff <alain@knaff.lu>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

Showing 2 changed files with 68 additions and 12 deletions Side-by-side Diff

... ... @@ -71,4 +71,66 @@
71 71 help
72 72 Support loading of a lzma encoded initial ramdisk or cpio buffer
73 73 If unsure, say N.
  74 +
  75 +choice
  76 + prompt "Built-in initramfs compression mode"
  77 + help
  78 + This setting is only meaningful if the INITRAMFS_SOURCE is
  79 + set. It decides by which algorithm the INITRAMFS_SOURCE will
  80 + be compressed.
  81 + Several compression algorithms are available, which differ
  82 + in efficiency, compression and decompression speed.
  83 + Compression speed is only relevant when building a kernel.
  84 + Decompression speed is relevant at each boot.
  85 +
  86 + If you have any problems with bzip2 or lzma compressed
  87 + initramfs, mail me (Alain Knaff) <alain@knaff.lu>.
  88 +
  89 + High compression options are mostly useful for users who
  90 + are low on disk space (embedded systems), but for whom ram
  91 + size matters less.
  92 +
  93 + If in doubt, select 'gzip'
  94 +
  95 +config INITRAMFS_COMPRESSION_NONE
  96 + bool "None"
  97 + help
  98 + Do not compress the built-in initramfs at all. This may
  99 + sound wasteful in space, but, you should be aware that the
  100 + built-in initramfs will be compressed at a later stage
  101 + anyways along with the rest of the kernel, on those
  102 + architectures that support this.
  103 + However, not compressing the initramfs may lead to slightly
  104 + higher memory consumption during a short time at boot, while
  105 + both the cpio image and the unpacked filesystem image will
  106 + be present in memory simultaneously
  107 +
  108 +config INITRAMFS_COMPRESSION_GZIP
  109 + bool "Gzip"
  110 + depends on RD_GZIP
  111 + help
  112 + The old and tried gzip compression. Its compression ratio is
  113 + the poorest among the 3 choices; however its speed (both
  114 + compression and decompression) is the fastest.
  115 +
  116 +config INITRAMFS_COMPRESSION_BZIP2
  117 + bool "Bzip2"
  118 + depends on RD_BZIP2
  119 + help
  120 + Its compression ratio and speed is intermediate.
  121 + Decompression speed is slowest among the three. The initramfs
  122 + size is about 10% smaller with bzip2, in comparison to gzip.
  123 + Bzip2 uses a large amount of memory. For modern kernels you
  124 + will need at least 8MB RAM or more for booting.
  125 +
  126 +config INITRAMFS_COMPRESSION_LZMA
  127 + bool "LZMA"
  128 + depends on RD_LZMA
  129 + help
  130 + The most recent compression algorithm.
  131 + Its ratio is best, decompression speed is between the other
  132 + two. Compression is slowest. The initramfs size is about 33%
  133 + smaller with LZMA in comparison to gzip.
  134 +
  135 +endchoice
... ... @@ -5,24 +5,18 @@
5 5 klibcdirs:;
6 6 PHONY += klibcdirs
7 7  
8   -# Find out "preferred" ramdisk compressor. Order of preference is
9   -# 1. bzip2 efficient, and likely to be present
10   -# 2. gzip former default
11   -# 3. lzma
12   -# 4. none
13 8  
14   -# None of the above
15   -suffix_y =
  9 +# No compression
  10 +suffix_$(CONFIG_INITRAMFS_COMPRESSION_NONE) =
16 11  
17   -# Lzma, but no gzip nor bzip2
18   -suffix_$(CONFIG_RD_LZMA) = .lzma
19   -
20 12 # Gzip, but no bzip2
21   -suffix_$(CONFIG_RD_GZIP) = .gz
  13 +suffix_$(CONFIG_INITRAMFS_COMPRESSION_GZIP) = .gz
22 14  
23 15 # Bzip2
24   -suffix_$(CONFIG_RD_BZIP2) = .bz2
  16 +suffix_$(CONFIG_INITRAMFS_COMPRESSION_BZIP2) = .bz2
25 17  
  18 +# Lzma
  19 +suffix_$(CONFIG_INITRAMFS_COMPRESSION_LZMA) = .lzma
26 20  
27 21 # Generate builtin.o based on initramfs_data.o
28 22 obj-$(CONFIG_BLK_DEV_INITRD) := initramfs_data$(suffix_y).o