public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] Export initial ramdisk compression config
@ 2013-09-15  9:19 P J P
  2013-09-23 19:52 ` Andrew Morton
  0 siblings, 1 reply; 11+ messages in thread
From: P J P @ 2013-09-15  9:19 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1137 bytes --]

   Hello,

While building the 3.11 kernel recently, I bumped into this issue.

Menuconfig allows one to choose compression format of an initial ramdisk 
image. But this selection does not result in creation of a duly compressed 
initramfs image. Because - $ make install - does not pass on the selected 
compression option to dracut(8) tool, which generates the initramfs file. This 
leads to a situation wherein the initramfs file is gzip(1) compressed, but the 
kernel knows only to decompress the user's chosen compression format.

The attached patch herein, attempts to fix this issue by exporting the 
compression configuration option to an environment variable of a sub-shell 
spawned by Make(1) with the invocation of installkernel(8) during the 
installation process.

The dracut(8) & new-kernel-pkg(8) tools need to be patched to recognise and 
read such an environment variable and use the selected compression algorithm 
while creating the initial ramdisk image files.

Could someone please review this one too?

Thank you.
--
Prasad J Pandit / Red Hat Security Response Team
DB7A 84C5 D3F9 7CD1 B5EB  C939 D048 7860 3655 602B

[-- Attachment #2: Type: TEXT/PLAIN, Size: 2507 bytes --]

From 88878c7dfb04e69b75f1518fe809b917095a33b8 Mon Sep 17 00:00:00 2001
From: P J P <prasad@redhat.com>
Date: Sun, 15 Sep 2013 13:37:43 +0530
Subject: [PATCH 2/2] Export initial ramdisk compression config option

Make menuconfig allows one to choose compression format of an
initial ramdisk image. But this choice does not result in duly
compressed ramdisk image. Because - $ make install - does not
pass on the selected compression choice to the dracut(8) tool,
which creates the initramfs file. dracut(8) generates the image
with the default compression, ie. gzip(1).

This patch exports the selected compression option to a sub-shell
environment, so that it could be used by dracut(8) tool to generate
appropriately compressed initramfs images.

There isn't a straight forward way to pass on options to dracut(8)
via positional parameters. Because it is indirectly invoked at the
end of a $ make install sequence.

 # make install
   -> arch/$arch/boot/Makefile
    -> arch/$arch/boot/install.sh
     -> /sbing/installkernel ...
      -> /sbin/new-kernel-pkg ...
       -> /sbin/dracut ...

Signed-off-by: P J P <prasad@redhat.com>

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 41250fb..9f4cdf1d 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -11,6 +11,23 @@ else
         KBUILD_DEFCONFIG := $(ARCH)_defconfig
 endif
 
+# Select initial ramdisk compression format, default is gzip(1).
+# This shall be used by the dracut(8) tool while creating an initramfs image.
+#
+INITRD_COMPRESS=gzip
+ifeq ($(CONFIG_RD_BZIP2), y)
+        INITRD_COMPRESS=bzip2
+else ifeq ($(CONFIG_RD_LZMA), y)
+        INITRD_COMPRESS=lzma
+else ifeq ($(CONFIG_RD_XZ), y)
+        INITRD_COMPRESS=xz
+else ifeq ($(CONFIG_RD_LZO), y)
+        INITRD_COMPRESS=lzo
+else ifeq ($(CONFIG_RD_LZ4), y)
+        INITRD_COMPRESS=lz4
+endif
+export INITRD_COMPRESS
+
 # BITS is used as extension for files which are available in a 32 bit
 # and a 64 bit version to simplify shared Makefiles.
 # e.g.: obj-y += foo_$(BITS).o
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 76faec1..b3d6c38 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -57,6 +57,11 @@ static int __init crd_load(int in_fd, int out_fd, decompress_fn deco);
  *	cramfs
  *	squashfs
  *	gzip
+ *	bzip2
+ *	lzma
+ *	xz
+ *	lzo
+ *	lz4
  */
 static int __init
 identify_ramdisk_image(int fd, int start_block, decompress_fn *decompressor)
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-10-10 15:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-15  9:19 [PATCH 2/2] Export initial ramdisk compression config P J P
2013-09-23 19:52 ` Andrew Morton
2013-09-24 19:41   ` P J P
2013-09-25 16:56     ` Rob Landley
2013-09-26  7:30       ` P J P
2013-10-09 21:48     ` Andrew Morton
2013-10-10  7:05       ` P J P
2013-10-10 14:43       ` P J P
2013-10-10 15:14       ` P J P
2013-09-30 21:41   ` P J P
2013-10-05 20:43   ` P J P

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox