Can the initramfs image be compressed by a method other than gzip, such as lzma?

3 Answers 3


Yes. I use in-kernel initrd and it offers at least the following methods:

  • None (as it is compressed with kernel)
  • GZip
  • BZip
  • LZMA (possibly zen-only)

You can use it on external file and with LZMA (at least on Ubuntu).

Wikipedia states that Linux kernel supports gzip, bzip and lzma (depending, of course, what algorithms are compiled in).

  • does it must be "in-kernel" initrd (and what do you actually means by in-kernel) ? what if I have external file of initrd?
    – uray
    Sep 18, 2010 at 22:00
  • I would be very surprised if it used different files. As in what it actually means - you can build-in initrd in kernel just as you can build-in modules. I have / on LVM so I need to have initrd script - and the easiest way for me is to build it into kernel. Sep 18, 2010 at 22:04
  • sorry but the 'initrd' in this question is actually an initramfs file or a filesystem that initially loaded by kernel, or the file which usually pointed by grub like this initrd /boot/initramfs-, maybe I used wrong term (I edited the question)?
    – uray
    Sep 18, 2010 at 23:04
  • As I stated in edit - yes at least in Ubuntu. I'd be very surprised if it hadn't work. You haven't used the wrong term but I said what 1) I have experience with 2) what I found (that Ubuntu do support it) 3) what I expect. Anyway - why not just try it. Sep 19, 2010 at 0:29
  • ok I tried it, it confirmed the kernel can load initramfs with lzma compression, I must compile the kernel using CONFIG_RD_LZMA=y. but it will KP if the compression parameter is other than default, for example if i try lzma -e -9 -z for initramfs image it will leads to KP.
    – uray
    Sep 19, 2010 at 6:46


These kernel config options determine if compression is enabled or not.

A quick:


on the kernel tree leads to:

usr/Kconfig:155:config INITRAMFS_COMPRESSION_BZIP2
usr/Kconfig:181:config INITRAMFS_COMPRESSION_XZ
usr/Kconfig:194:config INITRAMFS_COMPRESSION_LZO
usr/Kconfig:206:config INITRAMFS_COMPRESSION_LZ4
  • 1
    I believe this is only relevant for a "built in initramfs" (see github.com/torvalds/linux/blob/…). For most uses of initramfs (e.g. at boot time on Debian/Ubuntu) an external file is used. For that way of working, the CONFIG_RD_ options apply Jul 11 at 9:21

You can see what compressions are supported for initramfs with:

zgrep CONFIG_RD_ /proc/config.gz
# or
grep CONFIG_RD_ /usr/src/linux/.config

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.