PXE + Kickstart unattended CentOS 6.4 Operating System Installation

Source: Internet
Author: User
Tags file transfer protocol

PXE + Kickstart unattended CentOS 6.4 Operating System Installation

I. Introduction

1.1 What is PXE

PXE (Pre-boot Execution Environment, Pre-start Execution Environment) is the latest technology developed by Intel, working in the Network Mode of Client/Server, the workstation can download images from remote servers over the network and start the operating system over the network. During the startup process, the terminal requires the server to allocate an IP address and use TFTP (trivial file transfer protocol) or the MTFTP (multicast trivial file transfer protocol) protocol downloads a startup package to the local memory for execution. The startup package completes the basic software settings of the terminal, in this way, the operating system of the terminal that is pre-installed on the server is guided.

Strictly speaking, PXE is not an installation method, but a boot method. A prerequisite for PXE installation is that the computer to be installed must contain a NIC supported by PXE, that is, a PXE Client must be included in the NIC. The PXE protocol enables the computer to start over the network. This Protocol is divided into Client and Server, while PXE Client is in the ROM of the NIC. During computer boot, the BIOS transfers the PXE Client to the memory for execution, and then the PXE Client downloads the files stored in the remote end to the local computer for running through the network. To run the PXE protocol, you must set the DHCP server and TFTP server. The DHCP server assigns an IP address to the PXE Client (the host on which the system is to be installed). Because the IP address is assigned to the PXE Client, you need to add relevant PXE settings when configuring the DHCP server. In addition, TFTP Client already exists in the PXE Client ROM, so it can download the required files to the TFTP Server through the TFTP protocol.

PXE process:

1. the PXE Client starts from its PXE Nic and requests an IP address from the DHCP server in the network;

2. the DHCP server returns the IP address assigned to the client and the location of the PXE file (this file is usually 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 executes this file after obtaining the pxelinux.0 file;

5. Based on the execution result of pxelinux.0, load the kernel and file system through the TFTP server;

6. Go to the installation screen and select one of the HTTP, FTP, and NFS installation methods;

For detailed workflow, see the figure below:

1.2 What is Kickstart

Kickstart is an unattended installation method. It works by recording typical parameters that require manual intervention during installation and generating a file named ks. cfg. If a parameter is required during the installation process (not limited to the machine that generates the Kickstart Installation File), the installer first searches for the file generated by Kickstart. If a proper parameter is found, the parameter is used. If no proper parameter is found, manual intervention is required by the installer. Therefore, if the Kickstart file contains all the parameters that may occur during the installation process, the installer can only tell the installer where to obtain ks. cfg file. After the installation is complete, the installation program restarts the system according to the settings in ks. cfg and ends the installation.

PXE + Kickstart the complete process of unattended operating system installation is as follows:

Ii. System Environment

Lab environment: VMware Workstation 10

System Platform: CentOS release 6.4 (minimal installation)

Network Mode: NAT mode (shared Host IP address)

DHCP/tftp ip: 192.168.111.130

HTTP/FTP/nfs ip: 192.168.111.130

Firewall disabled/iptables: Firewall is not running.

SELINUX = disabled

Iii. Preparations

The system-config-kickstart tool is required to generate the ks. cfg file, which depends on X Windows. Therefore, we need to install X Windows and Desktop and restart the system as follows:

# Yum groupinstall "X Window System"

# Yum groupinstall Desktop

# Reboot

Iv. Configure the HTTP Installation Method

You can select HTTP, FTP, and NFS as the system installation method. Here we will introduce how to install HTTP. For other two installation methods, you can use Baidu.

4.1 install and configure HTTP

# Yum install httpd-y

# Rpm-qa | grep httpd

Enable service and set startup

#/Etc/init. d/httpd start

# Chkconfig -- level 35 httpd on

4.2 load an ISO Image

Attach an ISO image to a VM.

Mount the iso file to/mnt/cdrom.

4.3 copy all content of the CD to the http root directory/var/www/html/

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

HTTP is configured.

5. Configure TFTP

5.1 install tftp-server

# Yum install tftp-server-y

5.2 enable 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 = 11 cps = 100 2 flags = IPv4 }

Set disable to no

5.3 Start the tftp service

Because the tftp service is mounted to the super process xinetd, you can start the tftp service by starting xinetd.

#/Etc/init. d/xinetd restart

Set start xinetd

# Chkconfig xinetd on

6. Configure boot programs that support PXE

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

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

Note: syslinux is a powerful boot loader and compatible with various media. More specifically, SYSLINUX is a small Linux operating system designed to simplify the first Linux installation and create boot disks for repair or other special purposes.

6.2 copy/image/pxeboot/initrd. img and vmlinux from 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/isolinux/*. msg from the iso image to the/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 isolinux. cfg from the/isolinux directory in the iso image to the pxelinux. cfg directory, and change the file name to default

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

6.6 modify the default file

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

Default ks # by default, the start kernel prompt 1 marked in 'label ks' is started. # The 'boot: 'prompt is displayed. If it is set to '0', no prompt is displayed. The content specified in the 'default' parameter is directly started. Timeout 6 # Time-out period before user input, measured in 1/10 seconds. Display boot. msg # displays the content of a file. Pay attention to the file path. The default value is in the/var/lib/tftpboot/directory. You can also locate the path + file name similar to '/install/boot. msg. F1 boot. msg # The file displayed after pressing a key such as 'f1. F2 options. msg F3 general. msg F4 param. msg F5 rescue. msg label linux # 'label' specifies the keyword you ENTER at the 'boot: 'prompt, for example, boot: linux [ENTER], this will start the kernel and initrd marked under 'label linux. imgfile. The kernel vmlinuz # kernel Parameter specifies the kernel to be started. Append initrd = initrd. img # append specifies the parameters appended to the kernel, which can be used in grub to append to the kernel. Label text kernel vmlinuz append initrd = initrd. img text label ks kernel vmlinuz append ks = http: // 192.168.111.130/ks. cfg initrd = initrd. img # Tell the system where to obtain ks. cfg file label local localboot 1 label memtest86 kernel memtest append-

VII. Configure DHCP

7.1 install the DHCP service

# Yum-y install dhcp

7.2 copy the configuration template file to the DHCP configuration directory.

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

7.3 modify the configuration file/etc/dhcp/dhcpd. conf as follows:

Ddns-update-style interim; ignore client-updates; filename "pxelinux.0"; # position of the pxelinux Startup File; next-server 192.168.111.130; # IP address of the TFTP Server; subnet 192.168.111.0 netmask 255.255.255.0 {option routers 192.168.111.130; option subnet-mask 255.255.255.0; range dynamic-bootp 192.168.111.100 192.168.111.200; default-lease-time 21600; max-lease-time 43200 ;}

7.4 start the DHCP service

#/Etc/init. d/dhcpd start

8. Generate the ks. cfg file

8.1 install Kickstart

# Yum install system-config-kickstart

8.2 configure Kickstart In the desktop environment

Start X Windows

# Startx

Configure Kickstart

# System-config-kickstart

A. Set language, keyboard, time zone, Root password, and restart after installation.

B. Set the installation method. This article describes how to install HTTP.

C. Install MBR

D. Set partitions.

E. Partition Overview

F. Configure the network

G. Authentication Configuration

H. SELinux and firewall configuration

I. graphical environment Configuration

J. package installation Selection

K. Preview

L. Generate the ks. cfg file and save it in the/var/www/html/folder.

You can open the/var/www/html/ks. cfg file to view and modify the file.

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/# This option tells the installer to find the installation medium in the cdrom folder under the HTTP Root directory 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 us # System language lang en_US # SELinux configuration selinux -- disabled # Installation logging level logging -- level = info # Reboot after installation reboot # System 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 = 8192 part swap -- fstype = "swap" -- size = 1024 part/home -- fstype = "ext4" -- size = 2048% packages @ base % end

Note: If the key-skip is a Red Hat system, this option can skip the process of entering the serial number; if it is a CentOS series, this option can be left blank;

Reboot: This option must exist or be set in the text. Otherwise, kickstart displays a message and waits for the user to press any key to reboot;

The clearpart -- all -- initlabel command must be added. Otherwise, the system will ask the user to manually select whether to clear all the data. This requires human intervention, leading to automated process failure;

IX. test and install

After the automatic installation system is configured, start a new machine for testing and select NAT for network connection mode.

Create a VM and select Custom (advanced)

Select "Install the operating system later"

Select the client operating system type

Name a virtual machine

Set the memory of this virtual machine

Set network type

Select the I/O controller type

Select Disk Type

Select Disk

Disk size, ks. in the cfg file, the/size is 8 GB, the swap partition is 1 GB, And the/home partition is 2 GB. Therefore, the disk size here must be at least 12 GB.

In addition, you must check "allocate all disk space now". Otherwise, no disk space will be displayed during subsequent installation.

Disk File

Virtual Machine Overview

Creating a disk is slow. The VM needs to generate a 20 GB file.

Start the VM and select start from the NIC. the DHCP server is allocating an IP address to the client.

Start downloading vmlinuz and initrd. img

Installation process...

Installation process...

Installation process...

After the installation is complete, the logon page is displayed.

Log on to the system and check the disk partition as we set in the ks. cfg file.

The operating system environment for unattended installation of PXE + Kickstart is complete.

References

  • Fuqin wine: http://yuhongchun.blog.51cto.com/1604432/1100567

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.