Automatic Operation Koriyuki CentOS7 under pxe+kickstart+dhcp+tftp+http unattended installation system

Source: Internet
Author: User

I. Overview

1. About PXE
Preboot execution Environment Translation is the pre-boot execution environment, or PXE, the traditional way to install the operating system is CDROM or USB drive boot, and PXE technology is to solve the network boot installation system, of course, PXE technology is not a new technology, is part of the larger PC98 specification that Intel and Microsoft defined in 1998. Detailed documentation on the PXE specification

2. PXE Boot related role description
PXE function: Boot machine
Kickstart function: will install the system through the Ks.cfg file configuration information, automatic installation configuration to achieve unattended automatic installation;
TFTP: pxelinux.0 files, Vmlinuz, initrd.img and other kernel boot files are downloaded from the TFTP server on the PXE-boot network card;
The DHCP:PXE boot process obtains the IP address first, and provides the pxelinux.0 file location;
HTTP: For downloading ks.cfg and system image files
The generic unattended approach is as follows:
The PXE protocol is supported by a bare metal network card without a system, the IP and pxelinux.0 files are obtained from the DHCP server after power on and the relevant kernel boot files are loaded from the TFTP server, and the CFG configuration file of the kickstart is downloaded, the system image file location is loaded and installed, For unattended installation!
(Images from the Web):

3. Environmental Preparation Instructions
This test environment description:
PXE server: CentOS7.4 VIRTUALBOXT-based virtual machines
ip:172.16.3.152 (Internet access) internal test IP (host mode only) 192.168.56.254
Configure the service and install the package as follows:
Dhcp
Tftp
http
Syslinux package, providing boot files
All of the packages required above are installed via Yum

[[email protected] ~]# yum install  dhcp tftp tftp-server syslinux httpd -y

Firewall, SELinux shutdown, production line please open UDP tcp/80 port;

Test machine can be directly new installation CENTOS7 system note that the network to select only the host, the following description
Configure and Test next!

Second, build local installation source based on HTTPD

1, Mount CD-ROM production and installation source

##挂载CentOS7光盘[[email protected] ~]# mkdir /media/cdrom[[email protected] ~]# mount /dev/cdrom /media/cdrom[[email protected] ~]# mkdir -pv /var/www/html/centos/7/x86_64#绑定挂载到http默认目录下[[email protected] ~]#mount --bind /media/cdrom /var/www/html/centos/7/x86_64

2, Kickstart ks.cfg configuration file preparation
Making KS files from the anaconda-ks.cfg in the home directory

[[email protected] ~]# cd/var/www/html;mkdir ks[[email protected] ~]# cat ks.cfg#version=devel# System  Authorization Informationauth--enableshadow--passalgo=sha512# use CDROM installation media#cdrom# Install OS instead of upgradeinstall# Use network Installationurl--url=http://192.168.56.254/centos/7/x86_64# use graphical  installgraphical# Run the Setup Agent on first bootfirstboot--enable#ignoredisk--only-use=sda# Keyboard Layoutskeyboard --VCKEYMAP=CN--xlayouts= ' cn ' # System Languagelang zh_cn. utf-8# Network informationnetwork--bootproto=dhcp--device=enp0s3--onboot=off--ipv6=autonetwork--hostname= localhost.pkey.cn# Root passwordrootpw--iscrypted $1$lsesxuy.$7hmgy9vvxegegb98qtuuv1# System timezonetimezone Asia/ Shanghai--isutc# System bootloader configurationbootloader--append= "Crashkernel=auto"--location=mbr--boot-drive= Sdaautopart--type=lvm# Partition clearing Informationclearpart--none--initlabel%packages@^ Minimal@corekexec-toolsvimwgethttpd%end%addon com_redhat_kdump--enable--reserve-mb= ' auto '%end 

These are my reference configurations, and you can simply modify the following lines as a template:
Installed network mirroring Address:
URL--url=http://192.168.56.254/centos/7/x86_64
System Password After installation:
ROOTPW--iscrypted $1$lsesxuy.$7hmgy9vvxegegb98qtuuv1
Password can be passwd-1 "PASSWORD" via OpenSSL
The generated format is sha512 password replacement can be;
In addition, you can configure pre-installed packages between%packages and its%end after installation, which allows the program to pre-install the Wegt VIM package after installing the system, and more fun configurations
See Redhat official documentation

3. Configuration Start-up

[[email protected] ~]# systemctl start httpd[[email protected] ~]# systemct enable httpd
Third, configure the DHCP service

1. Configure DHCP Service
DHCP configuration file in the/etc/dhcp/directory, the default profile is not, but we can find the template sample file in the Help file to modify it

[[email protected] ~]#  cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf[[email protected] ~]# egrep -v ‘(^$|^#)‘ /etc/dhcp/dhcpd.confoption domain-name "pkey.cn";option domain-name-servers 192.168.56.1;default-lease-time 600;max-lease-time 7200;log-facility local7;subnet 192.168.56.0 netmask 255.255.255.0 {    range dynamic-bootp 192.168.56.110 192.168.56.120;    option routers 192.168.56.1;    next-server 192.168.56.254;    #tftp server也是本机,可以分开  filename "pxelinux.0";               #引导文件}

2. Start and view

[[email protected] ~]# systemctl start dhcpd[[email protected] ~]# systemctl enable dhcpd查看服务状态,已经监听在UDP   67上[[email protected] ~]# ss -tunlNetid  State      Recv-Q Send-Q       Local Address:Port                      Peer Address:Port              udp    UNCONN     0      0                        *:55770                                *:*                  udp    UNCONN     0      0                        *:47150                                *:*                  udp    UNCONN     0      0                        *:67                                   *:*                  
Iv. Configuring the TFTP service

After installing the Tftp-server package, the default data root directory is/var/lib/tftpboot/without modification, just need to copy some software boot files to come in.
1. Preparation of relevant documents

##引导文件[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/  #内核文件[[email protected] ~]# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot#引导菜单[[email protected] ~]# cp /usr/share/syslinux/{chain.c32,mboot.c32,menu.c32,memdisk} /var/lib/tftpboot#制件引导默认文件[[email protected] ~]# mkdir -pv /var/lib/tftpboot/pxelinux.cfg[[email protected] pxelinux.cfg]# cat default default menu.c32   prompt 5   timeout 30   MENU TITLE CentOS 7 PXE Menu   LABEL linux   MENU LABEL Install CentOS 7 x86_64   KERNEL vmlinuz   APPEND initrd=initrd.img inst.repo=http://192.168.56.254/centos/7/x86_64 ks=http://192.168.56.254/ks/ks.cfg

2. Boot Configuration Boot

[[email protected] tmp]# systemctl enable tftp[[email protected] tmp]# systemctl start tftp

3. TFTP test
/var/lib/tftpboot/Directory File Structure

结构查看[[email protected] tftpboot]# tree -L 2.├── chain.c32├── initrd.img├── mboot.c32├── memdisk├── menu.c32├── pxelinux.0├── pxelinux.cfg│?? └── default└── vmlinuz测试tftp[[email protected] tmp]# pwd;ls/tmp[[email protected] tmp]# tftp 192.168.56.254tftp> get vmlinuztftp> quit[[email protected] tmp]# pwd;ls/tmpvmlinuz
Five, PXE unattended installation test

1, modify the VirtualBox network
Manage--Global settings--Network--"host only (host-only) network"-double-click Vboxnet0 to turn off the VirtualBox-only DHCP service that comes with the host network:

2. Create a new virtual machine
And the only difference between installing virtual with CDROM is that you do not mount the image, only the network type of the new virtual machine is "host (host-only) network":

Power on--press F12 to select LAN boot:


The next step is to be familiar with the graphical automatic installation process! The whole installation system process is basically five or six minutes, depending on how much the installation package and the network performance of the system depends on, want to know the specific process, try it yourself!

Summarize:

The above is based on the PXE protocol and syslinux boot files, kickstart configuration files, dhcp,tftp-server,httpd services to make local installation source collaboration completed unattended installation system, you can also add CentOS6 installation in this set of environments, Just add the Modify profile!

Automated Koriyuki CentOS7 pxe+kickstart+dhcp+tftp+http unattended installation system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.