]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Add lzo, lz4 compression and read INITRD_COMPRESS
authorP J P <ppandit@redhat.com>
Fri, 11 Oct 2013 13:56:51 +0000 (19:26 +0530)
committerHarald Hoyer <harald@redhat.com>
Mon, 14 Oct 2013 07:38:06 +0000 (09:38 +0200)
This patch adds support for lzop(1) & lz4(1) compression
algorithms to compress iniramfs image file. Both are supported
by the Linux kernel.

Linux kernel exports user's choice of initramfs compression
algorithm as a shell environment variable: INITRD_COMPRESS.
This patch adds support to read this variable and duly compress
the initramfs image file.

Environment variable INITRD_COMPRESS has less precedence than the
command line options --gzip, etc. Ie. command line options could
override the compression algorithm defined by $INITRD_COMPRESS.

Signed-off-by: P J P <ppandit@redhat.com>
[Edited-by: Harald Hoyer: add documentation about lzo and lz4]

dracut.8.asc
dracut.sh

index 584514c0349f131438623062a0f41c13c9ed77ca..2ea6744712512699228073e336e6ed143bdc7a61 100644 (file)
@@ -365,6 +365,22 @@ Make sure your kernel has xz decompression support compiled in, otherwise you
 will not be able to boot. Equivalent to "lzma --compress=xz --check=crc32 --lzma2=dict=1MiB"
 ====
 
+**--lzo**::
+    Compress the generated initramfs using lzop.
+[WARNING]
+====
+Make sure your kernel has lzo decompression support compiled in, otherwise you
+will not be able to boot.
+====
+
+**--lz4**::
+    Compress the generated initramfs using lz4.
+[WARNING]
+====
+Make sure your kernel has lz4 decompression support compiled in, otherwise you
+will not be able to boot.
+====
+
 **--compress** _<compressor>_::
     Compress the generated initramfs using the passed compression program. If
     you pass it just the name of a compression program, it will call that
index d9533dd010724da2ee8cbf8ec04254c4c1ff277e..173a259a73bc17a0c077ee11aa27ebc4cae0c275 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -165,6 +165,12 @@ Creates initial ramdisk images for preloading modules
   --xz                  Compress the generated initramfs using xz.
                          Make sure that your kernel has xz support compiled
                          in, otherwise you will not be able to boot.
+  --lzo                  Compress the generated initramfs using lzop.
+                         Make sure that your kernel has lzo support compiled
+                         in, otherwise you will not be able to boot.
+  --lz4                  Compress the generated initramfs using lz4.
+                         Make sure that your kernel has lz4 support compiled
+                         in, otherwise you will not be able to boot.
   --compress [COMPRESSION] Compress the generated initramfs with the
                          passed compression program.  Make sure your kernel
                          knows how to decompress the generated initramfs,
@@ -342,6 +348,8 @@ TEMP=$(unset POSIXLY_CORRECT; getopt \
     --long bzip2 \
     --long lzma \
     --long xz \
+    --long lzo \
+    --long lz4 \
     --long no-compress \
     --long gzip \
     --long list-modules \
@@ -430,6 +438,8 @@ while :; do
         --bzip2)       compress_l="bzip2";;
         --lzma)        compress_l="lzma";;
         --xz)          compress_l="xz";;
+        --lzo)         compress_l="lzo";;
+        --lz4)         compress_l="lz4";;
         --no-compress) _no_compress_l="cat";;
         --gzip)        compress_l="gzip";;
         --list-modules) do_list="yes";;
@@ -673,6 +683,7 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
 [[ $fw_dir ]] || fw_dir="/lib/firmware/updates /lib/firmware"
 [[ $tmpdir_l ]] && tmpdir="$tmpdir_l"
 [[ $tmpdir ]] || tmpdir=/var/tmp
+[[ $INITRD_COMPRESS ]] && compress=$INITRD_COMPRESS
 [[ $compress_l ]] && compress=$compress_l
 [[ $show_modules_l ]] && show_modules=$show_modules_l
 [[ $nofscks_l ]] && nofscks="yes"
@@ -689,6 +700,8 @@ case $compress in
     lzma)  compress="lzma -9";;
     xz)    compress="xz --check=crc32 --lzma2=dict=1MiB";;
     gzip)  compress="gzip -9"; command -v pigz > /dev/null 2>&1 && compress="pigz -9";;
+    lzo)   compress="lzop -9";;
+    lz4)   compress="lz4 -9";;
 esac
 if [[ $_no_compress_l = "cat" ]]; then
     compress="cat"