PXE + Kickstart unattended installation of the operating system

What is kickstart

kickstart an unattended installation of the operating system, he works is to record various parameters of human intervention to fill in the installation process, and will generate a ks.cfg file, if present in process automation installation need to fill in the case of the election parameters, the installer will look for ks.cfg, if the corresponding parameter is found, using the parameters of the match, if not found, you will need to manually fill. So, if the ks.cfg file covers the required parameters, then the installation will be able to tell the system where to download ks.cfg file, then you can wait for the installation.

What is PXE

PXE (preboot execute environment, pre-boot execution environment) is the latest technology developed by Intel Corporation, working in network mode Client / Server, support for workstation download images from a remote server over the network, and thus support the launch of the operating system via the network, during startup, the terminal requires the server to assign an IP address, and then TFTP (trivial file transfer protocol) or MTFTP (multicast trivial file transfer protocol) protocol to download a package to start the machine's memory performed by this software package start terminal (client) basic software provided to guide the terminal operating system pre-installed in the server. PXE can boot multiple operating systems. PXE boot may be multiple operating systems, such as: Windows95 / 98/2000 / windows2003 / windows2008 / winXP / win7 / win8, linux series system.

Preparing the Environment

lab environment vmware Workstation12
the system platform CentOS6.9 graphical
Network mode NAT
Firewall iptables:not running,selinux:disabled

Ready to work

If you do not have a graphical interface, you can perform online installation graphical interface in accordance with the following

yum groupinstall "X Window System"
yum groupinstall "Desktop"
yum groupinstall chinese-support
reboot

HTTP installation

yum install -y httpd
rpm -qa|grep httpd
/etc/init.d/httpd start
chkconfig --level 35 httpd on

Load ISO image

Here Insert Picture Description
Here is a selection of mirrors which system to choose which image to install

  • Copy the contents of mirroring support html directory
[root@lcx ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        19G  2.3G   16G  14% /
tmpfs           491M  224K  491M   1% /dev/shm
/dev/sda1       477M   35M  417M   8% /boot
/dev/sr0        3.7G  3.7G     0 100% /media/CentOS_6.9_Final
[root@lcx ~]# cp -r /media/CentOS_6.9_Final/ /var/www/html/

The TFTP

yum install tftp-server -y
  • start up
vim /etc/xinetd.d/tftp
service tftp 
{ 
        socket_type             = dgram 
        protocol                = udp 
        wait                    = yes 
        user                    = root 
        server                  = /usr/sbin/in.tftpd 
        server_args             = -s /var/lib/tftpboot 
        disable                 = no 
        per_source              = 11 
        cps                     = 100 2 
        flags                   = IPv4 
}

PEX boot configuration support program

[root@lcx ~]# cp /usr/share/syslinux/{pxelinux.0,vesamenu.c32} /var/lib/tftpboot/

Copy the iso image of vmlinux and initrd.img to the specified file

[root@lcx ~]# cp /var/www/html/CentOS_6.9_Final/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/

ISO image is copied to a specified file * .msg

[root@lcx ~]# cp /var/www/html/CentOS_6.9_Final/isolinux/*.msg /var/lib/tftpboot/
  • Pxelinux.cfg a new directory in / var / lib / tftpboot / in
[root@lcx ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@lcx ~]# cp /var/www/html/CentOS_6.9_Final/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  • Modify the default file
vim /var/lib/tftpboot/pxelinux.cfg/default
default ks
prompt 1
timeout 6

display boot.msg

menu background splash.jpg
menu title Welcome to CentOS 6.9!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000

label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append initrd=initrd.img
label rescue
  menu label ^Rescue installed system
  kernel vmlinuz
  append initrd=initrd.img rescue
label ks
  kernel vmlinuz
  append ks=http://10.0.0.200/ks.cfg initrd=initrd.img ksdevice=eth0
label local
  menu label Boot from ^local drive
  localboot 1
label memtest86
  menu label ^Memory test
  kernel memtest
  append -

DHCP installation

yum install -y dhcp
  • Dhcp modify configuration files
[root@lcx ~]# vim /etc/dhcp/dhcpd.conf 

# ******************************************************************
# Cobbler managed dhcpd.conf file
# generated from cobbler dhcp.conf template (Tue Sep 25 06:55:49 2018)
# Do NOT make changes to /etc/dhcpd.conf. Instead, make your changes
# in /etc/cobbler/dhcp.template, as /etc/dhcpd.conf will be
# overwritten.
# ******************************************************************

ddns-update-style interim;

allow booting;
allow bootp;

ignore client-updates;
set vendorclass = option vendor-class-identifier;

option pxe-system-type code 93 = unsigned integer 16;

subnet 10.0.0.0 netmask 255.255.255.0 {
     option subnet-mask         255.255.255.0;
     range dynamic-bootp        10.0.0.100 10.0.0.254;
     default-lease-time         21600;
     max-lease-time             43200;
     next-server                10.0.0.200;
     class "pxeclients" {
          match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
          if option pxe-system-type = 00:02 {
                  filename "ia64/elilo.efi";
          } else if option pxe-system-type = 00:06 {
                  filename "grub/grub-x86.efi";
          } else if option pxe-system-type = 00:07 {
                  filename "grub/grub-x86_64.efi";
          } else {
                  filename "pxelinux.0";
          }
     }

}

# group for Cobbler DHCP tag: default
group {
}
  • Start dhcp
/etc/init.d/dhcpd start

Kickstart installation

yum install system-config-kickstart
  • Start a kickstart in the graphical interface
startx
system-config-kickstart

Here Insert Picture Description

  • Mounting Options HTTP
    Here Insert Picture Description
  • Partitioning Setup
    Here Insert Picture Description
  • Network Configuration
    Here Insert Picture Description
  • Authentication Configuration
    Here Insert Picture Description
  • Firewall Configuration
    Here Insert Picture Description
  • Graphic environment configuration
  • You need to install software packages
    Here Insert Picture Description
  • Preview
    Here Insert Picture Description
    Here Insert Picture Description
  • Generating ks.cfg file saved to / var / www / html / folder
    Here Insert Picture Description
    Here Insert Picture Description
    Enter to save
  • Edit the file ks.cfg
[root@lcx ~]# vim /var/www/html/ks.cfg 
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://10.0.0.200/CentOS_6.9_Final"
# Root password
rootpw --iscrypted $1$lJSsh5pq$MAcK5hMrCQkUYXCR0dnjC/
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone  Africa/Abidjan
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
key --skip
bootloader --append="rhgb quiet" --location=mbr --driveorder=sda 
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part / --fstype="ext4" --size=2048
part /home --fstype="ext4" --size=1024

%packages
@mysql-client

%end

If the system key --skip Red Hat, this option to skip the input process number; if Centos series, this content may not be retained
reboot this option must exist, it must be set to a position in the text, or display a message kickstart and waits for the user to press any key to reboot after
clearpart --all --initlable This command must be added, otherwise the system will let the user choose whether to clear all the data manually, which requires human intervention, and resulting in an automated process fails

test

  • Add a new virtual machine, network mode selection nat
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    Here Insert Picture Description
    specify a disk size, ks.cfg file, we define / size of 2GB, / home partition to 1GB, so here's disk size must be at least 3GB. Also, be sure to check the "allocate all disk space now", or at a later time when you will be prompted to install no disk space.
    Here Insert Picture Description
  • After completion you can start testing the new
    Here Insert Picture Description

Guess you like

Origin blog.csdn.net/qq_33235529/article/details/88249848