Skip to content

Instantly share code, notes, and snippets.

@abrahamrhoffman
Last active March 11, 2022 22:39
Show Gist options
  • Save abrahamrhoffman/6dae37d7bb533ae50ccb to your computer and use it in GitHub Desktop.
Save abrahamrhoffman/6dae37d7bb533ae50ccb to your computer and use it in GitHub Desktop.
CentOS 7 Kickstart File & How to build an (auto install) ISO

CentOS 7 Kickstart File - HOWTO Build ISO

There is so much documentation online from RedHat and CentOS about this topic - it's sad that I am writing this. But the real state of documentation on this topic (CentOS 7 + KS + ISO = Bootable DVD) is almost non-existent.

I found this: http://smorgasbork.com/component/content/article/35-linux/151-building-a-custom-centos-7-kickstart-disc-part-1

Which I greatly appreciate and +1, but the documentation is half-baked and there are numerous errors.

Finally... FINALLY! After four days of banging my head, I got this to work. Hopefully someone else will be able to do this in a few hours, instead of blowing their weekend like me. :(

GOAL

  • CentOS 7 Minimal Installation + Kickstart + ISO = DVD or USB for easy installs.

What you need

  • 2 Hours (If you're a Ninja)
  • CentOS 7 VM (Minimal install for Minimal ISO, Everything for Everything ISO, etc.)
  • The ability to slowly breathe in and out / fine malted beverage.

Notes

  • These instructions are for CentOS7 x86_64 Minimal
[root@localhost /]# cat /etc/centos-release
CentOS Linux release 7.0.1406 (Core)
  • Please execute all these instructions as root.

===========

START

  1. Download the CentOS 7 x86_64 Minimal ISO: http://goo.gl/Dj2vAo
  2. Use VirtualBox (or VMware Fusion or whatever you like) to install the OS to disc. Rec 20GB Disk & 2048MB RAM.
  3. After installation completes:
yum -y update && yum -y upgrade
yum -y install wget nano tree
shutdown -r now
  1. Re-attach the ISO in VirtualBox/VMware Fusion, then:
mkdir /mnt/dvd;mount -o loop /dev/sr0 /mnt/dvd
  1. Make the following directories:
mkdir -p ~/kickstart_build/isolinux
    +-- isolinux
    | +-- images
    | +-- ks
    | +-- LiveOS
    | +-- Packages
    +-- utils
  1. Copy all the files from the isolinux directory on CentOS DVD into your ~/kickstart_build/isolinux directory.
  2. Copy .discinfo from the CentOS DVD into your ~/kickstart_build/isolinux directory
  3. Recursively copy the contents of the images directory on the CentOS DVD into your ~/kickstart_build/isolinux/images directory.
  4. Copy the contents of the LiveOS directory on the CentOS DVD into your ~/kickstart_build/isolinux/LiveOS directory.
  5. Get the comps.xml file from repodata. This file is named with a unique hex string for each release. In CentOS 7.0.1406, for example, it is called 4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz. Copy it to ~/kickstart_build/comps.xml.gz and gunzip it so that you have ~/kickstart_build/comps.xml.

^^^ That means change the name to "comps.xml". Don't leave the long string in front of it.

Your kickstart config file will go into ~/kickstart_build/isolinux/ks. I like to have a separate directory for this, because I build a series of different config files for different machines or classes of machines.

Start from a sample configuration file

It is always best to start with a sample configuration file. CentOS makes it easy for you to get your hands on one. Just perform a standard installation on a machine. After the install, look in look in /root/anaconda-ks.cfg to get a sample kickstart configuration file.

Copy this file into ~/kickstart_build/isolinux/ks/ks.cfg.

If you want your kickstart to run completely unattended, you will need to make sure that the installer clears any existing partitions on the system before installing. Change this line:

  clearpart --none --initlabel

to

  clearpart --drives=sda --all --initlabel

Of course, if you're not installing to sda, you may need to modify this line.

Do not use the --all option if you plan on running your kickstart to install to a multiboot system; you will blow away all your operating systems. Then again, I don't know that kickstart makes much sense in such a scenario. You're much safer installing manually.

Note: it seems that in CentOS 7, anaconda writes a line into this file that is not valid according to the kickstart installer. This line:

network  --hostname=localhost.localdomain

should be:

network  --device=lo --hostname=localhost.localdomain

Note that the drive configuration here reflects the configuration of your build machine. If that is different from your target machine (for example, your build machine might use IDE drives, and your target might use SCSI, or you may want to use software RAID on the target machine), you'll have to edit some of these lines. When you're getting started, it's easiest if you use a build machine configured identically to your target machine.

Copy the RPMs

You will need access to all the RPMs that you might possibly include in your kickstart (along with all their dependencies). These will be located on your install media in the Packages directory.

@rohmdk
Copy link

rohmdk commented Apr 8, 2015

not yet completed??

@michaelainsworth
Copy link

This guide doesn't look finished.

@darrynza
Copy link

darrynza commented Feb 8, 2016

ahhh the irony... Funny enough I was able to do this in roughly 3 hours +- (for tweaking etc) with the link you supplied and said that " the documentation is half-baked and there are numerous errors. " the documentation is actually pretty spot-on with the exception of the perl script which I left out of my implementation and it worked 100%, unless the Doc has been updated since you attempted to use it in which case I apologize :)

@westwin
Copy link

westwin commented Mar 3, 2016

I'm new to iso. I'm wondering is there a way that:

  1. install a Minimal CentOS 7
  2. install my own rpms and do whatever customization
  3. based on the contents of this server, create a ISO

@citrocity
Copy link

Looks like you need to blow another weekend.. this isn't complete

@naveenmh
Copy link

naveenmh commented Dec 6, 2016

@HHawk
Copy link

HHawk commented May 17, 2019

You advertise yourself as "NINJA", however you look more like someone who didn't have som #### for weeks, because this is clearly not finished. Better to remove it to make you look more "GANGSTER"...!

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