0

I'm trying to create a custom CentOS 7 .iso that has a set of scripts included, eg. installX.sh.

I've followed the instructions here, creating a product.img with the file structure: /sbin/installX.sh, /.buildstamp

I then placed that in the images folder and generated the .iso. However, when testing out the .iso, it doesn't have installX.sh anywhere on the system when running find / -name installX.sh. This suggests the product.img file was ignored.

How can I load an .img file into the file structure of the installed OS?

The contents of .buildstamp:

[Main]
Product=CentOS Linux
Version=7.7
BugURL=https://bugs.centos.org
IsFinal=True
[Compose]
Lorax=19.6.92-1

The image file was created using this command:

find . | cpio -c -o | gzip -9cv > ../product.img

And was placed in linux/images in the ISO path

To generate the .iso, I used this command:

genisoimage -U -r -v -T -J -joliet-long -V "CentOS 7 x86_64" -volset "CentOS 7 x86_64" -A "CentOS 7 x86_64" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e images/efiboot.img -no-emul-boot -o ../CentOS7.iso .

Where the working directory is the file structure to become the .iso, and CentOS7.iso is the .iso I'm trying to create.

The .iso was checksummed using:

implantisomd5 ../CentOS7.iso

And was working and able to be installed as a normal CentOS 7 installation (Just without installX.sh).

1 Answers1

0

I think the easiest way to accomplish this would be to convert the .img to cd9660 format. Then mount it, and copy what you need on to the CentOS iso image you're building. You can accomplish the conversion using iat. For example, if I were on Ubuntu. I'd do it this way:

sudo apt install iat

followed by

iat yourimge.img youriso.iso

Then simply mount the freshly converted iso image in the same way you mounted the CentOS iso. Copy the files you need to the CentOS image you're creating where you need them.

somebody
  • 99
  • 2
  • This method will allow me to access the files on the `.img` and relies on being able to copy the file directly onto the mounted CentOS `.iso`, however the CentOS `.iso` has an install file structure with the filestructure hidden inside other `.img` files. It doesn't seem recommended to change these existing files meaning there's no way to directly add to the `.iso` without creating a `.img` for Anaconda to pick up. – Joseph Keane Mar 04 '20 at 09:13
  • OK I've re-read your question. It appears that your image was not found _because_ the ISO image wasn't created properly. It _appears_ that (as you say) **your** image wasn't included in the new ISO. What was the _exact_ command you used to create the new ISO? – somebody Mar 04 '20 at 19:05
  • See updates in question – Joseph Keane Mar 04 '20 at 21:24
  • Thanks for the update @JosephKeane I'm on a BSD, and use [mkisofs](https://manpage.me/?mkisofs) which is also available for Linux. Let me get back to you after I've whipped up the incantation for your needs. :) – somebody Mar 04 '20 at 21:45