Pxe+tftp+http+kickstart unattended installation operating system under CentOS 6.x

Source: Internet
Author: User
Tags get ip file transfer protocol

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 environment

Lab Environment: VMware Workstation 12

System platform: CentOS Release 6.7 graphical interface (System-config-kickstart tool generates KS.CFG file dependent on graphical interface)

Network mode: NAT mode

Here, I am the boot server, the KS installation server, the DHCP server are installed in the same virtual machine inside.

Selinux=disabled

Third, software preparation:

#yum-y install httpd tftp-server tftp DHCP Comment: httpd primarily provides a way for the client to install, or through NFS or FTP. Tftp-server is to provide a way to transfer kernel files and PXE files to clients. TFTP can not be installed, the installation is due to the convenience of the TFTP service test; The DHCP service assigns an IP address to the client.

#yum-y Install Syslinux ##:syslinux is a feature will be large boot loader, where the system is not installed by default, need to install manually.

#yum-y Install System-config-kickstart # #: Installs the Kickstart tool.

#mkdir/mnt/cdrom # #创建文件夹

#mount/dev/cdrom/mnt/cdrom # #将centos 6.x system mounted to the/mnt/cdrom directory

#cp-R/mnt/cdrom/var/www/html # #将挂载在 the system installation files under/mnt/cdrom are copied to the root directory of the httpd service.

Iv. Overall Configuration

1. Start the httpd server and set the boot from start, start the DHCP service, and set the boot-up.

#service httpd Start

#chkconfig httpd on

#chkconfig DHCPD on

#chkconfig DHCPD Start

2. Modify the TFTP configuration file, change the Disable=yes to no, and restart the xinetd service.

#vim/etc/xinetd.d/tftp #disable = yes change to Disable=no

#service xinted Restart

3. Copy the boot loader to the TFTP root directory

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

4. Copy the kernel files and image files of the system to the root directory of the TFTP

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

5. Copy the files displayed at boot time to the TFTP root directory:

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

6.

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

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

7. The default file permission defaults to 444, there is no write permission, you need to provide write permission. (because I am using the root user, the modified permissions are 644)

#chmod 644 Default

8. Modify the contents of the default file:

Default KS #标记启动内核
Prompt 1 #显示 ' boot: ' Prompt is ' 0 ' without prompting to start the contents of the default tag directly
Timeout 6 #在用户输入之前的超时时间

Display Boot.msg #显示某个文件的内容, the file path is:/var/lib/tftboot/

Menu Background Splash.jpg
Menu title Welcome to CentOS 6.7!
Menu Color Border 0 #ffffffff #00000000
Menu Color SEL 7 #ffffffff #ff000000
Menu Color Title 0 #ffffffff #00000000
Menu Color tabmsg 0 #ffffffff #00000000
Menu Color Unsel 0 #ffffffff #00000000
Menu Color Hotsel 0 #ff000000 #ffffffff
Menu Color Hotkey 7 #ffffffff #ff000000
Menu Color ScrollBar 0 #ffffffff #00000000

Label Linux
Kernel Vmlinuz
Append initrd=initrd.img
Label text
Kernel Vmlinuz
Append initrd=initrd.img Text
Label KS
Kernel Vmlinuz
Append ks=http://192.168.2.100/ks.cfg initrd=initrd.img Get httpd under the root of the KS.CFG server #告诉系统从192.168.2.100, this is the native.
Label Local
Localboot 1
Label Memtest86
Kernel memtest
Append-

9. Modify the DHCP configuration file

#vim/ETC/DHCP/DHCP

Ddns-update-style Interim; #DHCP-dns Interactive Update mode

Ignore client-updates; #忽略客户端更新
FileName "pxelinux.0"; #pxelinux Startup file Location
Next-server 192.168.2.100; #TFTP服务器的IP地址, here is the machine.

Subnet 192.168.2.0 netmask 255.255.255.0 {#说明网段
Option routers 192.168.2.100; #路由
Option Subnet-mask 255.255.255.0; #子网掩码

Range DYNAMIC-BOOTP 192.168.2.105 192.168.2.110; #DHCD地址池
Default-lease-time 21600; #客户端刷新配置信息的时间间隔
Max-lease-time 43200; #为客户端无法从DHCP服务器获得任何信息的时间, exceeding that time discards any information obtained from the server and uses the OS default configuration instead
}

10. Start the DHCP service

#service dhcpd start #当启动失败时, need to check the configuration file is wrong, the overall configuration process is very error-prone, so it is recommended to check the configuration file after modification.

11. Launch the System-config-kickstart tool to generate the Ks.cfg file. and place the Ks.cfg file under the root directory of the httpd service (/var/www/html/).

#system-config-kickstart

A. Set the language, keyboard, time zone, root password, and check the install restart options below. These configurations are applied to the newly installed client.

B. Select Install as HTTP and enter directory CDROM, referring to/var/www/html/cdrom/

C.boot Loader Options Default configuration

D. Select initialize the hard drive label, partition: 1G swap partition, 8G hard disk.

E. Network configuration option to add a block NIC to Eth0, with a net type of DHCP

F. Firewall option: Both SELinux and security level are selected disabled

G. installation package selection, this according to the specific needs to choose a different installation package, here I choose the graphical interface version.

H. Click on the left hand hand-handed preview. Click Save. Save to/var/www/html/directory:

OK, here, all the configurations are complete.

V. Testing

1. Turn off the DHCP functionality of VMware software

2. Create a new virtual machine, network card mode select NAT

3. Turn on power, get IP, get pxelinux.0 transfer kernel file, start installation

CentOS 6.x under Pxe+tftp+http+kickstart unattended installation operating system

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.