Linux automatic installation system working process introduction:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/95/wKiom1eVpIyQRxjlAAB1YsRrCVc569.png "title=" Pxe.png "alt=" Wkiom1evpiyqrxjlaab1ysrrcvc569.png "/>
The PXE client interacts primarily with 3 different types of servers and obtains relevant information before it can automatically install the system.
The first step is to PXE Client with DHCP Server
If it is a physical machine, start the calculator in PXE mode in the BIOS setup. At this point the computer sends a broadcast request over the network, requesting information such as an IP address to be assigned through the DHCP server. When the DHCP server receives a request from the client and verifies it, it returns to the client request and tells the client about the IP address, TFTP server information, and some profile information to allow the client to continue the operation.
Step two PXE Client with TFTP Server
After the client receives the information, it then requests the TFTP server to send the required files for the system installation, including pxelinux.0, Pexlinux.cfg/default (kernel boot file), Vmlinuz, initrd.img. After the TFTP server receives the client's request, the server, bootrom (diskless boot interface), launches the Linux installer boot kernel based on the profile information after the installation of the required files downloaded from the TFTP server.
Third step PXE Client vs. NFS Server
After the client installs the Linux kernel, the installer needs to get what media you have installed Linux, can be installed through the network, through the nfs,ftp,http, etc., then initialize the network, then locate the binary package and the location of the configuration file, Then read the automatic answer file ks.cfg, according to KS.CFG configuration information to obtain the system installation package and installation, after the installation is complete restart, remember to adjust from the BIOS to the hard drive boot.
In this case, the automated installation of the Linux system basically completed, in this process is basically the construction of each server, the actual installation of the system does not need to choose what, like a button to install MySQL, as long as the execution of a script is good.
In summary, the PXE network installation system requires the following steps, in the Order of deployment:
① Configure Server for NFS to store installation files for Linux systems.
② configures the TFTP server to provide the necessary files for client boot. Web server can also be used to replace, practice can also achieve results, but this experiment with the TFTP server practice.
③ configures the DHCP server to provide clients with IP addresses and other information.
④ configuration Kickstart for auto-answer installation.
The ⑤ uses the PXE feature to boot the client installation.
The first four of these five steps are installed on the server side, can be placed on different servers, can also be placed on the same server, where I put the server on the same server, and then with a client experiment, of course, these operations can also be done on the virtual machine, the difference is not small. Next we describe the installation of each server.
Attention!! This build process is completed on the virtual machine.
[NFS Installation]
Configure Server for NFS to store installation files for Linux systems.
Mount the optical drive to the MNT directory. or upload the contents of the ISO image file to the shared directory.
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/84/96/wKioL1eVq_nw-fWAAABq-NJO0y0471.png "title=" QQ picture 20160725140426.png "alt=" Wkiol1evq_nw-fwaaabq-njo0y0471.png "/>
After the mount is complete, a/data/sys directory is created, Ready for NFS sharing.
[Email protected]_2sys]# pwd
/data/sys #共享目录
[[Email protected]_2dev]# mount/dev/cdrom/mnt
Mount:/dev/sr0 write protection, will be mounted as read-only
Copy the content under the MNT to the shared directory.
[Email protected]_2sys]# cp-a/mnt/*/data/sys/
Port mapping of a tool, in the Centos7 Portmap changed to Rpcbind, the function has not changed
Rpcbind for dynamically assigning Ports to NFS connections
[Email protected]_2 ~] #systemctl Restart Rpcbind.service
[Email protected]_2 ~] #systemctl Restart Nfs.service
[Email protected]_2 kickstart]# showmount-e 192.168.131.132 #检查共享目录
Export list for 192.168.131.132:
/data/sys 192.168.131.0/24
[tftp installation]
Install TFTP server, direct yum install tftp-server*, install TFTP will install a xinetd package dependency. Because TFTP is managed by xinted.
For TFTP server operations, only the TFTP configuration file needs to be modified:
[Email protected]_2 ~]# 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 #tftp文件存放目录
Disable = no = "Say yes to No
Per_source = 11
CPS = 100 2
Flags = IPV4
}
[ Configure PXE Linux]
[Email protected]_2isolinux]# sed-i ' s#keepalive=0#keepalive=1#g ' yum.conf
Modify this parameter to save the package after Yum is installed.
[Email protected]_2pxeboot]# yum install-y syslinux
[Email protected]_2pxeboot]# rpm-ql syslinux|grep/pxelinux.0
/usr/share/syslinux/pxelinux.0
[Email protected]_2pxeboot]# cp ' RPM-QL syslinux|grep/pxelinux.0 '/var/lib/tftpboot/
Copy the images/pxeboot/{Initrd.img,vmlinuz} from the system installation directory to tftpboot at the same time
[Email protected]_2 pxeboot] #cp initrd.img vmlinuz/var/lib/tftpboot/
This is the kernel boot configuration file.
[Email protected]_2 isolinux] #cp isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default
Here to modify the default file, easy to install later
I will only have a modified part of the post, for your reference, if there is a need to see for yourself.
[Email protected]_2 pxelinux.cfg]# Cat Default
Default Linux
Prompt 1
Timeout 600
......
Labellinux
Menu Label ^install CentOS 7
Kernel Vmlinuz
# Append Initrd=initrd.img inst.stage2=hd:label=centos\x207\x20x86_64quiet
Append ks=http://192.168.131.132/ks.cfg initrd=initrd.img
# Appendks=nfs://192.168.131.132:/data/sys/kickstart/ks.cfg initrd=initrd.img
There are 2 options, you can use NFS, or HTTP, I have 2 kinds of modification methods are written out.
" default Startup File "
[Email protected]_2/]# cd/var/lib/tftpboot/
[Email protected]_2 tftpboot]# LL
Total Dosage 42672
-r--r--r--. 1 root root 38508192 7 Month 10:02initrd.img
-rw-r--r--. 1 root root 26771 7 Month 10:11pxelinux.0
drwxr-xr-x. 2 root root 7 Month 13:09pxelinux.cfg
-r-xr-xr-x. 1 root root 5156528 7 Month 10:02vmlinuz
[Email protected]_2 tftpboot]# CD pxelinux.cfg/
[Email protected]_2 pxelinux.cfg]# LL
Total Dosage 8
-rw-r--r--. 1 root root 3095 7 Month 11:31default
[ Install DHCP server]
Direct Yum installation, modify configuration file.
[[Email protected]_2~]# vim/etc/dhcp/dhcpd.conf
Ddns-update-stylenone;
Ignoreclient-updates;
Allow booting
Allow BOOTP
Default-lease-time 21600;
Max-lease-time 43200
Option Routers 192.168.131.2
Subnet 192.168.131.0 netmask 255.255.255.0 {
Range FROMDYNAMIC-BOOTP 192.168.131.140 192.168.131.150;
Next-server 192.168.131.132;
FileName "/data/sys/kickstart/ks.cfg";
next-server192.168.131.132;
FileName "pxelinux.0" #这里需不需要写绝对路径也不确定, can write or do not write, see the actual situation
}
After modifying the configuration file, restart it.
[Kickstart]
The last step to configure the Ks.cfg file, do not know that you have not noticed, in the virtual machine installed after the Linux system, in the root home directory has a anaconda-ks.cfg file, this is the local installation of the configuration file, the local installation of the record, whether graphical, disk partition Ah, initialize the network card, create root The user and password are here, so this time we use this configuration file as the KS profile installation.
[Email protected]_2 ~]# mkdir-p/data/sys/kickstart
[Email protected]_2 ~]# CP anaconda-ks.cfg/data/sys/kickstart/ks.cfg
[[Email protected]_2 kickstart]# chmod 644 ks.cfg #注意, do not set to 777 similar permissions and may get failed.
Ks files are information that is installed at the time of the system installation, and PXE client installs the system according to this profile.
[Email protected]_2 kickstart]# Cat Ks.cfg
#version =devel
# System Authorization Information
Auth--enableshadow--passalgo=sha512
Install
NFS--server=192.168.131.132--dir=/data/sys
# Use graphical Install
Text
# Run The Setup Agent on first boot
Firstboot--enable
......
It's basically done here, and then you can customize the installation of a virtual machine to try to install it.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/84/97/wKioL1eVsuPyOBLcAABcpWSbeYA191.png "title=" 123213.png "alt=" Wkiol1evsupyoblcaabcpwsbeya191.png "/>
Here is a problem I encountered in the installation, get here to analyze, first of all to exclude the firewall and other problems, because I have been all closed, according to the prompt client has obtained the IP address, connected to the TFTP, found that the file does not exist, Here is the pexlinux.0 file I mentioned above need not write the absolute path of the file, I removed the path and restart the installation succeeded.
About the Ks.cfg file, can be like me directly copy the original existing files, of course, can also be configured, the equivalent of the system you encountered in the installation of the information you want to choose, such as character sets, partitions, add users, all concentrated into the KS.CFG, the client installation only need to according to the KS configuration file on the line, all the way down Until the installation is complete.
The whole process is generally so, the specific details of the problem is not particularly understanding, there is a bad place to write, please in the comments middle finger out, study together, progress together!
This article comes from the "stop walking equals to chronic death" blog, so be sure to keep this source http://goforward.blog.51cto.com/11169198/1829648
Unattended automated installation of Linux systems