Mixed compression initrds partially work

Bug #1840945 reported by Alkis Georgopoulos
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Updated description:

The kernel supports loading multiple initrds, like: [cpio microcode, gzip initrd.img].

Appending yet another initrd after that only works for selected compressions, not all of them. I'm not sure if this is a bug or a feature request.

So for example, this works: [cpio microcode, xz initrd.img, gzip extra.img]
And this doesn't: [cpio microcode, lz4 initrd.img, gzip extra.img]

To reproduce:
Get vmlinuz and initrd.img from an eoan daily build and put them in a directory.
Create a compressed extra.img:
# date > date.txt
# echo date.txt | cpio -oH newc | gzip > extra.img
Concatenate them:
# cat initrd.img.original extra.img > initrd.img
Boot them:
# kvm -m 512 -kernel vmlinuz -initrd initrd.img -append rdinit=/bin/sh

Then inside kvm:
# ls /date.txt

The date.txt file doesn't exist when initrd.img is lz4, while it appears if it's xz.

`dmesg | grep -i initramfs` reports:
Trying to unpack rootfs image as initramfs...
Initramfs unpacking failed: Decoding failed

description: updated
description: updated
description: updated
Revision history for this message
Ubuntu Kernel Bot (ubuntu-kernel-bot) wrote : Missing required logs.

This bug is missing log files that will aid in diagnosing the problem. While running an Ubuntu kernel (not a mainline or third-party kernel) please enter the following command in a terminal window:

apport-collect 1840945

and then change the status of the bug to 'Confirmed'.

If, due to the nature of the issue you have encountered, you are unable to run this command, please add a comment stating that fact and change the bug status to 'Confirmed'.

This change has been made by an automated script, maintained by the Ubuntu Kernel Team.

Changed in linux (Ubuntu):
status: New → Incomplete
Revision history for this message
Alkis Georgopoulos (alkisg) wrote : Re: Concatenated lz4 initrds don't work

This is about loading the kernel/initrd, so running apport-collect on the host won't provide any useful info, and running it inside the initramfs isn't possible.

Changed in linux (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

I tried all the COMPRESS= methods available in /etc/initramfs-tools/initramfs.conf in both eoan and bionic.

For each one, I ran:
date > date.txt
echo date.txt | cpio -oH newc > date.img
update-initramfs -u
cat initrd.lz4 date.img > initrd.img
kvm -m 512 -kernel vmlinuz -initrd initrd.img -append rdinit=/bin/sh

The results show that:
xz works in both eoan and bionic,
gzip and bzip2 regressed in eoan,
lzma, lzop and lz4 never worked.

=== EOAN ===
Linux kernel x86 boot executable bzImage, version 5.2.0-10-generic (buildd@lgw01-amd64-046) #11-Ubuntu SMP Tue Jul 30 19:19:46 UTC 2019, RO-rootFS, swap_dev 0x8, Normal VGA

SIZE FILENAME WORKS?
 9016056 vmlinuz
43335408 initrd.xz yes
43339869 initrd.lzma no date.txt
63081861 initrd.bzip2 no date.txt
68362761 initrd.lzop no date.txt
68364423 initrd.gzip no date.txt
77600825 initrd.lz4 kernel panic

=== BIONIC ===
Linux kernel x86 boot executable bzImage, version 4.15.0-58-generic (buildd@lcy01-amd64-013) #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019, RO-rootFS, swap_dev 0x7, Normal VGA

SIZE FILENAME WORKS?
 8302232 vmlinuz
39946592 initrd.xz yes
39942761 initrd.lzma no date.txt
56997316 initrd.bzip2 yes
61043794 initrd.lzop no date.txt
61046528 initrd.gzip yes

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

`| lz4 > date.img` is incorrect

One must use `lz4 -9 -l`

For xz one should use `xz --check=crc32`

Revision history for this message
Alkis Georgopoulos (alkisg) wrote :

@xnox, thank you, in #3 I was testing date.img as a plain cpio without compression,
while with your updated lz4/xz commands, it appears that when date.img matches the compression of initrd.img, then it works fine.

So the problem only happens when mixed compressions are used.

Btw, the reason I was trying that, is that in the new version of the "ltsp" netbooting package, we send all the netbooting code as an additional initrd.

So if we can't use mixed compressions, we'll need to provide a different initrd for each image/chroot/vm/live-cd that the ltsp sysadmin will want to netboot.

If the plans to default to lz4 initramfs are cancelled, then ltsp will work anywhere with a single initrd, from jessie and 16.04 to buster and hopefully 20.04. :)

Otherwise... where should we hunt the bug? In the kernel decompression code, or in mkinitramfs?

summary: - Concatenated lz4 initrds don't work
+ Mixed compression initrds partially work
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.