[ipxe-devel] Does imgextract keep writing to same named location by design?

Michael Brown mcb30 at ipxe.org
Mon Mar 14 09:01:00 UTC 2022


On 11/03/2022 16:44, John Hanks wrote:
> I am using imgextract to download several images, like so
> 
> imgextract --name one http://master/one.img <http://master/one.img>
> imgextract --name two http://master/two.img <http://master/two.img>
> imgextract --name three http://master/three.img <http://master/three.img>
> boot kernel initrd=initrd.magic initrd=one initrd=two initrd=three blah 
> blah blah
> 
> So far so good, except that I wanted to try adding a lot of these but am 
> restricted by the maximum kernel command line length. I naively tried
> 
> imgextract --name mysystem http://master/one.img <http://master/one.img>
> imgextract --name mysystem http://master/two.img <http://master/two.img>
> imgextract --name mysystem http://master/three.img <http://master/three.img>
> boot kernel initrd=initrd.magic initrd=mysystem blah blah blah
> 
> and it worked!!! But, that seems way too easy, like I'm cheating. Is 
> this expected to work this way or am I exploiting a bug that might get 
> fixed later? I don't want to depend on this unless it's working this way 
> on purpose.

You are triggering slightly undefined behaviour by using both 
"initrd=initrd.magic" and an explicit "initrd=<name>" argument.

The "initrd=initrd.magic" will cause the kernel to already see an initrd 
that comprises the concatenation of all of the images as seen by 
"imgstat".  (The magic initrd will also include constructed CPIO headers 
for any images that have a non-empty argument list, but that's 
irrelevant for your use case.)

So, assuming that your images are all compressed CPIO initrd images that 
are amenable to concatenation, then you should be able to get the 
behaviour you want by simplifying your script to something like:

   imgextract http://master/one.img
   imgextract http://master/two.img
   imgextract http://master/three.img
   boot kernel initrd=initrd.magic

i.e. remove the (redundant) --name options, and tell the kernel to load 
only initrd.magic.

Hope that helps,

Michael


More information about the ipxe-devel mailing list