Linux Intermediate: PXE + Kickstart Install CentOS 6.x operating system

Source: Internet
Author: User
Tags file transfer protocol iptables

First, preface

Most of this article is for reference:http://www.cnblogs.com/mchina/p/centos-pxe-kickstart-auto-install-os.html

Mainly used for learning.


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:

650) this.width=650; "src=" http://images.cnitblog.com/blog/370046/201406/152331542808644.jpg "width=" "height=" 595 "alt=" 152331542808644.jpg "/>


1.2 What is Kickstart? Anaconda

Kickstart is an unattended installation method. It works by documenting the typical parameters that need to be filled in manually during the installation process (auto-quiz) 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:

650) this.width=650; "src=" Http://images.cnitblog.com/blog/370046/201406/152331551083531.jpg "width=" 452 "height=" 424 "alt=" 152331551083531.jpg "/>

second, the test environment

Lab Environment: VMware Workstation 11

System Platform: CentOS Release 6.5 (minimized installation)

Network mode:

Server: A total of 2 network cards, eth0: bridging mode, Eth1:vmnet3

Dhcp/tftp ip:192.168.100.254

Http/ftp/nfs ip:192.168.100.254

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

Selinux=disabled

[[email protected] ~]# chkconfig iptables off[[email protected] ~]#  setenforce 0[[email protected] ~]# getenforcepermissive##  Edit  /etc/sysconfig/ selinux, selinux=disabled  Restart is in effect [[email protected] ~]# vi /etc/sysconfig/selinux#  this file controls the state of selinux on the system.#  SELINUX= can take one of these three values:#      enforcing - SELinux security policy is enforced.#      permissive - SELinux prints warnings instead of enforcing.#      disabled - no selinux policy is loaded. selinux=disabled# selinuxtype= can take one of these two values:#      targeted -&nBsp targeted processes are protected,#     mls - multi  Level security protection. selinuxtype=targeted


Client:eth0:VMnet3

ip:192.168.100.10


Third, configure HTTP mode for installation

The installation of the system can choose HTTP, FTP, NFS, we introduce the HTTP method of installation, the client through the HTTP protocol, the server side download the installation tree, the other two ways to install, we can self-Baidu.

3.1 Installing and configuring HTTPD

#  installation  httpd[[email protected] ~]# yum -y install httpd[[email  Protected] ~]# chkconfig httpd on[[email protected] ~]# service httpd  startstarting httpd: httpd: apr_sockaddr_info_get ()  FAILED FOR SKYPEHTTPD:  could not reliably determine the server ' S fully qualified domain  name, using 127.0.0.1 for ServerName                                                              [  ok   ][[email protected] ~]# netstat -tulpnactive internet connections   (only servers) Proto recv-q send-q local address  foreign address  state    PID/Program nametcp    0   0      0.0.0.0:22       0.0.0.0:*     listen       1039/sshdtcp        0       0 127.0.0.1:25     0.0.0.0:*              LISTEN      1115/mastertcp         0      0 :::80          :::*                    LISTEN      11275/httpdtcp         0      0 :::22               :::*                    LISTEN      1039/sshdtcp         0      0 ::1:25              :::*                    listen      1115/master#   We see that the  80 port is already in the listening state

3.2 Uploading an ISO image file

# mount ISO Image [[email protected] ~]# Mount/dev/cdrom/mntmount:block device/dev/sr0 is write-protected, mounting read-only# Copy the entire contents of the disc to the HTTP DocumentRoot directory:/var/www/html[[email protected] ~]# cp-ar/mnt//var/www/html


Iv. Configuring TFTP

4.1 Installing Tftp-server

#  installation  xinetd, tftp-server[[email protected] ~]# yum -y install  xinetd[[email protected] ~]# yum -y install tftp-server#  Editor  tftp  Configuration file,  set  disable  to  no[[email protected] ~]# vi /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          per_source                = 11          cps                  = 100 2         flags                 = ipv4 }#  Boot  tftp service,  due to TFTP by  xinetd  control, so need to reboot  XINETD service is available [[EMAIL PROTECTED] ~]# SERVICE XINETD STARTSTARTING XINETD:                                              [  OK  ]#  Set xinetd  boot [[email  Protected] ~]# chkconfig xinetd on
v. Configuring PXE-enabled boot programs

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

[Email protected] ~]# yum-y install syslinux# 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.


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

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

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

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

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

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

5.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/mnt/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/default

5.6 Modifying the default file

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

default ks           #默认启动的是   ' label ks '   Boot kernel prompt 1           #显示   ' boot:  '   Prompt. When   ' 0 '   is not prompted, the content specified in   ' default '   parameters will be launched directly. timeout 6    #在用户输入之前的超时时间 in  1/10  seconds. display boot.msg   #显示某个文件的内容, note the path to the file. The default is under the/var/lib/tftpboot/  directory. You can also refer to a path + file name like   '/install/boot.msg '. f1 boot.msg    #按下   ' F1 '   Such a key is displayed after the file. f2 options.msg f3 general.msg f4 param.msg f5 rescue.msg label  linux       # ' label '   Specify the keywords you entered at   ' boot: '   prompt, such as boot:  Linux[enter], this will start the ' Label linux '   under the kernel  and initrd.img  files.   kernel vmlinuz   #kernel   Parameters specify the kernel to start.   append initrd=initrd.img  #append   Specifies the parameters appended to the kernel, and the parameters appended to the kernel that can be used in the grub  are also available here.Label text   kernel vmlinuz   append initrd=initrd.img text  label ks   kernel vmlinuz   append ks=http:// 192.168.100.254/ks.cfg initrd=initrd.img     #告诉系统, where to get a ks.cfg file  label local    localboot 1 label memtest86   kernel memtest    append -
Vi. Configuring DHCP

6.1 Installing the DHCP service

# yum-y Install DHCP

6.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

6.3 Modify the/etc/dhcp/dhcpd.conf configuration file, or create a dhcpd.conf empty file directly, with the following contents:

ddns-update-style interim; ignore client-updates;  filename  "pxelinux.0";           #pxelinux   startup file location;  next-server 192.168.100.254;     #TFTP  Server  IP address;subnet 192.168.100.0 netmask 255.255.255.0  {        option routers                 192.168.100.254;          option subnet-mask               255.255.255.0;        range dynamic-bootp  192.168.100.10 192.168.111.20;         default-lease-time  21600;         max-lease-time 43200;} 

6.4 Multi-card problem

There is also a problem: if the machine running DHCPD has more than one network card, you also need to tell DHCPD is working on which NIC interface:

[Email protected] ~]# vi/etc/sysconfig/dhcpddhcpdargs= "eth1"

6.5 Starting the DHCP service

#/ETC/INIT.D/DHCPD start# chkconfig dhcpd on
Vii. Creating a ks.cfg script

Copy the/root/anaconda-ks.cfg/var/www/html/ks.cfg and edit it according to the actual situation. Note Do not include Chinese characters in this file.

# url --url=http://192.168.100.254/mnt/  #这个选项告诉安装程序: mnt to server 192.168.100.254  http root directory   folder to find the installation media #platform=x86, amd64, or intel em64t#version=devel# firewall  Configurationfirewall --disabled# install os instead of upgradeinstall# use  network installationurl --url=http://192.168.100.254/mnt/# Root passwordrootpw  --iscrypted $6$060kt9rryfxbrlgx$ wwwnqylnpz0es8dtlouy3lxqjtdhirtoojidbpyozrd2etoj.jsnbgnmylqvbfrthpzwsdrkjcraml7lqddr00# system  Authorization informationauth  --useshadow  --enablemd5# use graphical  installtextfirstboot --disable# System keyboardkeyboard us# System  languagelang en_us# selinux configurationselinux --disabled# installation  logging levellogging --level=info# reboot after installationreboot# system  Timezonetimezone  --utc asia/shanghai# network informationnetwork  -- bootproto=dhcp --device=eth0 --onboot=on# system bootloader configurationkey -- Skipbootloader --append= "Rhgb quiet"  --location=mbr --driveorder=sda# clear the  master boot recordzerombr# partition clearing informationclearpart --all  --initlabel# disk partitioning informationpart / --fstype= "Ext4"  --size= 8192part swap --fstype= "swap"  --size=1024part /data --fstype= "EXT4"  --size=2048% Packages@core%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;

After the default installation is complete, the root user password is: 123456;

Hard disk requires at least 12G;


Eight, installation test

Automatic installation system configuration, the following start a new machine to test, the process of creating a virtual machine is not speaking, the network connection mode VMnet3.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/0E/wKioL1UgKUCwthcZAAF-2I7fXMQ795.jpg "title=" 1.png " alt= "Wkiol1ugkucwthczaaf-2i7fxmq795.jpg"/>

Start the virtual machine, quickly press F2, modify the BIOS, select boot from the network card, the DHCP server is assigning IP addresses to clients.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5D/13/wKiom1UgLl2h4YiKAACf3K5gqJg542.jpg "style=" float: none; "title=" 1.png "alt=" Wkiom1ugll2h4yikaacf3k5gqjg542.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/0E/wKioL1UgL6DwWkNeAABYRJpB1hU406.jpg "title=" 4.png " Style= "Float:none;" alt= "wkiol1ugl6dwwkneaabyrjpb1hu406.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/0E/wKioL1UgL6Dz-pQRAACtiYJo9mc384.jpg "style=" float: none; "title=" 2.png "alt=" Wkiol1ugl6dz-pqraactiyjo9mc384.jpg "/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5D/13/wKiom1UgLl3wBdsSAAClkOiG_X8375.jpg "style=" float: none; "title=" 3.png "alt=" Wkiom1ugll3wbdssaaclkoig_x8375.jpg "/>


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5D/13/wKiom1UgLl6DHFXKAADkAOl7Y7o005.jpg "style=" float: none; "title=" 6.png "alt=" Wkiom1ugll6dhfxkaadkaol7y7o005.jpg "/>

After the installation is complete, restart. Since then, pxe+kickstart Unattended installation of operating system environment has been built.

This article is from the "Share Your Knowledge" blog, so be sure to keep this source http://skypegnu1.blog.51cto.com/8991766/1629027

Linux Intermediate: PXE + Kickstart Install CentOS 6.x 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.