CentOS 6.6 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

1 Service TFTP2 { 3Socket_type =Dgram4protocol =UDP5wait =Yes6user =Root7Server =/usr/sbin/inch. TFTPD8Server_args =-S/var/lib/Tftpboot9Disable =NoTenPer_source = One  OneCPS = - 2  AFlags =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.7 Copy all files under Syslinux to Tftpboot, you can select multiple system installation versions when PXE boot

# cp/usr/share/syslinux/*/var/lib//tftpboot/

6.8 Modifying the default file

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

DEFAULT menuprompt0MENU TITLE Www.jd.comTIMEOUT2400Totaltimeout6000ontimeout locallabel local menu LABEL (local) menu DEFAULT localboot-1LABEL CentOS-6.6Kernel/vmlinuz MENU LABEL CentOS-6.6Append initrd=/initrd.img ksdevimce=bootif lang= kssendmac text ks=http://10.13.252.112/ks/66ks.cfgIpappend2LABEL CentOS-7.1Kernel/vmlinuz MENU LABEL CentOS-7.1Append initrd=/initrd.img ksdevimce=bootif lang= kssendmac text ks=http://10.13.252.112/ks/70ks.cfgIpappend2MENU End

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;subnet10.13.252.0Netmask255.255.255.0{option Routers10.13.252.112; option Subnet-mask255.255.255.0; filename"pxelinux.0"; next-server10.13.252.112; option Domain-name-servers10.13.252.112; Range Dynamic-bootp10.13.252.200 10.13.252.250;default-lease-time21600; Max-lease-time43200;}

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 upgrade 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 installation Reboot # 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 Partitioning Information part/--fstype="Ext4"--size=8192Part Swap--fstype="Swap"--size=1024x768 Part/Home--fstype="Ext4"--size=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.

CentOS 6.6 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.