May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Kickstart CentOS 7: Making ISO for automated installation

Kickstart” is powerful tool for automated OS installation and configuration available in CentOS or RHEL. You can install CentOS without touching keyboard or mouse and even can automate post installation configuration process.

I’m recently building a Hadoop cluster for R&D, which makes me repeatedly install and re-install CentOS on several virtual machines. This is boring task takes hours. So I googled for automation and the answer was the Kickstart.

Basically a Kickstart is configuration file. CentOS load it at the beginning of installation process and apply it.

There are some ways to load the configuration file, through network, file system, or include installation ISO. I took the ISO way.

There is already good detail article about making kickstart-able ISO: “Building a custom CentOS 7 kickstart disc, part 1”, I followed this article with some modified steps.

Prepare directory and copy files from CentOS installation disk

$ mkdir ks_build
$ mkdir ks_build/isolinux
$ mkdir ks_build/isolinux/images
$ mkdir ks_build/isolinux/ks
$ mkdir ks_build/isolinux/LiveOS
$ mkdir ks_build/isolinux/Packages
$ mkdir ks_build/utils
$ cp /media/cdrom/CentOS7x86_64/isolinux/* ks_build/isolinux/
$ cp -R /media/cdrom/CentOS7x86_64/images/* ks_build/isolinux/images/
$ cp /media/cdrom/CentOS7x86_64/LiveOS/* ks_build/isolinux/LiveOS/
$ cp -p /media/cdrom/CentOS7x86_64/Packages/* ks_build/isolinux/Packages/
$ cp /media/cdrom/CentOS7x86_64/repodata/0e6e90965f55146ba5025ea450f822d1bb0267d0299ef64dd4365825e6bad995-c7-x86_64-comps.xml.gz ks_build/comps.xml.gz
$ gunzip ks_build/comps.xml.gz

Create kickstart configuration file

I created two files. One for Hadoop master nodes and the other for slave nodes. The only difference is disk partition settings. I will only paste configuration for master nodes.

Meaning of each options are described in 23.3. Kickstart Syntax Reference, a Red Hat document. There is also an GUI tool named “system-config-kickstart” for editing a configuration file.

$ vi ks_master.cfg
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL

# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# System authorization information
auth  --enableshadow  --passalgo=sha512
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=vda
# Keyboard layouts
keyboard --vckeymap=jp106 --xlayouts='jp','us'
# System language
lang en_US.UTF-8
# Reboot after installation
reboot
# Root password
rootpw  --iscrypted $6$P3w8ID5.Zn3KObRb$eYGfYprCnPzwDF6WVPCLgx.tDFFo4/8prhovv.hEfdyfGRQ12MexcUwBESU3Hl2jS22KjA8si6.VdPChvnB4q1
# System language
timezone Asia/Tokyo --isUtc --nontp
# Firewall configuration
firewall --disabled
# Network information
network  --device=lo --hostname=localhost.localdomain
network --onboot=no --device=eth0 --bootproto=dhcp --noipv6
# Use graphical install
graphical
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# skip eula
eula --agreed

# System bootloader configuration
bootloader --location=mbr --driveorder=vda --append="crashkernel=auto rhgb quiet"
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --size=500
part swap --asprimary --fstype="swap" --size=6144
part / --asprimary --fstype="ext4" --grow --size=1

# Repository
repo --name="CentOS"  --baseurl=cdrom:sr0 --cost=100
%packages
@core
@base
%end
$ cp ks_master.cfg ks_build/isolinux/ks/

Note, the “–onboot” option is set to “no”. Because I haven’t setup a DHCP server at this time. Without DHCP server, the instllation will stop at configuration screen.

network --onboot=no --device=eth0 --bootproto=dhcp --noipv6

Create repository

$ cd ~/ks_build/isolinux
$ createrepo -g ~/ks_build/comps.xml . 

Build ISO

$ cd ~/ks_build
$ chmod 664 isolinux/isolinux.bin
$ mkisofs -o custom.iso -b isolinux.bin -c boot.cat -no-emul-boot -V 'CentOS 7 x86_64' -boot-load-size 4 -boot-info-table -R -J -v -T isolinux/

Run kickstart

Boot from the ISO created by above command.

Press “ESC” at boot menu.

 

 

Type below command at boot prompt.

linux inst.ks=cdrom:/dev/cdrom:/ks/ks_master.cfg

 

 

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>