Automatic Installation of centos through PXE

Source: Internet
Author: User

The Installation Management Program of centos is anaconda. After the system is installed, a kickstart configuration file anaconda_ks.cfg is automatically generated in the Root's home directory. This file consists of command segments, software package segments, and script segments.

Command segment: contains various operating commands for installing the system

Package segment: contains software packages and package groups that are specified to be installed or Not Installed

% Packages indicates that this segment is a package segment and ends with % end

Pkg_name: Specifies the software package to be installed.

@ Group_name: Specify the package group to be installed

-Pkg_name: indicates that this package is not installed. If this package is dependent, it will also be installed.

Script section:

% Pre: Pre-installation script. Preparations for the installation environment are completed at % end.

% Post: script after installation. the operation to be performed after installation is completed. End this segment with % end.

The Kickstart file can be configured through the system-config-kickstart graphical interface, and then a configuration file is generated, which can be saved in the specified directory with the specified file name. You can also open an existing kickstart configuration file to import and modify the configuration.

Install system-config-kickstart

# yum install system-config-kickstart

You can also run the ksvalidator command to check the Kickstart File Syntax.

# kickstart ks.cfg


Automatic PXE installation:


1. Configure DHCP

Install DHCP

# yum install dhcp

Configure DHCP and edit the configuration file/etc/DHCP/DHCPD. conf.

Option domain-name "example.org"; # specify the domain name option domain-name-servers 172.16.142.1; # Separate multiple DNS domain names with commas (,) to default-lease-time 86400; # default Lease Term max-lease-time 100000; # maximum Lease Term log-facility local7; # The Log Device type is local7subnet 172.16.0.0 netmask 255.255.255.0.0 {# specify the IP address and subnet mask range 172.16.142.2 172.16.142.254; # The available address pool range is option routers 172.16.142.1; # specify the gateway next-server 172.16.142.1; # specify the next server as the TFTP server address FILENAME "pxelinux.0"; # specify to download the pxelinux.0 file on the TFTP server}

Check whether the configuration file has syntax errors.

# service dhcpd configtestSyntax:OK

Reload the DHCP service configuration file

# service dhcpd force-reload

Set startup Service

# chkconfig dhcpd on

View startup status

# Chkconfig -- list dhcpddhcpd 0: off 1: off 2: On 3: On 4: On 5: on 6: off # Start the service at the running level

View the IP Address allocation information in the lease information database:

# cat /var/lib/dhcpd/dhcpd.leases# The format of this file is documented in the dhcpd.leases(5) manual page.# This lease file was written by isc-dhcp-4.1.1-P1lease 172.16.142.4 {  starts 2 2014/07/29 10:53:30;  ends 2 2014/07/29 10:55:30;  tstp 2 2014/07/29 10:55:30;  cltt 2 2014/07/29 10:53:30;  binding state free;  hardware ethernet c4:6a:b7:d8:78:b0;  client-hostname "android-ef3831713d10353c";}lease 172.16.142.6 {  starts 2 2014/07/29 11:02:12;  ends 2 2014/07/29 11:04:12;  tstp 2 2014/07/29 11:04:12;  cltt 2 2014/07/29 11:02:12;  binding state free;  hardware ethernet 20:1a:06:bf:dc:43;  uid "\001 \032\006\277\334C";  client-hostname "PC201406062256";}


2. Configure the TFTP Server

Install TFTP & TFTP-Server

# yum install tftp tftp-server

Enable the TFTP service

# chkconfig tftp on# service xinetd restart

Check whether the TFTP service is enabled

# ss -unl |grep :69UNCONN     0      0                         *:69                       *:*


3. Provide PXE Working Environment

Install syslinux

# yum install syslinux

Copy the pxelinux.0 file to TFTP.

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


4. Provide boot kernel and other required files

Mount the system disk to/Media/CDROM.

# mount /dev/cdrom /media/cdrom

Copy the file to the tftpboot directory.

# cp /media/cdrom/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot# cp /media/cdrom/isolinux/{splash.jpg,vesamenu.c32,boot.msg}  /var/lib/tftpboot

File required for the vesamenu. c32 boot menu. Create the pxelinux configuration file directory pxelinux. cfg under the tftpboot directory.

Copy the/Media/CDROM/isolinux. cfg Startup menu file to the pxelinux. cfg directory and rename it to the default file.

# Mkdir/var/lib/tftpboot/pxelinux. CFG # cp/Media/CDROM/isolinux. CFG/var/lib/tftpboot/pxelinux. CFG/default # Content of the configuration file default vesamenu. c32 # Use vesamenu. c32 text interface program # prompt 1 timeout 600 # set timeout 60 seconds, in 0.1 seconds display boot. msgmenu background splash.jpg # Set the background image menu title welcome to centos 6.5! # Set the Title menu color border 0 # ffffffff #00000000 menu color sel 7 # ffffffff # ff000000menu Color title 0 # ffffffff #00000000 menu color tabmsg 0 # ffffffff #00000000 menu color unsel 0 # ffffffff #00000000 menu color hotsel 0 # ff000000 # ffffffffmenu color hotkey 7 # ffffffff # ff000000menu color scrollbar 0 # ffffffffff #00000000 label Linux # Set labels, press the tab key at startup to go to the command line interface. You can use the label to replace the command and the parameter menu label ^ install or upgrade an existing system menu default kernel vmlinuz # kernel position append initrd = initrd. IMG Ks = # specifies the KS File Location label VESA menu label install system with ^ basic video driver kernel vmlinuz append initrd = initrd. IMG xdriver = VESA nomodeset # When no video card driver is available, use the basic display drive label rescue menu label ^ rescue installed system kernel vmlinuz append initrd = initrd. IMG rescue # rescue mode label local menu label boot from ^ local drive localboot 0 xFFFF # Start local disk label memtest86 # memory test menu label ^ memory test kernel memtest append-


5. Provide the installation Source

Install httpd

# Yum install httpd # create a CD mounting directory # mkdir/var/www/html/centos # mount the CD to the directory # Mount/dev/CDROM/var/www/html/centos # Or mount the disc to/Media/CDROM, then bind/var/www/html/centos to/Media/CDROM # Mount/dev/CDROM/Media/CDROM # Mount/Media/CDROM/var/www/html/ centos


6. Provide the KS. cfg file

Note: The Ks. cfg file other must have the read permission.

Copy the KS. cfg file to the default HTTP directory.

# CP ~ /Anaconda_ks.cfg/var/www/html/KS. CFG # Kickstart file automatically generated by Anaconda. # version = develinstall # Install source compatible with centos5. The URL -- url = http: // 172.16.142.1/centos is returned .... # partition formatting clearpart -- allpart/boot -- fstype = ext4 -- size = 200 part pv.008002 -- size = 61440 volgroup vg0 -- pesize = 8192 pv.008002logvol/-- fstype = ext4 -- name = root -- vgname = vg0 -- size = 20480 logvol swap -- name = swap -- vgname = vg0 -- size = 2048 logvol/usr -- fstype = ext4 -- name = USR -- vgname = vg0 -- size = 10240 logvol /var -- fstype = ext4 -- name = var -- vgname = vg0 -- size = 20480 # specify the installation source repo -- name = "centos" -- baseurl = http: // 172.16.142.1/centos -- cost = 100 # configure the Installed Package and package group % packages @ base @ core @ base @ basic-desktop... ibus-table-cangjieibus-table-erbiibus-table-wubilftp % end # script % post after installation... % end


This article is from the "bh4cxj" blog, please be sure to keep this source http://9144446.blog.51cto.com/9134446/1533008

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.