[Patch] to add support for lzop(1), lz4(1) & INITRD_COMPRESS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



  Hello,

Attached herein is a patch for the dracut(8) tool. It adds support for the lzop(1) & lz4(1) compression algorithms for creating initramfs images. Both algorithms are supported by the Linux kernel.

Linux kernel also exports user's choice of initramfs compression algorithm to a shell environment variable: INITRD_COMPRESS.

 -> http://www.spinics.net/lists/mm-commits/msg100054.html

The attached patch recognises this variable, but sets it at lower precedence than the command line options. Ie. dracut(8) command line options --gzip, --bzip2 etc. would override the compression algorithm defined by the $INITRD_COMPRESS environment variable.

Could someone please review this patch?

Thank you.
--
Prasad J Pandit / Red Hat Security Response Team
From 7e4cb9c5440c37b3d66c8144e884d005d96f49a5 Mon Sep 17 00:00:00 2001
From: P J P <ppandit@xxxxxxxxxx>
Date: Fri, 11 Oct 2013 19:26:51 +0530
Subject: Add lzo, lz4 compression and read INITRD_COMPRESS

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@xxxxxxxxxx>

diff --git a/dracut.sh b/dracut.sh
index d9533dd..173a259 100755
--- 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"
-- 
1.8.3.1


[Index of Archives]     [Linux Kernel]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux