PXE Unattended installation system

Source: Internet
Author: User
Tags yum repolist

Experimental topology:
Rhel6.5_1
-----CentOS6.5 (Vmnet1)----------(VMNET1)
Rhel6.5_2
Lab One: Building a PXE installed server
Operating system: RHEL 6.5
Network card connection: eth0 (VMNET1)
Host Name: svr5.tarena.com
IP Address: 192.168.4.5/24
Turn off iptables firewall, selinux protection mechanism

1. Check the lab environment
[Email protected] ~]# ifconfig eth0
Eth0 Link encap:ethernet HWaddr 00:0c:29:57:1e:86
inet addr:192.168.4.5 bcast:192.168.4.255 mask:255.255.255.0
...
[Email protected] ~]# hostname
Svr5.tarena.com
[email protected] ~]# Yum repolist
[Email protected] ~]# iptables-f
[[Email protected] ~]# service Iptables Save
[[email protected] ~]# grep selinux=disabled/etc/sysconfig/selinux
Selinux=disabled
[Email protected] ~]# Setenforce 0
2. Configure the Yum source (the real machine has been configured before, the process is slightly ...) )
Check it out.
ftp://192.168.4.1/pub/iso/rhel6.5
3. Configure DNS
[Email protected] ~]# rpm-q bind Bind-chroot
[Email protected] ~]# yum-y install bind bind-chroot bind-utils
[Email protected] ~]# cp-p/etc/named.conf/etc/named.conf.bak
[Email protected] ~]# vim/etc/named.conf
...
Listen-on Port: (any;};
//Listen-on-v6 Port 53 {:: 1;};
...
allow-query {any;};
...
Zone "Tarena.com" in {
The type master;
The file "Tarena.com.zone";
45};
46
Zone "4.168.192.in-addr.arpa" in {
The type master;
File "192.168.4.arpa";
50};
...
[Email protected] ~]# named-checkconf/etc/named.conf
[Email protected] ~]# cd/var/named/
[Email protected] named]# cp-p named.empty tarena.com.zone
[email protected] named]# cat Tarena.com.zone
$TTL 3H
@ in SOA @ rname.invalid. (
2015011401; Serial
1D; Refresh
1H; Retry
1W; Expire
3H); Minimum
In NS dns1.tarena.com.
Dns1 in A 192.168.4.5
$GENERATE 100-200 pc$ in A 192.168.4.$
[Email protected] named]# cp-p tarena.com.zone 192.168.4.arpa
[email protected] named]# cat 192.168.4.arpa
$TTL 3H
@ in SOA @ rname.invalid. (
2015011401; Serial
1D; Refresh
1H; Retry
1W; Expire
3H); Minimum
In NS dns1.tarena.com.
5 in PTR dns1.tarena.com.
$GENERATE 100-200 $ in PTR pc$.tarena.com.
[Email protected] ~]# rndc-confgen-r/dev/urandom-a
[Email protected] ~]# service named restart
[Email protected] ~]# chkconfig named on
[Email protected] ~]# host pc100.tarena.com 192.168.4.5
[Email protected] ~]# host 192.168.4.150 192.168.4.5
4. Configure DHCP
[[email protected] ~]# rpm-q DHCP
[[email protected] ~]# yum-y Install DHCP
[Email protected] ~]# cat/etc/dhcp/dhcpd.conf
Option Domain-name "tarena.com";
Option Domain-name-servers 192.168.4.5;
Default-lease-time 7200;
Max-lease-time 14400;
Subnet 192.168.4.0 netmask 255.255.255.0 {
Range 192.168.4.100 192.168.4.200;
Option routers 192.168.4.1;
Next-server 192.168.4.5;
FileName "pxelinux.0";
}
[Email protected] ~]# service DHCPD restart
[Email protected] ~]# chkconfig dhcpd on
5. Configuring TFTP
[Email protected] ~]# rpm-q tftp-server
[Email protected] ~]# yum-y install Tftp-server
[[email protected] ~]# chkconfig tftp on
[Email protected] ~]# service xinetd restart
[Email protected] ~]# chkconfig xinetd on
[Email protected] named]# NETSTAT-ANPTU | grep xinetd
UDP 0 0 0.0.0.0:69 0.0.0.0:* 2526/xinetd
6. Prepare the Startup file
[Email protected] ~]# yum-y install Syslinux
[Email protected] ~]# cd/usr/share/syslinux/
[email protected] syslinux]# CP pxelinux.0/var/lib/tftpboot/
[Email protected] syslinux]# cd/var/lib/tftpboot/
[Email protected] tftpboot]# yum-y install wget
[Email protected] tftpboot]# wget ftp://192.168.4.1/pub/iso/rhel6.5/isolinux/vmlinuz
[Email protected] tftpboot]# wget ftp://192.168.4.1/pub/iso/rhel6.5/isolinux/initrd.img
[[email protected] tftpboot]# ls
Initrd.img pxelinux.0 Vmlinuz
7. Test TFTP
[Email protected] tftpboot]# cd/tmp/
[[email protected] tmp]# yum-y install TFTP
[[Email protected] tmp]# tftp 192.168.4.5-c get pxelinux.0
[Email protected] tmp]# LS-LH pxelinux.0
-rw-r--r--1 root root 27K January 14:43 pxelinux.0
8. Configure the Boot Menu
[Email protected] ~]# mkdir/var/lib/tftpboot/pxelinux.cfg
[Email protected] ~]# cd/var/lib/tftpboot/pxelinux.cfg/
[Email protected] pxelinux.cfg]# wget ftp://192.168.4.1/pub/iso/rhel6.5/isolinux/isolinux.cfg
[Email protected] pxelinux.cfg]# MV isolinux.cfg default

Prepare an answer file
Find an installed RHEL6.5 template client (optional PXE server native in this case), create a rhel6-ks.cfg answer file with the System-config-kickstart tool
[Email protected] ~]# yum-y install System-config-kickstart
[[email protected] ~]# System-config-kickstart//run under the graphical desktop, see details
!!!! Basic configuration: Specify default language, time zone, root password (redhat)
!!!! Installation method: New Installation, FTP installation (192.168.4.1,/pub/iso/rhel6.5)
!!!! Partition information: Clear master boot record, delete all existing partitions, initialize disk label,/boot 200MB, SWAP 2GB,/space remaining
!!!! Network configuration: First NIC DHCP automatic acquisition
!!!! Firewall configuration: Disable SELinux, disable firewall
!!!! Package selection: Do not install the graphical desktop
Save File as/root/rhel6.5-ks.cfg
2. Upload the generated rhel6.5-ks.cfg file to the FTP server
[Email protected] ~]# scp/root/rhel6.5-ks.cfg[email protected]:/var/ftp/pub/
[[email protected] ~]# Vim/var/lib/tftpboot/pxelinux.cfg/default//Modify boot configuration file
Default Linux//boot system from which tag
Prompt 1//whether interactive installation
Timeout 600//wait timeout in default system (unit: 1/10 seconds)
Label Linux//define a label named Linux
Kernel Vmlinuz//Select this tab to load the kernel files
Append ks=ftp://192.168.4.1/pub/rhel6.5-ks.cfg initrd=initrd.img//download and enable auto answer file
3. Check the file above the ftp://192.168.4.1
[Email protected] ~]# elinks--dump ftp://192.168.4.1/pub/rhel6.5-ks.cfg
4. Start a bare client (new virtual machine) to test unattended installation
!!!! The setup process is automatically answered without manual interaction
!!!! Waiting for client system installation to complete

Experiment Three: Post-installation script operations
Automatically configure Yum client files after installation is complete
Automatically installs the HTTPD service and sets the boot start
Configure Default Web page content to "I Love studying ..."

1. Directly edit the KS file on the FTP server and add the following at the bottom
[Email protected] ~]# vim/var/ftp/pub/rhel6.5-ks.cfg
...
%post--interpreter=/bin/bash
rm-rf/etc/yum.repos.d/*
Echo ' [Rhel6]
Name=redhat Linux 6.5
baseurl=ftp://192.168.4.1/pub/iso/rhel6.5
Enabled=1
Gpgcheck=0 ' >/etc/yum.repos.d/rhel6.repo
Yum Clean All
Yum-y Install httpd
Echo ' I Love studying ... ' >/var/www/html/index.html
/ETC/INIT.D/HTTPD start
Chkconfig httpd on
%end
2. Start a bare client (new virtual machine) to test unattended installation
3. Check the installed client, confirm the Post script setting result
[Email protected] ~]# ifconfig eth0 | grep "inet addr"//view auto-configured IP address
inet addr:192.168.4.100 bcast:192.168.4.255 mask:255.255.255.0
[Email protected] ~]# chkconfig--list httpd//View the self-starting state of the Web service
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6: Off
[[email protected] ~]# yum-y install elinks//Make sure Yum installation package is available
[[email protected] ~]# elinks--dump http://127.0.0.1//Access Test page
I Love Linux ...

PXE Unattended installation 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.