Automated Installation and Deployment of Linux Operating System Using CD-ROM iso

Keywords: Linux CentOS firewall SELinux network

In the front, I wrote an article about how to install the operating system in batches by PXE. It is not always possible to install the operating system by PXE anywhere. If you need to install it on CD-ROM at this time, by default, it is installed by interactive mode. In fact, you can also achieve automatic installation and deployment by kickstart mode. The installation of CD-ROM through ks.cfg is relatively simple, and the following is a simple summary.

I. Realization Principle

The operating system is installed by reading the ks.cfg file. The ks.cfg configuration file can be placed in the root directory of the CD, then the isolinux/isolinux.cfg file can be modified, the kernel parameters can be set, and the location of the ks.cfg file can be specified. Because the original iso image file is read-only, it can not be modified directly in the iso CD directory file, so it needs to be copied to a temporary directory and encapsulated as an iso image file after modification.

II. Copy Mirror Temporary Directory

mkdir /mnt/cdrom
mount -o loop CentOS-6.8-x86_64-minimal.iso /mnt/cdrom
cp -ar /mnt/cdrom/ /root/iso    # Originally there was no ISO directory under root, and it was copied and renamed iso.

3. Generating ks.cfg files

There are about two ways to generate ks.cfg files. One is to customize and generate the specified ks.cfg files through the graphics tool system-config-kickstart. The other is to write the ks.cfg configuration files directly for those who are familiar with kickstart grammar. The configuration of ks. CFG used in this experiment is relatively simple. It is generated by tools. The ks. cfg file is given below.

#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Root password
rootpw --iscrypted $1$p6oEoqGo$UDHZdzw56Rl6Rt5oi1A0Q1
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Do not configure the X Window System
skipx
# Installation logging level
logging --level=info
# Reboot after installation
#reboot
# System timezone
timezone --isUtc Asia/Shanghai
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel 
# Disk partitioning information
part /boot --asprimary --fstype="ext4" --ondisk=sda --size=200
part swap --asprimary --fstype="swap" --ondisk=sda --size=4096
part / --asprimary --fstype="ext4" --grow --ondisk=sda --size=1

Copy to the CD Mirror Root Directory:

/bin/cp ks.cfg /root/iso/

IV. Modifying the Startup Menu Kernel Parameters

Modify the menu item configuration file isolinux/isolinux.cfg:

default vesamenu.c32
#prompt 1
timeout 1    # Timeout automatically select menu time settings, set to 1:00, that is, flash by, set to 3 seconds.

Modify the kernel parameters to specify the location of ks.cfg:

label linux
  menu label ^Install CentOS 6.8 x64 System.    # Customized menu
  menu default
  kernel vmlinuz
  append initrd=initrd.img ks=cdrom:/ks.cfg     # Location of ks file added: root directory of CD-ROM

5. Encapsulating iso Mirror Files

cd /root/iso/    # Enter the mirror catalogue

If there is no mkisofs command, execute the installation:

yum install mkisofs -y

Execute the command to encapsulate the image:

mkisofs -o /root/CentOS6.8_x64.iso \
    -V centos6 -b isolinux/isolinux.bin \
    -c isolinux/boot.cat \
    -no-emul-boot -boot-load-size 4 \
    -boot-info-table -R -J -T -v .

Check and write md5 values (optional):

implantisomd5 /root/CentOS6.8_x64.iso

Automated installation through CD-ROM has been completed. The next test can be done by importing iso image through virtual machine.

Posted by scotch33 on Sat, 30 Mar 2019 19:24:29 -0700