Linux PXE-based system automatic unattended installation

Source: Internet
Author: User

Objective

In a production environment, we often need to install the operating system on multiple client hosts or servers, and if each is manually installed, Time- consuming and laborious, is obviously unrealistic. So, how to do this kind of work efficiently? This article will explain how to realize the automatic unattended installation of Linux system .

Installation package required for PXE service

DHCP: Dynamic Host Configuration Protocol, providing IP addresses to clients

Tftp-server:tftp server-side, providing the required files for system installation

XINETD:TFTP Service Super Daemon for wake-up TFTP service

HTTPD: Provide installation source based on HTTP service

Syslinux: Provides the pxelinux.0 file, which is used to boot the system, equivalent to Bootloader

Install the required installation package

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/28/wKiom1UbkXmSx0KHAACUq2eo8eM944.jpg "title=" 1.jpg " alt= "Wkiom1ubkxmsx0khaacuq2eo8em944.jpg"/>

DHCP service configuration

The configuration file for the DHCP service is/etc/dhcp/dhcpd.conf by default, but this file is not configured by default, and this service provides a Reference file/usr/share/doc/dhcp*/dhcpd.conf.sample, copy this file overwrite the original configuration file, directly modify.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/1F/wKioL1UbYNmzsnXlAAB9C9saglA110.jpg "title=" 2.jpg " alt= "Wkiol1ubynmzsnxlaab9c9sagla110.jpg"/>

#option  domain-name  "scholar.com";               #分配dns域 #option domain-name-servers 172.16.10.10;      # Assigning DNS addresses #default-lease-time 600;                         #默认租约时长 #max-lease-time 7200;                             #最大租约时长 # above for DHCP global configuration, if only for implementing PXE can default Subnet 172.16.0.0 netmask  255.255.0.0 {         #提供dhcp服务的网段   range  172.16.10.20 172.16.10.100;             #地址池   option routers 172.16.0.1;                     #网关   next-server 172.16.10.10;                      #tftp服务器地址    filename  "pxelinux.0"                           #PXE引导文件} #以下仅为介绍dhcp特殊配置, no need to configure #host winxp  {                                   # Set reserved private address #  hardware ethernet 00:0c:29:50:29:02;          #保留主机物理地址 #  fixed-address 172.16.100.2;                   #保留地址, non-address in-pool address, priority allocation #}

After the DHCP service configuration is complete and the test configuration has no syntax errors, start the service and set the boot

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/25/wKiom1Ubag_wC6tDAABzWfrWaNg003.jpg "title=" 3.jpg " alt= "Wkiom1ubag_wc6tdaabzwfrwang003.jpg"/>

DHCP works on the UPD 67 port, and after starting the service, you can see if port 67 is turned on

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/26/wKiom1UbaxOg9h72AAAtz-rjlUY403.jpg "title=" 4.jpg " alt= "Wkiom1ubaxog9h72aaatz-rjluy403.jpg"/>

TFTP service configuration

xinetd is the Super daemon for TFTP, That is, TFTP is a sub-service of XINETD, modifying the configuration file to ensure that the TFTP service is not disabled.

[[email protected] ~]# vim /etc/xinetd.d/tftpservice tftp{         socket_type              = dgram        protocol                 = udp         wait                     = yes        user                     =  root        server                   = /usr/sbin/in.tftpd         server_args             = -s /var/lib/ tftpboot        disable                  = no    #确保此项为no          per_source               = 11        cps                      =  100 2        flags                    = ipv4}

After modifying the configuration file, start the xinetd process and set the TFTP service to boot

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/5C/22/wKioL1UbjUyzZubyAABKO79neA8702.jpg "title=" 4.1. JPG "alt=" wkiol1ubjuyzzubyaabko79nea8702.jpg "/>

TFTP works on UDP port 69, and after starting the service, you can see if Port 69 is turned on

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5C/22/wKioL1UbjyCQlKFgAAAtzRQJOaw699.jpg "title=" 4.2jpg.jpg "alt=" Wkiol1ubjycqlkfgaaatzrqjoaw699.jpg "/>

Note: Please turn off fire or set rules to allow access to port 69, or the TFTP service will not be accessible.

Provide boot kernel and other files

Copy the required files for PXE from the mounted CD to the TFTP working directory (default is/var/lib/tftpboot)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/22/wKioL1Ubh9XwliaJAAIj9Fximd8919.jpg "title=" 5.jpg " alt= "Wkiol1ubh9xwliajaaij9fximd8919.jpg"/>

Providing a PXE working environment

Copy the pxelinux.0 file (provided by the Syslinux package and need to be installed in advance) to the TFTP working directory

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/27/wKiom1UbiELDPScuAACVPI0qz9E749.jpg "title=" 6.jpg " alt= "Wkiom1ubieldpscuaacvpi0qz9e749.jpg"/>

Provide installation source

There are many services available for the installation source, such as HTTP, FTP, NFS, and so on, and we do this based on the HTTP service. Create a directory that is used specifically for the installation source in the HTTP service's working directory and bind it to the mounted disc directory.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/23/wKioL1Ublt7DVHfXAAFNC1dGbqI177.jpg "title=" 7.jpg " alt= "Wkiol1ublt7dvhfxaafnc1dgbqi177.jpg"/>

Start the HTTP service and set the boot, the HTTP service works on TCP port 80, and after starting the service, you can see if port 80 is turned on.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/29/wKiom1UbnVrTMRWrAACnPGsa5TQ766.jpg "title=" 8.jpg " alt= "Wkiom1ubnvrtmrwraacnpgsa5tq766.jpg"/>

Provide kickstart file

The kickstart file can be created on its own (requires installation of S Ystem-config-kickstart.noarch Tools ), you can also copy system files directly and then modify. Here we do not demonstrate the creation process, directly copy the file modification (this file is/root/anaconda-ks.cfg)

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5C/25/wKioL1Ubr7HjntkkAADbIfrxN2w296.jpg "title=" 9.jpg " alt= "Wkiol1ubr7hjntkkaadbifrxn2w296.jpg"/>

#修改或添加以下两项, the destination points to the installation source URL--url=http://172.16.10.10/rhel6.6repo--name= "Redhat"--baseurl=http://172.16.10.10/rhel6.6 --cost=100

To be able to load the kickstart file at startup, you also need to modify the/var/lib/tftpboot/pxelinux.cfg/default file to add the KS the location of the pieces.

[[email protected] ~]# vim/var/lib/tftpboot/pxelinux.cfg/defaultlabel Linux menu label ^install or upgrade an existing s Ystem Menu Default kernel vmlinuz append initrd=initrd.img ks=http://172.16.10.10/ks.cfg #指向ks文件

Start test

Set the host for the system to be installed as a network card boot

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/25/wKioL1UbtjzCjQ6xAADX247iCUI784.jpg "title=" 10.jpg "alt=" Wkiol1ubtjzcjq6xaadx247icui784.jpg "/>

Boot start

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/2C/wKiom1UbzT7x_aErAALbzSh8VDM912.jpg "title=" 11.jpg "alt=" Wkiom1ubzt7x_aeraalbzsh8vdm912.jpg "/>

Boot successfully started to install various packages

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/27/wKioL1Ub0DLjEFNcAAEjkuBiBxw070.jpg "title=" 13.jpg "alt=" Wkiol1ub0dljefncaaejkubibxw070.jpg "/>

Installation successful, view IP address

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5C/2B/wKioL1Ub1wexaydqAAIp12bqL-A876.jpg "title=" 14.jpg "alt=" Wkiol1ub1wexaydqaaip12bql-a876.jpg "/>

The end

Well, the above is the entire process of automatic unattended installation based on PXE, if the kickstart file cannot be downloaded at boot, check if there is a DHCP conflict in the network, or if SELinux is turned off. Only for individual learning to organize, if there are mistakes, big God do not spray ~ ~ ~

This article is from the "North Scholar" blog, please make sure to keep this source http://scholar.blog.51cto.com/9985645/1627450

Linux PXE-based system automatic unattended installation

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.