"Complex" CentOS 6.4 under Pxe+kickstart unattended installation operating system

Source: Internet
Author: User
Tags file transfer protocol

First, Introduction

1.1 What is PXE

PXE (Pre-Boot execution Environment, pre-boot execution Environment) is the latest technology developed by Intel Corporation, working in the Client/server network mode, enabling workstations to download images from remote servers over the network, This supports booting the operating system over the network, and during the boot process, the terminal requires the server to assign an IP address, then TFTP (trivial File Transfer Protocol) or MTFTP (Multicast trivial file transfer Protocol) protocol to download a boot package into native memory executed by this boot package to complete the terminal basic software setup, thus booting the terminal operating system preinstalled in the server.

Strictly speaking, PXE is not a way to install, but a way to boot. A requirement for a PXE installation is that a PXE-supported network card (NIC) must be included on the computer to be installed, that is, the PXE Client must be in the network card. The PXE protocol enables a computer to boot over the network. This protocol is divided between the client side and the Server side, while the PXE client is in the ROM of the NIC. When the computer boots, the BIOS directs the PXE client into memory and then the files that are placed at the remote end by the PXE client are downloaded locally to run on the network. Running the PXE protocol requires setting up a DHCP server and a TFTP server. The DHCP server assigns an IP address to the PXE client (the host that will install the system), and because it assigns an IP address to the PXE client, the appropriate PXE settings need to be added when configuring the DHCP server. In addition, the TFTP client already exists in the PXE client ROM, so it can download the required files via the TFTP protocol to the TFTP Server.

Working process for PXE:

1. PXE Client starts from its own PXE network card and requests IP from the DHCP server in the network;

2. The DHCP server returns the IP that is assigned to the client and the location of the PXE file (the file is typically placed on a TFTP server);

3. The PXE Client requests the pxelinux.0 file from the TFTP server in the network;

4. The PXE Client obtains the pxelinux.0 file after the implementation of the file;

5. Load the kernel and file system via the TFTP server based on the results of pxelinux.0 execution;

6. Enter the installation screen, which can be installed by selecting one of the HTTP, FTP, and NFS modes;

Detailed workflow, please refer to the following picture:

1.2 What is Kickstart

Kickstart is an unattended installation method. It works by documenting typical parameters that require manual intervention during the installation process and generating a file named Ks.cfg. If you have to fill in the parameters during the installation process (not limited to the machine that generated the Kickstart installation files), the installer will first look for the files generated by the kickstart, and if the appropriate parameters are found, use the found parameters; Need to be manually intervened by the installer. So, if the kickstart file covers all the parameters that may be required during installation, then the installer can simply tell the installer where to fetch the ks.cfg file and then go to work on it. When the installation is complete, the installer restarts the system according to the settings in the Ks.cfg and ends the installation.

Pxe+kickstart unattended installation of the operating system the complete process is as follows:

Second, the system environment

Lab Environment: VMware Workstation 10

System Platform: CentOS Release 6.4 (minimized installation)

Network mode: Nat mode (the IP address of the shared host)

Dhcp/tftp ip:192.168.111.130

Http/ftp/nfs ip:192.168.111.130

The firewall is turned off/iptables:firewall is not running.

Selinux=disabled

Iii. preparatory work

The System-config-kickstart tool is required to generate the Ks.cfg file, and this tool relies on X windows, so we need to install X Windows and desktop and restart the system, as follows:

# yum Groupinstall "X window System"

# yum Groupinstall Desktop

# reboot

Iv. Configuring HTTP Installation Methods

The installation of the system can choose HTTP, FTP, NFS, we are here to introduce the installation of HTTP, the other two ways to install, we can self-Baidu.

4.1 Installing and Configuring HTTP

# yum Install Httpd–y

# Rpm-qa|grep HTTPD

Turn on the service and set the boot up

#/ETC/INIT.D/HTTPD Start

# chkconfig--level httpd on

4.2 Loading the ISO image

Set the load ISO image in the virtual machine.

Mount the ISO file to/mnt/cdrom.

4.3 Copy the entire contents of the disc to the root directory of HTTP/var/www/html/

# cp-r/mnt/cdrom//var/www/html/

The HTTP section is set up.

V. Configuring TFTP

5.1 Installing Tftp-server

# yum Install Tftp-server–y

5.2 Enabling the TFTP service

# vi/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         Disable                 = no         per_source                       cps                     2         flags                   = IPv4 }   

Set Disable to No

5.3 Starting the TFTP service

Because the TFTP service is mounted under the hyper-process xinetd, the TFTP service is started by starting xinetd.

#/etc/init.d/xinetd Restart

Set Boot xinetd

# Chkconfig xinetd on

Vi. Configuring PXE-enabled boot programs

6.1 Copy the pxelinux.0 file to the/var/lib/tftpboot/folder

# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/

Description:syslinux is a powerful boot loader and is compatible with a variety of media. More precisely: Syslinux is a small Linux operating system that is designed to simplify the first time you install Linux, and to create repair or other special-purpose boot disks.

6.2 Copy the/image/pxeboot/initrd.img and vmlinux in the ISO image to the/var/lib/tftpboot/folder

# Cp/var/www/html/cdrom/images/pxeboot/{initrd.img,vmlinuz}/var/lib/tftpboot/

6.3 Copy the ISO image in the/isolinux/*.msg to/var/lib/tftpboot/folder

# cp/var/www/html/cdrom/isolinux/*.msg/var/lib/tftpboot/

6.4 Create a new pxelinux.cfg directory in/var/lib/tftpboot/

# mkdir/var/lib/tftpboot/pxelinux.cfg

6.5 Copy the isolinux.cfg from the/isolinux directory in the ISO image to the Pxelinux.cfg directory, and change the file name to be called the default

# Cp/var/www/html/cdrom/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

6.6 Modifying the default file

# Vi/var/lib/tftpboot/pxelinux.cfg/default

Default KS#默认启动的是"Label KS" in the boot kernel labeled prompt1#显示' Boot: ' Prompt. For' 0 ' When not prompted, will be launched directlyThe content specified in the ' default ' parameter. Timeout6      #在用户输入之前的超时时间, the unit is1/10 seconds. Display Boot.msg#显示某个文件的内容, note the path to the file. The default is the/var/lib/tftpboot/Directory. You can also refer to locating similar'/install/boot.msg ' such, the path+ file name. F1 boot.msg#按下' F1 ' such a key after the file is displayed. F2 options.msg F3 general.msg F4 param.msg F5 rescue.msg label Linux# ' label ' specifies the keywords you entered at  ' boot: ' prompt, such as boot:linux[enter], this will start kernel and initrd.img files. Kernel vmlinuz #kernel parameter specifies the kernel to start. Append initrd=initrd.img  #append specify parameters appended to the kernel to be able to be in the grub The parameters that are appended to the kernel are available here as well. Label text kernel vmlinuz append initrd=initrd.img text label KS kernel vmlinuz append ks=ht tp://192.168.111.130 /ks.cfg initrd=initrd.img  #告诉系统, where to get ks.cfg file label Local localboot 1 label memtest86 kernel memtest append-< /span>                

VII. Configuring DHCP

7.1 Installing the DHCP service

# yum-y Install DHCP

7.2 Copy the configuration template file into the DHCP configuration directory

# cp-f/usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample/etc/dhcp/dhcpd.conf

7.3 Modify the/etc/dhcp/dhcpd.conf configuration file with the following contents:

Ddns-update-style Interim; Ignore client-updates;   FileName "pxelinux.0";  #192.168.111.130; 192.168.111.100 192.168.111.200 of the #TFTP Server ; default-lease-time 21600; Max-lease-time 43200;}   

7.4 Starting the DHCP service

#/ETC/INIT.D/DHCPD Start

Viii. Generating ks.cfg files

8.1 Installing Kickstart

# yum Install System-config-kickstart

8.2 Configuring Kickstart in the desktop environment

Start the X Windows environment

# STARTX

Configure Kickstart

# System-config-kickstart

A. Set language, keyboard, time zone, root password, reboot after installation.

B. Set the installation method, this article describes the installation of HTTP mode, so select the HTTP

C. Installing the MBR

D. Setting Up partitions

E. Overview of partitions

F. Configuring the Network

G. Authentication configuration

H. SELinux and firewall configuration

I. Graphical Environment configuration

J. Package Installation Options

K. Preview

L. Generate the Ks.cfg file, save it in the/var/www/html/folder

We can open the/var/www/html/ks.cfg file for viewing and making changes.

Platform=x86, AMD64, or Intel em64t #version =devel # Firewall configuration Firewall--disabled # Install OS instead of up Grade Install # Use network installation URL--url=http://192.168.111.130/cdrom/#这个选项告诉安装程序: Look for the installation media under the CDROM folder under the HTTP root of the server 192.168.111.130 # root password rootpw--iscrypted $1$vsvtp./e$  6PVMNFJD.SHQ2LGFJJYFA1 # System Authorization Information auth--useshadow--ENABLEMD5 # Use graphical install graphical  Firstboot--disable # System keyboard keyboard US # system language Lang en_US # selinux configuration SELinux--disabled # Installation Logging level Logging--level=info # Reboot after installationReboot # System timezone timezone--ISUTC Asia/shanghai # Network Information Network--BOOTPROTO=DHCP--device=eth0 --onboot=on # System bootloader configuration key--skip bootloader--append= "rhgb quiet"--location=mbr--driveorder =SDA # Clear The Master Boot Record zerombr # Partition clearing information clearpart--all--initlabel # Disk Partit Ioning Information part/--fstype= "EXT4"--size=8192 part swap--fstype= "swap"--size=1024 part/home--fstype= "Ext4"--s Ize=2048%packages @base%end  

Note:key--skip If it is a red hat system, this option can skip the input sequence number process, if it is the CentOS series, you can not keep this content;

Reboot This option must exist, you must also set the location in the text, or kickstart display a message, and wait for the user to press any key after the reboot;

Clearpart--all--initlabel This command must be added, or the system will let the user manually choose whether to clear all the data, which requires human intervention, resulting in the failure of the automation process;

Nine, test installation

The automatic installation system is complete, the following starts a new machine to test, network connection mode select NAT mode.

New virtual machine, select Custom (Advanced)

Select "Install operating system later"

Select the client operating system type

Name a virtual machine

Set the memory for this virtual machine

Set the network type

Select I/O Controller type

Select disk Type

Select disk

Specify the size of the disk, in the Ks.cfg file, we define a/size of 8gb,swap partition for the 1gb,/home partition to 2GB, so the disk size here must be at least 12GB.

Also, be sure to tick "allocate all disk space now", or you will be prompted for no disk space when you install it later.

Specify disk files

Virtual Machine Overview

The disk is being created and the process is slow and the virtual machine needs to produce a 20GB file.

Start the virtual machine, select start from the network card, and the DHCP server is assigning an IP address to the client.

Start Download Vmlinuz and initrd.img

Installation process ...

Installation process ...

Installation process ...

After the installation is complete, the login screen is displayed after rebooting.

Log in to the system to see that the disk partition is the same as the one we set in the Ks.cfg file.

Pxe+kickstart unattended installation of operating system environment.

"Complex" CentOS 6.4 under Pxe+kickstart unattended installation operating system

Related Article

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.