From: Andrei Borzenkov <arvidjaar@gmail.com>
To: David Shaw <dshaw@jabberwocky.com>
Cc: grub-devel@gnu.org, syslinux@zytor.com
Subject: Re: Using memdisk with grub2 and a gzip-compressed ISO
Date: Thu, 23 Apr 2015 19:59:31 +0300 [thread overview]
Message-ID: <20150423195931.1eb53b70@opensuse.site> (raw)
In-Reply-To: <C7ACECCE-ACED-44D0-BD29-22D9D8FB9941@jabberwocky.com>
В Thu, 23 Apr 2015 10:23:09 -0400
David Shaw <dshaw@jabberwocky.com> пишет:
> Hello,
>
> Pardon the cross-post to two lists, but this problem seems to lie in a somewhat gray area between grub2 and memdisk. Basically, the problem is this: it used to be possible to boot a compressed ISO image via memdisk and grub legacy, but this no longer works with grub2.
>
> Here's the setup: Two machines, both with 4GiB of RAM. The only difference between the two is that one is using grub legacy (0.97) and the other is using grub2 (2.02). I am using memdisk from syslinux 4.02 (though for completeness I also tried 4.05 and 6.03, with the same results). The ISO image itself is 3388047 bytes gzip compressed and 9394176 bytes uncompressed.
>
> The grub legacy configuration:
>
> title boot ISO image
> kernel /memdisk iso
> initrd /my-image.iso.gz
>
> The grub2 configuration:
>
> menuentry 'boot ISO image' {
> linux16 /memdisk iso
> initrd16 /my-image.iso.gz
> }
>
> If anyone would like to see it, the sample gzip-compressed ISO image is\x01 at http://www.jabberwocky.com/my-image.iso.gz
>
> Now to the problem: When booting the box with grub 0.97, it works. The ISO boots and the right things happen. Here's the output from memdisk:
>
> Ramdisk at 0x37cb4000, length 0x0033b28f
> gzip image: decompressed addr 0xbf5fa800, len 0x008f5800: ok
>
> When booting the box with grub2 2.02, it does not work. The error is:
>
> Ramdisk at 0x37979000, length 0x0033b290
> gzip image: decompressed addr 0xbfff7000, len 0x00008f58: failed
> Decompression error: output buffer overrun
>
> I'm not sure if this is related to the problem, but note the length in the "Ramdisk" line from grub legacy is one byte shorter than the length from grub2. Also note that the length given in the "gzip image" line is shifted one byte to the left in the grub legacy version (i.e. it's exactly 0x100 times larger).
>
> 1) I have tried this with memdisk from syslinux 4.02, 4.05, and 6.03 with the same results each time.
> 2) Changing the level of compression (i.e. gzip -1 instead of gzip -9) does not make a difference.
> 3) This works fine with an uncompressed image with grub2. This also works fine with a zip-compressed image with grub2. It only seems to fail with a gzip-compressed image with grub2.
>
> Andrei Borzenkov kindly analyzed the image and suggested I contact both the syslinux and grub groups as he has a notion of what went wrong. Andrei, can you fill in anything I missed?
>
What happens is as following. grub initrd command supports both legacy
initrd and initramfs. Initramfs is concatenation of (compressed) cpio
archives. For uncompressed cpio archive start of archive and end of
trailer are required to be aligned on 4 bytes boundary according to
Documentation/early-userspace/buffer-format.txt. Kernel actually checks
at least start alignment.
Kernel is pretty liberal in what it gets. It will ignore any amount of
zero padding between individual archives (and at the beginning as well)
and treats initrd size only as upper boundary - it will decompress
stream starting from the beginning, not assuming anything about total
compressed stream size. This allows grub to simply pad files on 4 bytes
from both ends without actually knowing anything about content.
Here where the problem happens. When loaded by grub initrd gets extra
zero byte padding, thus shifting total size by one byte, because
syslinux apparently assumes initrd size is always exact and interprets
last 4 bytes as size.
I'd actually expect that if syslinux is using Linux compatible
protocol to load initrd, it accepts at least the same data as Linux
would. May be it could relax requirement for exact size for initrd?
Especially as it apparently happens only with some compression
algorithms.
next prev parent reply other threads:[~2015-04-23 16:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-23 14:23 Using memdisk with grub2 and a gzip-compressed ISO David Shaw
2015-04-23 16:59 ` Andrei Borzenkov [this message]
2015-04-23 22:17 ` [syslinux] " H. Peter Anvin
2015-04-24 3:14 ` Andrei Borzenkov
2015-04-24 3:30 ` H. Peter Anvin
2015-04-24 3:41 ` Andrei Borzenkov
2015-04-24 4:39 ` H. Peter Anvin
2015-04-24 6:25 ` Andrei Borzenkov
2015-04-27 22:20 ` H. Peter Anvin
2015-04-29 13:55 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-04-29 16:28 ` Andrei Borzenkov
2015-04-29 17:45 ` Andrei Borzenkov
2015-04-29 18:35 ` Vladimir 'phcoder' Serbinenko
2015-04-30 3:36 ` Andrei Borzenkov
2015-04-29 18:42 ` David Shaw
2015-05-07 14:23 ` Vladimir 'φ-coder/phcoder' Serbinenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150423195931.1eb53b70@opensuse.site \
--to=arvidjaar@gmail.com \
--cc=dshaw@jabberwocky.com \
--cc=grub-devel@gnu.org \
--cc=syslinux@zytor.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.