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

Re: XZ compression for the initramfs



On Mon, Jan 4, 2016 at 3:58 AM, Martin Michlmayr <tbm@cyrius.com> wrote:
> It goes from about 1 minute to 2 minutes and 20 seconds (without running
> flash-kernel) which is a huge increase percentage wise but a minute more
> is imho not a big deal, especially if it means avoiding troubles because
> the ramdisk doesn't fit in flash.  [If TS-209 users cared about performance,
> surely they would have upgraded to a faster machine already :-P]

Wait for minutes is pain, but obviously better than having to throw
away the device.
So agreed.

> This is with MODULES=dep on an Orion machine with 256 MB RAM.  XZ will
> probably use swap if you only have 64 MB RAM, but all the QNAP machines
> have at least 128 MB RAM.

Now I understand why I remembered it took 5+ minutes not finishing
"update-initramfs" command, it was due to swapping.
After learning the lesson, here's my result on Linkstation LS-WTGL
(orion5x with only 64M memory):

# update-initramfs -u  # by zip
real    1m1.747s
user    0m35.080s
sys     0m18.980s
-rw-r--r-- 1 root root 3579355 /boot/initrd.img-4.3.0-trunk-orion5x

# export XZ_DEFAULTS="--memlimit=40MiB"
# update-initramfs -u  # by xz
real    2m15.200s
user    1m46.052s
sys     0m19.600s
-rw-r--r-- 1 root root 2479348 /boot/initrd.img-4.3.0-trunk-orion5x

# export XZ_DEFAULTS="--memlimit=60MiB"
# update-initramfs -u  # case of out of memory
update-initramfs: Generating /boot/initrd.img-4.3.0-trunk-orion5x
xz: Adjusted LZMA2 dictionary size from 8 MiB to 4 MiB to not exceed
the memory usage limit of 60 MiB
Killed
E: mkinitramfs failure cpio 141 xz --check=crc32 137
update-initramfs: failed for /boot/initrd.img-4.3.0-trunk-orion5x with 1.

I also tried on Linkstation LS-WSXL (kirkwood with 128M memory).
Without limiting XZ_DEFAULTS, it fails to generate. After setting to
XZ_DEFAULTS="--memlimit=80MiB", it got fixed.
I think QNAP should be the similar situation.

I suggest it's better to inform the following in NEWS:
- Using "xz" as compression method can extremely reduce the size of
initrd image, but it may takes around 2x time compared to zip. For
arm/orion5x it usually takes 2 minutes to create (update-initramfs).
- For device with 128M memory or even less, it's necessary to set up
environment variable XZ_DEFAULTS to limit the memory usage while
creating initrd. For example, below two setting is confirmed working
on system with 64M and 128M memory respectively:
  * export XZ_DEFAULTS="--memlimit=40MiB"
  * export XZ_DEFAULTS="--memlimit=80MiB"
You can also append the XZ_DEFAULTS setting to ~/.bashrc for your convenience.

Cheers,
Roger


Reply to: