clalancette / pycdlib

Python library to read and write ISOs
GNU Lesser General Public License v2.1
147 stars 38 forks source link

Trouble adding El Torito to ISO #38

Closed willervinNTS closed 4 years ago

willervinNTS commented 5 years ago

I have a basic VMware ESXi ISO that boots fine. For testing purposes, I'm attempting to take it's contents out and add them to a new ISO using iso.add_file() and iso.add_eltorito().

I've used Cdrtools to get some data from the ISO to see what parameters are needed for the iso.add_eltorito() method, and this is what I found:

Eltorito validation header: Hid 1 Arch 0 (x86) ID '' Cksum AA 55 OK Key 55 AA Eltorito defaultboot header: Bootid 88 (bootable) Boot media 0 (No Emulation Boot) Load segment 0 Sys type 0 Nsect 4 Bootoff 2FF1 12273

With that information, this is how I'm attempting to add El Torito to the new ISO: self.iso.add_eltorito(bootfile_path='/BOOT.CFG;1', bootcatfile='/BOOT.CAT;1', media_name='noemul', boot_load_size=4, boot_load_seg=0, efi=False, boot_info_table=True, platform_id=0 )

This is still not creating a bootable ISO. Are the parameter values incorrect or is there a step I'm missing here. Thanks.

clalancette commented 4 years ago

I'm sorry I never answered this; I got really busy at the beginning of October, and I'm just digging out.

For the most part, it looks like you've replicated the information from what isoinfo told you. The one bit that you did not replicate (and that pycdlib doesn't currently support) is the boot offset (also known as the "Load RBA" in the original El Torito spec, p. 10). pycdlib doesn't currently support setting this as it is something it manages internally; as files are added or removed to the ISO, it can move around the different entries here, so it just updates the variable as appropriate. That all being said, I'm honestly not sure if that is your problem or not.

If you are still interested in pursuing this, there are a few things we can try:

  1. Try to recreate the ISO using genisoimage/mkisofs. If you can find a combination of options that works using those programs, and send them to me, I may be able to recreate the same thing here.
  2. Open the original ISO and write it back out with pycdlib without doing any modifications at all, then try to boot that. If that works, then we know it is something during the modification process that is causing problems. Some code that will probably work for this (though untested):
    import pycdlib
    iso = pycdlib.PyCdlib()
    iso.open('/path/to/original.iso')
    iso.write('/path/to/new.iso')
  3. If we get through all of that and still aren't any closer, I can write some simple programs to dump out various pieces of data, and see if we can track it down that way.
clalancette commented 4 years ago

Just FYI, I was able to get my hands on an ESXI ISO, and I confirmed that number (2) above works fine (at least, I can boot it).

There are a few slightly unusual things going on in the El Torito section of the ISO, but I think they are things that pycdlib may be able to handle. I think at this point, looking at the code you are trying to use is the best course of action. I may be able to pinpoint where you are going wrong and/or see if we need to make changes to pycdlib to make this work.

clalancette commented 4 years ago

I'm going to close this out with no response. If you'd still like to pursue this, please feel free to reopen and we can continue debugging.

killermoehre commented 3 years ago

I would like to reopen this issue, as I have the exact same problem.

My task includes:

clalancette commented 2 years ago

I'm sorry, I never saw this response until now.

If you'd like to pursue this, please open a new issue and we can debug over there.

killermoehre commented 2 years ago

Actually, it works now very well. No need for further troubleshooting. Much appreciated that you still answered.

clalancette commented 2 years ago

Great, glad to hear it.