Skip to content

Instantly share code, notes, and snippets.

@ganapathichidambaram
Created January 13, 2020 09:50
Show Gist options
  • Save ganapathichidambaram/8c9b08129b41ed6a1f4ac10f72d88aad to your computer and use it in GitHub Desktop.
Save ganapathichidambaram/8c9b08129b41ed6a1f4ac10f72d88aad to your computer and use it in GitHub Desktop.
Creation of CentOS-8 Custom ISO

ISO Creation from Scratch

In this tutorial we are going to look into creation of CentOS ISO based on CentOS 8. There are few slight difference between the folder structure from CentOS 7. In CentOS 7 isolinux contains directly Packages without any parent folder and every rpm will be under single folder. But in CentOS 8 it would segreagated into two separate folder such as BaseOS and AppStream. And those configuration defined on media.repo file present in the iso file.

  • To Create ISO we need to create necessary folder struture like mentioned below.
mkdir -p ~/kickstart_build/isolinux/{BaseOS,AppStream}/Packages
  • To Create minimal ISO, we required packages list, where we can gather from any minimal installation using rpm query. Also make sure the pacakge with version and arch, so that copy those packages without any extra relevant packages.
rpm -qa | sort > minimal_pkg_name.log
  • Assume we have DVD ISO on CD-ROM and mount the same into /mnt directory. According to your resource you may use the mount device.
mount /dev/cdrom /mnt
  • Copy this content into script.sh and execute it to copy the packages from DVD iso folder to your build folder.
while read file;do
cp /mnt/BaseOS/Packages/$file.rpm ~/kickstart_build/isolinux/BaseOS/Packages/
cp /mnt/AppStream/Packages/$file.rpm ~/kickstart_build/isolinux/AppStream/Packages/
done < minimal_pkg_name.log
  • Also we need to verify whether any conflict or dependencies pacakages required for the rpm which we copied. Executre this rpm test to make sure there is no dependencies or conflict, else kindly do the necessary action to remove the conflict packages or copy the dependencies packages into build rpm(BaseOS/AppStream) folder.
mkdir /tmp/testdb
rpm --initdb --dbpath /tmp/testdb
rpm --test --dbpath /tmp/testdb -Uvh ~/kickstart_build/isolinux/BaseOS/Packages/*.rpm ~/kickstart_build/isolinux/AppStream/Packages/*.rpm
  • Additionally we need to copy the below content from DVD ISO for successful installation.
cp -r /mnt/{images,EFI} ~/kickstart_build/isolinux/
cp -r /mnt/isolinux/* ~/kickstart_build/isolinux/
cp /mnt/.treeinfo ~/kickstart_build/isolinux/
cp /mnt/.discinfo ~/kickstart_build/isolinux/
  • We need to create repodata for the packages which we copied into build folder. So that installation would find the packages from media repository.
cd ~/kickstart_build/isolinux/BaseOS/ && createrepo -g ~/kickstart_build/comps.xml . && cd ~/kickstart_build/isolinux/AppStream/ && createrepo -g ~/kickstart_build/comps.xml .
  • To Make sure necessary permission to execute isolinux while installation.
chmod 664 ~/kickstart_build/isolinux/isolinux.bin
  • Finally To Create ISO execute this command to create ISO file. Also make sure LABEL should be exactly same as mentioned on grub configuration file. Else Installation would fail to find the img file to boot up installation process.
cd ~/kickstart_build/

mkisofs -o FlexyDial_4-x86_64.iso -b isolinux.bin -c boot.cat -no-emul-boot \
  -V 'FlexyDial4' \
  -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/

@olja230674
Copy link

How can I run a post installation script? In Centos 7 I used the post section of ks file

@BH1SCW
Copy link

BH1SCW commented Aug 26, 2022

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment