CentOS 7 Pxe+kickstart+tftp+vsftp+bios+uefi

Source: Internet
Author: User
Tags chrony saltstack


Tag: Ima Mat Master action address automatically installs log memory host


Objective


In general, the new server is on the shelves. Requires the system administrator to manually install the system, configure the IP address, and then remotely log on to the server for software installation, configuration and other management. This way, in the case of a few servers, is normal. Imagine, if hundreds of servers on the shelves, and then install the operating system in turn, will be a disaster. It is difficult to successfully shelves and configure the server within the specified time.



This requires the server IP address and hostname to be managed in the Dhcp+dns mode in a large room. Before the server is shelves, configure the host to retain and assign the host name in DHCP, based on its MAC address. DHCP, in conjunction with the PXE service provided by TFTP, provides the PXE boot Linux kernel and boot image, and automates the installation and configuration of the operating system through automatic answer files. As far as Linux is concerned, starting the Saltstack client Salt-minion service after installation will enable the new server to be automatically controlled. The rest of the installation services can be done through saltstack. From start to finish, you will not be able to access the new server via SSH and can automate the installation and configuration management of the package.


Theory description automatic Start installation process


The server is centrally managed from the first power-up to the Salt-master host, following a series of processes:


    1. The system administrator binds its MAC address to a specific IP address and host name in the DHCP server and specifies the PXE boot file.
    2. The server is power-up, obtains the IP address via PXE, and loads the pxeclient, obtaining the Linux kernel and initializing the boot image as TFTP.
    3. The server loads the auto-answer script and gets the package through the network to install the Linux system automatically. Install and boot the Salt-minion service.
    4. After the server installation is complete and restarted, the IP address is automatically obtained and the connection Salt-master request is controlled.
    5. After Salt-master control the new server, install the package Configuration service automatically with the Administrator configuration template to manage the new host.


The above process we need to set up the service has DNS, DHCP, TFTP, http/ftp services. Where DHCP and DNS provide address and hostname assignment, TFTP provides a PXE boot image, and http/ftp as a Linux repository provides the packages needed during installation.


DHCP Option 60


DHCP Option Vendor Class identifier is the vendor class identifier. This option acts on the client to optionally identify the client vendor type and configuration. This information is n 8-bit encoded and resolved by the DHCP service side. The vendor may choose to define special vendor class identifier information for the client to express special configuration or other information about the client. For example, this identifier may encode the client's hardware configuration. The class specification information that the client sends over to the server that cannot be resolved must be ignored (although there may be a report). Server response to Vendor specification information to the client should only be done by option 43来.



This information needs to be defined at the DHCP server, through which the DHCP server determines whether the client is pxeclient. And through its arch code to determine its platform, as a basis to provide different PXE boot program to the client.


PXE and GPXE


Pxe:



(Preboot execute environment, pre-boot execution Environment) is the latest technology developed by Intel Corporation, working in the network mode of client/server, enabling workstations to download images from remote servers over the network and thereby support booting the operating system over a network. During the boot process, the BIOS calls the pxeclient into memory and then the IP address is requested by pxeclient to the DHCP server, and then the TFTP or MTFTP protocol is used to download a boot package to the native memory for execution by this boot package to complete the terminal basic software setup, This directs the terminal operating system to be pre-installed in the server.



GPXE:



is an open-source network launcher. It provides a direct PXE alternative and provides a number of additional features such as DNS, HTTP, iSCSI, and more. In addition, there is a commercial takeover risk due to GPXE. Its developers have launched an open source project called Ipxe . As a branch of GPXE. IPXE supports multiple start-up methods such as HTTP, ISCSI, FCoE, Wi-Fi, InfiniBand, and more. Scripts are also supported to control the startup process.


BIOS and UEFI


Bios:



(Basic input/output system abbreviation, Chinese: base input and output systems), on the IBM PC compatible machine, is an industry standard firmware interface. The word BIOS appears in 1975 for the first time by the cp/m operating system. The BIOS is the first software that is loaded when a PC is started.



The BIOS is used to perform a self-test of each part of the system when the computer is powered on, and to boot the bootloader or the operating system loaded in memory. In addition, the BIOS provides some system parameters to the operating system. System hardware changes are hidden by the BIOS, and the program uses the BIOS service instead of directly accessing the hardware. The modern operating system ignores the abstraction layer provided by the BIOS and accesses the hardware components directly.



  



UEFI:



The full name "Unified Extensible Firmware Interface" (Unified extensible Firmware Interface) is a standard that describes the type interface in detail. This interface is used by the operating system to automatically load from a pre-boot operating environment onto an operating system.



The Extensible Firmware Interface (extensible Firmware Interface,efi) is the recommended standard for Intel's architecture, interfaces, and services for PC firmware. Its primary purpose is to provide a set of correctly specified startup services that are consistent across all platforms before the OS is loaded, and are seen as a successor to the BIOS with a history of nearly more than 20 years.



Also, because UEFI does not support 32-bit, the UEFI section discusses only the x64 platform. The Itanium architecture is not supported because there is no experimental environment.






All services required for installation



Yum install TFTP tftp-server DHCP xinetd syslinux





DHCPD configuration file






option Space PXE;
Option PXE.MTFTP-IP Code 1 = ip-address;
Option Pxe.mtftp-cport Code 2 = unsigned integer 16;
Option Pxe.mtftp-sport Code 3 = unsigned integer 16;
Option Pxe.mtftp-tmout Code 4 = unsigned integer 8;
Option Pxe.mtftp-delay Code 5 = unsigned integer 8;
Option Client-system-arch code = unsigned integer 16;





Allow booting;
Allow BOOTP;





Default-lease-time 6000;
Max-lease-time 72000;





Subnet 10.1.1.0 netmask 255.255.255.0 {
Range 10.1.1.50 10.1.1.70;
Option routers 10.1.1.11;
Class "Pxeclients" {
Match if substring (option vendor-class-identifier, 0, 9) = "Pxeclient";
Next-server 10.1.1.11;
If option Client-system-arch = 00:07 or option Client-system-arch = 00:09 {
FileName "Bootx64.efi";
} else {
FileName "pxelinux.0";
}
}
}






TFTP configuration file


Sed-i '/disable/s/yes/no/'/etc/xinetd.d/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
}

Create the desired directory in Tftpboot


  • mkdir/var/lib/tftpboot/pxelinux.cfg/
  • Default menu file directory used by BIOS boot
  • 1 UI pxelinux.cfg/vesamenu.c32
     2 prompt 1
     3 timeout 60
     4 
     5 display pxelinux.cfg/boot.msg
     6 menu background pxelinux.cfg/splash.jpg
     7 menu title Welcome to PXE+kickstart auto install systems
     8 menu color border 0 #ffffffff #00000000
     9 menu color sel 7 #ffffffff #ff000000
    10 menu color title 0 #ffffffff #00000000
    11 menu color tabmsg 0 #ffffffff #00000000
    12 menu color unsel 0 #ffffffff #00000000
    13 menu color hotsel 0 #ff000000 #ffffffff
    14 menu color hotkey 7 #ffffffff #ff000000
    15 menu color scrollbar 0 #ffffffff #00000000
    16 
    17 
    18 label linux
    19   menu label ^Install CentOS7.4 Minimal
    20   menu default
    21   kernel cores/CentOS/7.4/vmlinuz
    22   append initrd=cores/CentOS/7.4/initrd.img ip=dhcp inst.repo=ftp://10.1.1.11/CentOS/7.4 inst.ks=ftp://10.1.1.11/kickstart.cfgs/CentOS-7.x-min.cfg
    23 
    24 label linux
    25   menu label ^Install CentOS6.9 Minimal
    26   kernel cores/CentOS/6.9/vmlinuz
    27   append initrd=CentOS6/initrd.img ip=dhcp repo=ftp://10.1.1.11/CentOS/6.9 ks=ftp://10.1.1.11/kickstart.cfgs/CentOS-6.x-min.cfg
    28 
    29 label linux
    30   menu label ^Install Windows10
    31   kernel memdisk raw iso
    32   append initrd=ftp://10.1.1.11/Windows/10/W10X32_CN_PE.iso
    33 
    34 label local
    35   menu label Boot from ^local drive
    36   localboot 0xffff

  • Default Content
  • Mkdir-p/var/lib/tftpboot/cores/{centos,ubuntu,windows}
    • Kernel file directories for each system
    • cd/var/lib/tftpboot/cores/
    • mkdir centos/{6.9,7.4}
    • mkdir ubuntu/{16,17}
    • mkdir windows/{7,10}





Here's just an example of unattended CentOS 7 Minimaul



Mount image File



Mount/dev/cdrom/mnt



Copy kernel files



Cp-rf/mnt/isolinux/{initrd.img,vmlinuz}/var/lib/tftpboot/cores/centos/7.4





Bios


Copy the required files into the/var/lib/tftpboot/directory



cp/usr/share/syslinux/{pxelinux.0,vesamenu.c32,memdisk,gpxelinux.0}/var/lib/tftpboot/


    • pxelinux.0 is the PXE boot loader,
    • Gpxelinux for GPXE Boot program
      • It allows you to download Linux images using a fast HTTP protocol rather than a slower TFTP protocol to speed up installation. However, some hardware does not support GPXE. For example, IBM X3650 M4.
    • Memdisk used to boot the ISO file
    • Vasamenu.c32 used to draw the PXE menu
UEFI


Copy Centos6 in Bootx64.efi, bootx64.conf, splash.xpm.gz, conf file renamed to Efidefault is the boot menu of UEFI



(Centos7 is the GRUB2 way)


  • Bootx64.efi
  • Efidefault
  • default=0
    splashimage=(nd)/splash.xpm.gz
    timeout 10
    hiddenmenu
    
    title CentOS 7.4 UEFI 
            root (nd)
            kernel /cores/CentOS/7.4/vmlinuz ip=dhcp ks=ftp://10.1.1.11/kickstart.cfgs/CentOS-7.x-min_UEFI.cfg repo=ftp://10.1.1.11/CentOS/7.4
            initrd /cores/CentOS/7.4/initrd.img
    
    title CentOS 6.9 UEFI
            root (nd)
            kernel /cores/CentOS/6.9/vmlinuz ip=dhcp ks=ftp://10.1.1.11/kickstart.cfgs/CentOS-6.x-min_UEFI.cfg repo=ftp://10.1.1.11/CentOS/6.9
            initrd /cores/CentOS/6.9/initrd.img
    
    title Install system with basic video driver
            kernel /images/pxeboot/vmlinuz nomodeset askmethod
            initrd /images/pxeboot/initrd.img
    
    title rescue
            kernel /images/pxeboot/vmlinuz rescue askmethod
            initrd /images/pxeboot/initrd.img


  • Splash.xpm.gz





Vsftp


Create the required system directory


    • Mkdir-p/var/ftp/{centos,ubuntu,windows,cfgs}
    • Cd/var/ftp
    • mkdir centos/{6.9,7.4}
    • mkdir ubuntu/{16,17}
    • mkdir windows/{7,10}


Copy the full image file



cp-rf/mnt/*/var/tfp/centos/7.4



Second-level directory structure








tree /var/ftp
.
├── CentOS
│   ├── 6.9 │   └── 7.4 ├── kickstart.cfgs
├── Ubuntu
│   ├── 16 │   └── 17 └── Windows
    ├── 10 └── 7

Kickstart

 1 install
 2 url --url=ftp://10.1.1.104/CentOS/7.4
 3 text
 4 lang en_US.UTF-8
 5 keyboard us
 6 zerombr
 7 bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet" --location=mbr --driveorder=sda
 8 network  --bootproto=dhcp --device=enp0s3 --onboot=yes --noipv6 --hostname=CentOS7
 9 timezone --utc Asia/Shanghai
10 authconfig --enableshadow --passalgo=sha512
11 rootpw  --iscrypted $6$Ivywr2J3hw9DVOyM$YSNpObpKiJ7iRvOL9wpJf/mEY29cAuMG3drIvcXc56pQkyQIR68RuwfonNVSkt2CZMcgLwITASS/tlX98SfTZ0
12 clearpart --all --initlabel
13 part /boot --fstype xfs --size 1024 
14 part swap --size 1024    
15 part / --fstype xfs --size 8192
16 part /home --fstype xfs --size 1 --grow
17 services --enabled="chronyd"
18 firstboot --disable
19 selinux --disabled
20 firewall --disabled
21 logging --level=info
22 reboot
23 
24 %packages            
25 @^minimal
26 @core
27 chrony
28 kexec-tools
29 
30 %end


 
BIOS MBR partition ks file
 
1 install
 2 url --url=ftp://10.1.1.11/CentOS/7.4
 3 text
 4 keyboard us
 5 lang en_US.UTF-8
 6 bootloader --location=mbr            
 7 zerombr
 8 clearpart --all --initlabel
 9 part /boot/efi --fstype efi --size 200 --asprimary --ondisk sda
10 part /boot --fstype xfs --size 500 --ondisk sda
11 part swap --size 1024 --ondisk sda
12 part / --fstype xfs --size 8192 --ondisk sda
13 part /home --fstype xfs --size 1 --grow --ondisk sda
14 network  --bootproto=dhcp --device=enp0s3 --onboot=yes --noipv6 --hostname=CentOS7
15 timezone --utc Asia/Shanghai
16 authconfig --enableshadow --passalgo=sha512
17 rootpw  --iscrypted $6$Ivywr2J3hw9DVOyM$YSNpObpKiJ7iRvOL9wpJf/mEY29cAuMG3drIvcXc56pQkyQIR68RuwfonNVSkt2CZMcgLwITASS/tlX98SfTZ0
18 logging --level=info
19 
20 %pre
21 parted -s /dev/sda mklabel gpt
22 %end
23 
24 %packages            
25 @^minimal
26 @core
27 chrony
28 kexec-tools
29 %end
30 
31 reboot
UEFI GTP partition KS file


Because of the detailed kickstart configuration file parameters too many, here is not indicated.



TFTP fabric Directory





tree/var/lib/Tftpboot


.
├──bootx64.efi
├──cores
│├──centos
││├──6.9
│││├──initrd.img
│││└──vmlinuz
││└──7.4
││├──initrd.img
││└──vmlinuz
│├──ubuntu
││├──16
││└──17
│└──windows
│├──10
│└──7
├──efidefault
├──gpxelinux.0
├──memdisk
├──pxelinux.0
├──pxelinux.cfg
│├──boot.msg
│├──default
│├──splash.jpg
│└──vesamenu.c32
└──splash.xpm.gz

Start the service


    • Systemctl start DHCPD
    • Systemctl Start TFTP
    • Systemctl Start xinetd
    • Systemctl Start VSFTPD


Join power-on self-boot


    • Systemctl Enable DHCPD
    • Systemctl Enable TFTP
    • Systemctl Enable xinetd
    • Systemctl Enable VSFTPD



Tested CentOS7 PXE unattended installation is not a problem, both BIOS and UEFI are available.






CentOS 7 Pxe+kickstart+tftp+vsftp+bios+uefi


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.