[syslinux] [PATCH] 4 Patches for initrd+= and initrdfile= Options

Shao Miller sha0.miller at gmail.com
Thu Oct 25 23:49:50 PDT 2012


Attached are 4 patches against Syslinux 4.06 providing two new options for
the linux.c32 ComBoot32 module.  If we are shifting gears towards 4.10 or 5
any time soon, feel free to let me know and I'll attempt to apply the
patches to those and to deal with any conflicts.

You can merge these commits onto your 4.06 from my 'multi_initrd' branch at:

  git://git.zytor.com/users/sha0/syslinux.git

In brief:

The "initrd+=" option allows you to append initramfs-style blobs (files
which can be produced with 'cpio -o -H newc') to whatever "initrd" was
specified via the "initrd=" option (or was specified indirectly via the
INITRD directive).

This means you can have some custom initramfs that contains some stuff you
might like to layer on top of whatever initramfs your Linux distribution
gives you; useful for changing startup scripts or adding drivers/features or
changing behaviour.

This option can be specified more than once, and can take a comma-separated
list of files.

Please note: This option uses the plus-sign symbol, so _please_ bring
forward any conflicts with existing processing of the kernel command-line or
of Syslinux config-files which may result.

The "initrdfile=" option allows you to load a file and encapsulate it as
though you had used 'cpio -o -H newc', and pass the resulting blob alongside
the other items that might have been specified with "initrd=" or "initrd+=".

This is useful for taking a raw file from the Syslinux booted-from
filesystem and sending it through to Linux' rootfs via the initramfs scheme.

This option can be specified more than once, and can take a comma-separated
list of files.

Besides use for Linux, this implementation also allows Syslinux users to
boot Michael Brown's 'wimboot' kernel and be able to pass it the raw files
it needs in order to boot a Microsoft Windows PE .WIM.

Thanks to Brandon Penglase for very patiently testing the wimboot
functionality.  Thanks to Michael Brown for wimboot and iPXE, naturally.

Thanks to Ady for criticizing the plus-sign symbol and suggesting
alternatives.

Some patch details follow.  Enjoy!


>From 693903de260d39db89e246a1e569a084f444cdd7 Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Thu, 25 Oct 2012 02:17:36 -0400
Subject: [PATCH 1/4] linux.c32: Move some initrd=x,y,z code out of main

In handling an "initrd=x,y,z" option, it seems reasonable to be able
to handle similar options in a similar fashion, so some of the code
has been moved out of 'main' and into a new 'process_initramfs_args'
function.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
 com32/modules/linux.c | 82
++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 61 insertions(+), 21 deletions(-)


>From 4610994cf5b8388d9351549987c6c6270ad0ee7e Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Thu, 25 Oct 2012 03:58:07 -0400
Subject: [PATCH 2/4] linux.c32: Add new initrd+= option for multiple initrds

linux.c32 now processes the kernel's command-line for "initrd+="
options.

Given "initrd+=foo", linux.c32 will concatenate the file "foo"
to the initrds that it has already loaded due to the "initrd="
option.

Given "initrd+=foo,bar", linux.c32 will concatenate both files
"foo" and "bar" to the initrds that it has already loaded due
to the "initrd=" option.  That is, multiple filenames can be
specified with comma separators.

Given "initrd+=foo initrd+=bar", linux.c32 will concatenate
both files "foo" and "bar" to the initrds that it has already
loaded due to the "initrd=" option.  That is, the "initrd+="
option can be specified multiple times.

The position of any "initrd=" option relative to any "initrd+="
option is irrelevant.  The "initrd=" option is always processed
before all "initrd+=" options.

PLEASE NOTE: It is important to note that there are NO SPACES
involved in using the "initrd+=" option.  "initrd += foo" will
not work.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
 com32/modules/linux.c | 7 +++++++
 1 file changed, 7 insertions(+)


>From bd70ee4433a5eb3f71fabcb26c47ae10e848b6ee Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Thu, 25 Oct 2012 21:25:38 -0400
Subject: [PATCH 3/4] linux.c32: Introduce initrdfile= option

It is useful to be able to load a file and pass it into a kernel's
rootfs via the initramfs scheme.  Given "initrdfile=foo", we will
load the file foo, encapsulate it with the initramfs cpio format,
then pass it alongside any initramfs files that were specified by
"initrd=" and "initrd+=" options.

One can specify the desired path/filename for the file to have
within the rootfs by using the at (@) sign, as in:

  initrdfile=foo@/goes/to/foo

One can also specify multiple files, separated by commas, such as:

  initrdfile=foo,bar@/somewhere/bar,baz

One can also use this option multiple times, as in:

  initrdfile=foo,bar initrdfile=baz@/somewhere/baz

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
 com32/modules/linux.c | 49
+++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)


>From ff696292491b77bec7f5a85c72626ff8f70dc45f Mon Sep 17 00:00:00 2001
From: Shao Miller <sha0.miller at gmail.com>
Date: Fri, 26 Oct 2012 02:14:28 -0400
Subject: [PATCH 4/4] initramfs chain handling: Accounting fixes for padding,
 etc.

Signed-off-by: Shao Miller <sha0.miller at gmail.com>
---
 com32/lib/syslinux/initramfs_file.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-linux.c32-Move-some-initrd-x-y-z-code-out-of-main.patch
Type: application/octet-stream
Size: 3251 bytes
Desc: not available
URL: <http://www.zytor.com/pipermail/syslinux/attachments/20121026/61e77f38/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-linux.c32-Add-new-initrd-option-for-multiple-initrds.patch
Type: application/octet-stream
Size: 1833 bytes
Desc: not available
URL: <http://www.zytor.com/pipermail/syslinux/attachments/20121026/61e77f38/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-linux.c32-Introduce-initrdfile-option.patch
Type: application/octet-stream
Size: 3295 bytes
Desc: not available
URL: <http://www.zytor.com/pipermail/syslinux/attachments/20121026/61e77f38/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0004-initramfs-chain-handling-Accounting-fixes-for-paddin.patch
Type: application/octet-stream
Size: 2617 bytes
Desc: not available
URL: <http://www.zytor.com/pipermail/syslinux/attachments/20121026/61e77f38/attachment-0003.obj>


More information about the Syslinux mailing list