Use PXE + DHCP + TFTP + kickstart set up unattended system installation server

Principles and concepts: 

1 , What is PXE strictly speaking, is not a PXE installation, but a guided way. PXE installation of the necessary conditions is to be installed in the computer contains a PXE support for NIC (NIC), that is, the card must have a PXE Client. PXE (Pre-boot Execution Environment) protocol can be activated by causing a computer network.

Protocol is divided into client and server side, the PXE client ROM card, when the computer is booted, the PXE client into memory the BIOS executed, the PXE client will be placed at the distal end of the file is downloaded over the network to the local operation.

Run PXE protocol need to set up a DHCP server and TFTP server. DHCP server is used to PXE Client (host system will be installed) assigned an IP address, since the IP address is assigned to the PXE Client, so that when configuring the DHCP server need to add the appropriate PXE settings.

Further, the ROM of the PXE client, there has been a TFTP Client. PXE Client through the TFTP Server TFTP protocol to download the required files.

 

2 , What is the KickStart 

KickStart is an unattended installation. KickStart working principle is to generate a file named ks.cfg by recording a typical installation manual intervention required to fill the various parameters, and; (KickStart installation file generation is not limited to the machines in a subsequent installation process ) when asked to fill in the parameters of the situation appears, the installer will first go find the file KickStart generated when finding the right parameters, using the parameters found, when appropriate parameter is not found, the installer only needs manual intervention.

Thus, if the KickStart file covers all the parameters required to complete the installation process appears, the installer can only tell the installer where to take the ks.cfg file, then go do your own thing. And so installed, the installer will reboot option to reboot the system according to ks.cfg set in, and complete the installation.

Of BIOS boot sequence is: hard drives, network

 

Perform PXE + KickStart installation need content:

• DHCP server is used to assign the client IP; 

• TFTP PXE server used to store related files, such as: system boot files; 

• FTP server used to store system installation files; 

• KickStart generated ks.cfg configuration file; 

• PXE support with a host card to be installed;

First, configure the basic environment

1. Install the ftp service and open service, set up at startup

[root @ chuck ~] # yum install vsftpd -y # must be able to configure the network connection /etc/yum.repos.d 

[root @ chuck /] # systemctl start vsftpd # ftp service start 
[root @ chuck /] # systemctl enable vsftpd # set boot from Kai 
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.

2. Installation TFTP, modify the configuration file and open the tftp service

[root @ chuck /] # yum install -y tftp tftp-server xinetd # installation services and daemon services 

configured tftp server: 

vim /etc/xinetd.d/tftp 

modify the configuration file inside the 13 and 14 lines. Changed to the following: 

server_args = -s / tftpboot # indicates that the server's default directory is / tftpboot 

disable = NO

  

About the need to restart the modification is completed xinetd service, see the service port is open.

[root@chuck /]# systemctl start xinetd
[root@chuck /]# lsof -i :69
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
xinetd 2324 root 5u IPv4 35075 0t0 UDP *:tftp 

3. install dhcp, modify the configuration file and start the service

[root@chuck /]# yum install -y dhcp

  

Configuring DHCP server:

[root @ chuck /] # cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf # generate a configuration file 
cp: overwrite "/ etc / dhcp / dhcpd. conf "? y

DHCP server to add a VMNET4 card, ip to 192.168.1.10 (the segment will do as long as 1)

[root @ Chuck ~] # ifconfig ens38 192.168.1.10/24 

[root @ Chuck /] #> # /etc/dhcp/dhcpd.conf empty this configuration file, re-written. 
[@ Chuck the root /] # Vim /etc/dhcp/dhcpd.conf 

  Subnet 192.168.1.0 Netmask 255.255.255.0 { 

  Range 192.168.1.100 192.168.1.200; 

  Option-name-Domain Servers 192.168.1.1; 

  Option-Domain name "Internal. example.org "; 

  ; Routers 192.168.1.1 Option 

  Option Broadcast-address 192.168.1.255; 

  default-Lease Time-600; 

  max-Lease Time-7200; 

  Next-Server 192.168.1.10; 

  filename" the pxelinux.0 "; 

 } 
configuring , to not start DHCP, preparatory work has been completed.

Second, use PXE boot configuration required documents

install software:

Installation package

[root @ chuck /] # yum install -y system-config-kickstart && syslinux 

prepared tftp need to share files out 

[Chuck the root @ ~] # Mount / dev / CDROM / Media / 

[the root Chuck @ ~] # mkdir / tftpboot 

[Chuck the root @ ~] # mkdir the /tftpboot/pxelinux.cfg 

[Chuck the root @ ~] # CP /usr/share/syslinux/pxelinux.0 / tftpboot / # Note, only the system-config-kickstart package is installed, it there is / usr / share / syslinux / directory and the files in the directory. 

 [Chuck the root @ ~] # CP /media/images/pxeboot/initrd.img / tftpboot / 

[the root Chuck @ ~] # CP / Media / Images / pxeboot / vmlinuz / tftpboot / 

[the root Chuck @ ~] # CP / Media /tftpboot/pxelinux.cfg/default the /isolinux/isolinux.cfg 

[root @ Chuck ~] # chmod 644 /tftpboot/pxelinux.cfg/default

   

Third, modify the default, specify the installation of the operating system and the way ks.cfg file path

vim /tftpboot/pxelinux.cfg/default 

then modify /tftpboot/pxelinux.cfg/default profile. 

Change: default 

is: default linux 

# modify the first row, behind linux means 61 to find the following row label linux. As follows: 

default linux linux # modify 

and edit the line 64 (i.e., added later inst.repo = ftp: //192.168.10.10/pub inst.ks = FTP: //192.168.10.10/ks.cfg) 

the append the initrd = initrd.img inst.repo = ftp: //192.168.1.10/pub inst.ks = ftp: //192.168.1.10/sk.cfg # modify Setup configuration file by FTP server access

More than amend the default configuration file is accessed kickstart file via ftp server approach.

 

Wherein Line 1: default linux specified entry name represents the default;

Line 2: prompt 1 to prompt the user to select whether to wait set, waits for the user 1 represents a control;

18,23,27,31 first inlet guide row label linux represented definition, represents a different mounting system as defined in the inlet line 18 a graph showing the installation.

Modify configuration files over, to start the automatic installation, the installer must have access to the kickstart file.

There are several ways to access the kickstart file, the most commonly used method is through the network server,

For example: ftp server, WEB server or NFS server, this method is very easy to deploy and manage change also become very simple. You can also USB disk, CD-ROM or local hard disk. Kickstart file if the USB or CD-ROM is very easy to access, just the kickstart file is placed in the boot medium to start installation. The use DHCP and TFTP and PXE server configuration up more complex.

The mounting point kickstart file program written in the following format:

ks = ftp: // server / dir / file such as: ks = ftp: // ftp server IP / ks.cfg

ks = http: // server / dir / file as: ks = http: // http server IP / ks.cfg

ks = nfs: server: / dir / file such as: ks = nfs: nfs server IP: /var/ftp/pub/ks.cfg

ks=hd:device:/dir/file 如:ks=hd:sdb1:/kickstar-files/ks.cfg

ks=cdrom:/dir/file 如:ks=cdrom:/kickstart-files/ks.cfg

More than amend the default configuration file is accessed via ftp server approach kickstart file

Next we make kickstart unattended installation file.

 

Before creating a profile, we need to change the yum source at a local source, or select the following packages are installed in this step can not be selected, suggesting that prohibited

[root@chuck ~]# cd /etc/yum.repos.d/

[root@chuck yum.repos.d]# ls

CentOS-Base.repo      CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo  epel.repo

CentOS-Base.repo.old  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo    epel-testing.repo

[root@chuck yum.repos.d]# mkdir bak

[root@chuck yum.repos.d]# mv *.repo  bak/

[root@chuck yum.repos.d]# ls

bak  CentOS-Base.repo.old

[root@chuck yum.repos.d]# vim my.repo

[development]       

name=my-centos7-dvd

baseurl=file:///var/ftp/pub

enabled=1

gpgcheck=0

 

[root@chuck yum.repos.d]# yum makecache

Install system-config-kickstart package:

[root @ chuck ~] # system -config-kickstart # perform system-config-kickstart pop up interface. If the server is installed graphical interface can use this command to generate ks.cfg directly, if it is a minimal installation, use xmanager software xstart connection settings parameters to the late unattended installation need to be configured: 

Note: The xshell remote connection, execute the above command may fail to eject selection box, you need to be resolved: 

1. Installation GDM 

yum the install -Y GDM 
  

 

2. Xstart was performed: need to enter the server IP: 192.168.0.63 default SSH, the root = User Command: System-config-kickstart 

3. kickstart configuration window will pop up 

  language default settings installation, time zone, root password, and check the following reboot after installation. 

  Then select the installation method, using FTP installation, fill in the server address is: 192.168.1.10 directory: / pub 

  Click Boot Loader Options: install a new boot loader installation options: MBR 

  partition information: Clear the master boot record, delete all existing partitions, initialize the disk, divided / boot swap / main partition 

  network configuration default can 

  verify that the default 

  firewall all closed 

  display configuration: You can choose their own 

  custom packages: development-- check inside three sub-options.

Installation script: In the "Pre-installation Script", "post-install script" dialog box can be added separately before installation executable statement after the installation of automatic moving line. This setting allows automated server configuration easier.

For example: to automatically configure the client provided YUM warehouse after installation.

rm -rf /etc/yum.repos.d/*
echo '[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///mnt/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release' > /etc/yum.repos.d/rhel6.repo

  

All this on the installation configuration has been configured, save it: Click the top left corner of the file select Save, save under the chosen path

[root @ chuck ~] #cp ks.cfg / var / ftp # ks.cfg copy files to / var / ftp directory 

NOTE: When ks.cfg is to use the unattended installation Kickstart file. 

Corresponds to: /tftpboot/pxelinux.cfg/default file provided through ks = ftp: //192.168.1.10/ks.cfg

  

Based on the configuration of the ftp yum source for client installation package with the reading:

[Root @ chuck ~] #mount / dev / cdrom / var / ftp / pub # mount the CD-ROM to RHEL7 / var / ftp / pub directory under

Restart the FTP service under

[root @ chuck ~] # systemctl restart vsftpd 

recommend turning off the firewall and selinux, 

if not closed, then, tftp service will be problems. 

[xuegod63 the root @ ~] # getenforce 

Disabled 

setting firewall: 

# iptables -F 

arranged two machines network mode: VMnet4 

 

to a server and DHCP settings define the same IP subnet 

then start DHCP, is set to boot 

[root @ chuck /] # systemctl Start dhcpd 

[root @ Chuck /] # chkconfig dhcpd ON 
Note: the request was forwarded to the "systemctl enable dhcpd.service". 
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.

  

New Virtual Machine modify the BIOS boot order priority for the network, started after power up, boot time can also be directly F12. Follow-up can wait for the automatic installation! !

Guess you like

Origin www.cnblogs.com/LinuxBasic/p/12070889.html