Home/Server & Website Managed Operations/Tutorial: Automated CentOS Installation Based on Kickstart
Server & Website Managed Operations

Tutorial: Automated CentOS Installation Based on Kickstart

Foreword

A client has over 60 servers that need to centrally deploy CentOS on Inspur x86 servers to build a Hadoop-based big data platform. This guide primarily uses Kickstart to achieve the simplest automated installation of CentOS via CD/DVD. Most tutorials found online are not fully applicable to our specific environment. This article will not elaborate on Kickstart concepts; for details, please refer to the extended reading section.

Kickstart is one of the most common methods for automated Linux installation.

Environment Preparation

Customizing the System

CentOS-6.4-x86_64

Official download link – http://wiki.centos.org/Download

Installing Packages

Tips for proxy internet access: export http_proxy=ip:port

yum -y install createrepo mkisofs

Production Process

Directory Structure

Copy the original CentOS ISO content without any trimming

mkdir /mnt/centos
mount /dev/sr0 /mnt/centos
mkdir /tmp/iso
cp -r /mnt/centos/* /tmp/iso

Adding Kickstart Configuration File

The file path and installation method can be freely defined.

cd /tmp/iso/isolinux
# Modify boot configuration, pay attention to the ks= part
vi isolinux.cfg

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/isolinux/ks.cfg

# Manually add Kickstart configuration file
vi ks.cfg


# Practice of automated CentOS installation based on Kickstart
# Kickstart file automatically generated by anaconda.
# version=DEVEL

# Install OS instead of upgrade
# Indicates installation, not upgrade
install

# Use text mode installation
# Text mode installation
text

# Use network installation
# Use network installation
# url --url=ftp://ip/centos
# Local installation: Use CDROM installation media
# Use CD/DVD for installation
cdrom

# Installation number configuration
# If it is a Red Hat system, it will require entering a key. Here we configure it to skip. If not configured, the installation will pause and ask the user to enter the key.
# key –skip

# System language
# Language environment
# lang en_US.UTF-8
lang zh_CN.UTF-8

# System keyboard
# Keyboard type
keyboard us

# Network information
# Network configuration
# network --device eth0 --bootproto dhcp --onboot yes

# Root password
# root password
rootpw chinaums

# Firewall configuration
# Disable firewall
firewall --disabled

# SELinux configuration
# Disable SELinux
selinux --disabled

# Run the Setup Agent on first boot
# Disable the system setup wizard on first boot
firstboot --disable

# System authorization information
# User authentication configuration: useshadow indicates using local authentication, --passalgo indicates the password encryption algorithm
authconfig --enableshadow --passalgo=sha512

# System timezone
# Set timezone to Shanghai
timezone --isUtc Asia/Shanghai

# System bootloader configuration
# Specify the bootloader installation location, drive order, and parameters passed to the kernel after OS installation is complete
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"

# Clear the Master Boot Record
# Clear MBR boot record
zerombr yes

# Partition clearing information
# Clear all data on the hard disk
clearpart --all --initlabel

# Disk partitioning information
# Custom partitions

# Create a 200M partition mounted at /boot with ext4 type
part /boot --fstype=ext4  --size=200 --ondisk=sda

# Create a 20000M SWAP partition
part swap --size=20000 --ondisk=sda

# Create / directory
part / --fstype=ext4 --grow --size=1 --ondisk=sda

# Reboot after installation
# Restart after completion
reboot --eject

# This package list is for CentOS 6.4
# Software packages customized for CentOS 6.4
%packages
@base
@core
@chinese-support
@server-policy
telnet

# Add post-installation script
%post
# Configure services
# Custom services
service NetworkManager stop
chkconfig NetworkManager off
service network restart

# Eject CD-ROM
# Eject CD after installation is complete
# eject

# Reboot
# Restart after execution is complete
# reboot -f

# End of automated deployment
%end

Generating Dependencies and ISO File

Note the accuracy of paths and commands.

cd /tmp/iso
createrepo -g repodata/*comps.xml . 
mkisofs -o /tmp/CentOS-6.4_64_auto.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table  -joliet-long  -R -J -v -T /tmp/iso/

Testing and Suggestions

We recommend two reference articles. It is suggested to test repeatedly in a virtual machine before deploying on physical machines.

Linux Kickstart Automatic Installation – http://liaoph.com/linux-kickstart/
CentOS 6.4 Customized Automated Installation Disc – http://www.wpython.com/444.html

FREE CHECKUP

Free server checkup

We will send a problem checklist and remediation advice within one business day — no obligation to engage.

135 410 16684
Weekdays Mon – Fri 10:00 – 22:00 (UTC+8) · 7×24 emergency response
Call now
CONTACT

Contact Us

How can we help?

* Required