From 38c90c536d96982ada4017d00da3878f87e7300e Mon Sep 17 00:00:00 2001 From: bert schulze Date: Sun, 28 Feb 2010 20:15:47 +0100 Subject: initramfs-tools: support different compression tools in mkinitramfs this version uses /etc/initramfs-tools/initramfs.conf to determine the compression method, checks kernel and userspace support with fallback to gzip. Since LZO didnt work for me at all with 2.6.33 I left that out for now. (closes: #533903) [ minor changes in mkinitramfs code ] Signed-off-by: maximilian attems --- conf/initramfs.conf | 6 ++++++ initramfs.conf.5 | 9 ++++++++- mkinitramfs | 16 +++++++++++++++- mkinitramfs.8 | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/conf/initramfs.conf b/conf/initramfs.conf index 23dd249..18c6c7e 100644 --- a/conf/initramfs.conf +++ b/conf/initramfs.conf @@ -35,6 +35,12 @@ BUSYBOX=y KEYMAP=n +# +# COMPRESS: [ gzip | bzip2 | lzma ] +# + +COMPRESS=gzip + # # NFS Section of the config. # diff --git a/initramfs.conf.5 b/initramfs.conf.5 index 984d1a2..4d8ef89 100644 --- a/initramfs.conf.5 +++ b/initramfs.conf.5 @@ -1,4 +1,4 @@ -.TH INITRAMFS.CONF 5 "2010/03/25" "Linux" "initramfs.conf manual" +.TH INITRAMFS.CONF 5 "2010/04/04" "Linux" "initramfs.conf manual" .SH NAME initramfs.conf \- configuration file for mkinitramfs @@ -48,6 +48,13 @@ The keymap will anyway be loaded by the initscripts later, and the packages that might need input will normally set this variable automatically, so there should normally be no need to set this. +.TP +\fB COMPRESS +Specifies the compression method used for the initramfs image. +.B mkinitramfs +will default to gzip if the kernel lacks support (CONFIG_RD) or the +corresponding userspace utility is not present. + .TP \fB UMASK Set the umask value of the generated initramfs file. diff --git a/mkinitramfs b/mkinitramfs index 877dfb4..33ef99b 100755 --- a/mkinitramfs +++ b/mkinitramfs @@ -123,6 +123,20 @@ case "${version}" in ;; esac +# Check userspace and kernel support for compressed initramfs images +compress=${COMPRESS} +if command -v ${compress} >/dev/null 2>&1; then + compress=gzip + [ "${verbose}" = y ] && \ + echo "No ${COMPRESS} in ${PATH}, using gzip" +fi + +if ! `grep -q -i config_rd_${COMPRESS}=y /boot/config-${version}` ; then + compress=gzip + [ "${verbose}" = y ] && \ + echo "linux-2.6 misses ${COMPRESS} support, using gzip" +fi + if [ -d "${outfile}" ]; then echo "${outfile} is a directory" exit 1 @@ -273,7 +287,7 @@ eval ` find . 4>&-; echo "ec1=$?;" >&4 } | { cpio --quiet --dereference -o -H newc 4>&-; echo "ec2=$?;" >&4 - } | gzip >"${outfile}" + } | ${compress} >"${outfile}" echo "ec3=$?;" >&4 ` if [ "$ec1" -ne 0 ]; then exit "$ec1"; fi diff --git a/mkinitramfs.8 b/mkinitramfs.8 index 5d3c42b..c19697a 100644 --- a/mkinitramfs.8 +++ b/mkinitramfs.8 @@ -27,7 +27,7 @@ mkinitramfs \- low-level tool for generating an initramfs image The .B mkinitramfs script generates an initramfs image. -The initramfs is a gzipped cpio archive. The archive can be used on a +The initramfs is a compressed cpio archive. The archive can be used on a different box of the same arch with the corresponding Linux kernel. .B mkinitramfs is meant for advanced usage. On your local box -- cgit v1.2.3