Today I had a small challenge to take, when I wanted to modify a bootable .iso image on Mac OS. I couldn’t find any 1-click-software to do so, therefore I had to figure out another way. Because it took me some time to figure out, I thought other people might also be interested in the solution
What we are going to do?
It is not possible to modify a bootable (and read only) .iso image on Mac OS. If you don’t need to preserve the bootable image, you can just copy all files and create a new one in Disk Utility. But when you need to be able to boot from it (or burn it to a disk which should be bootable), things get a little complex. Since it is impossible to modify contents directly, we will do the following:
- Save El Torito boot information
- Copy all contents from the image to a local folder
- Edit the things we need to change in the folder
- Create a new bootable image of the folder’s contents using the former saved boot information
Download and install geteltorito
geteltortio is a little perl script to extract the El Torito boot informations from the .iso file. Let’s download it:
curl -O http://userpages.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito
And make it executable:
chmod -x ./geteltorito
(if you want you can copy it to
/usr/local/bin to be able to execute it from anywhere. Note that it requires perl, so if you don’t have perl installed, do so i.e. with
sudo port install perl)
Save El Torito boot information
Now we are going to extract the boot information from the .iso file:
geteltorito -o boot.bin /path/to/image.iso
The boot.bin file will be used at the end, to reassemble a bootable .iso image.
Copy and modify the data
Let’s create a temporary folder, we can delete it afterwards again, but need it to copy the .iso data to in order to modify it.
Now we simply mount the image (double click it in Finder) and will copy it’s contents (use the appropriated name of the mounted disk of course):
cp /Volumes/Mounted_image ~/image_folder
Now we have to copy our previously made El Torito
boot.bin file to the folder:
cp /path/to/boot.bin ~/image_folder
Now you can modify what you need to modify in the image_folder… When you are done, let’s continue!
Reassemble bootable .iso
For this step we will need a utility called mkisofs, it is part of the cdrtools which you might need to install if you don’t have them already, using your favorite package manager (
sudo port install cdrtools or compile from source).
Now we are going to create the new .iso using mkisofs:
mkisofs -udf -no-emul-boot -relaxed-filenames -joliet-long -hide boot.bin -b boot.bin -D -o ./new_image.iso ~/image_folder
After some time of generation we should now have a new_image.iso which you can burn with your favorite app. Hope this might be useful for someone…