Skip to main content

Custom ISO

There are many reason to create a custom installer. This example was created to add the console output to the 1st serial port to deploy CentOS on a headless device.

Before you begin, make sure you have genisoimage and syslinux installed

yum install -y genisoimage syslinux

1. Download .iso from a CentOS mirror. See https://www.centos.org/download/mirrors/ for a list of mirrors nearest to you

wget http://linux.cc.lehigh.edu/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso

2. Mount .iso to a directory
sudo mount -o loop -t iso9660 CentOS-7-x86_64-Minimal-1810.iso centos_iso

3. copy its contents to another working directory:
cp -rf centos_iso/ centos_customized_iso

4. edit centos_customized_iso/isolinux/isolinux.cfg, overwrite its contents with the following. DO NOT alter the LABEL.

default linux
prompt 1
timeout 50

label linux
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 console=tty0 console=ttyS0,115200n8

label text
kernel vmlinuz
append initrd=initrd.img text inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 console=tty0 console=ttyS0,115200n8

label check
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet

5. prepare .iso again from centos_customized_iso directory:
sudo mkisofs -r -V “CentOS 7 x86_64” -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o custom.iso centos_customized_iso

6. run isohybrid on the new .iso (otherwise it won’t boot from USB)
isohybrid custom.iso

7. Make sure .iso is proper with a format like this, with “file” command:
file custom.iso

The output will be similar to this:

custom.iso: DOS/MBR boot sector ISO 9660 CD-ROM filesystem data (DOS/MBR boot sector) ‘CentOS 7 x86_64’ (bootable); partition 1 : ID=0x17, active, start-CHS (0x0,0,1), end-CHS (0x2ae,63,32), startsector 0, 1406976 sectors

8. Burn this to USB with dd command (here /dev/sdb is my USB drive):
dd if=custom.iso of=/dev/sdb bs=1MB

9. Insert this USB to your machine and boot from USB, and in the boot: prompt, type “linux text” as the install command
boot: linux text

To further customize and automate the installation, add a Kickstart to the append.