# Repack linux ISO

Commands expect to be in a root shell

## Install needed tools
mkisofs xorriso isohybrid

## Editing ISO image

Create workspace  
`mkdir /tmp/custom_iso`  
Mount image and extract it since it is read only  
```
mount -t iso9660 -o loop ~/original.iso /mnt/`  
tar cf - /mnt/. | (cd /tmp/custom_iso; tar xfp -)
```
You can now modify the files for editing the bootloader config for example!  

## Back into an iso

### Legacy only
Rebuild iso with mkisofs  
`mkisofs -o output.iso -b syslinux/isolinux.bin -c syslinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -J -R -V "Custom ISO" /tmp/custom_iso`  
Bless it with isohybrid  
`isohybrid output.iso`  

### EFI and Legacy
Rebuild iso with mkisofs  
`mkisofs -o output.iso -b syslinux/isolinux.bin -J -R -l -c syslinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -eltorito-alt-boot -e boot/grub/efi.img -no-emul-boot -graft-points -V "Custom ISO" /tmp/custom_iso`  
Bless it with isohybrid  
`isohybrid --uefi  output.iso` 

### Sources
https://gist.github.com/AkdM/2cd3766236582ed0263920d42c359e0f  
https://tuxfixer.com/mount-modify-edit-repack-create-uefi-iso-including-kickstart-file/  