Pxe+kickstart for automatic installation centOS6.5

Source: Internet
Author: User

About PXE

PXE works in Client/server network mode, where the client can download from the server to the image file and the kickstart file via the network without the operating system locally and automatically complete the system installation based on the kickstart file. When deploying an environment for multiple servers, this way of installing the operating system in batches greatly reduces the effort.


PXE-dependent services:

1) DHCP: Dynamically assign IP address, subnet mask, gateway, DNS address and other network properties to clients;

2) TFTP: For the client to provide installation of the required boot program, kernel, RAMDisk and other files;

3) http: Provide kickstart file and installation source.

PXE works: During the client startup process, if there is no local boot program, and finally through the network card as the boot device, the PXE function on the NIC will be activated, the Pxe_client program is called into memory to execute, broadcast request DHCP address, The DHCP server in the local area network responds with the configuration of various network properties, such as address, subnet mask, gateway, and so on. The client then downloads the pxelinux.0 file from the specified TFTP server according to the instructions of the DHCP server (PXE boot document, similar to bootloader), loads execution after download completes, and then uses the kernel, Ramdisk,anaconda program, etc. to request PXE boot to the server to start the installation Process.

DHCP and TFTP client programs are generally integrated on the NIC.


Deployment process

Deploying a DHCP server

[[email protected] ~]# yum install dhcp[[email protected] ~]# cp  /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf[[email protected] ~]# vim  /etc/dhcp/dhcpd.confoption domain-name  "baby.org";                 #域名搜索列表option  domain-name-servers 114.114.114.114;    #域名服务器地址default-lease-time 600;                        #默认租约期限 (units per second) max-lease-time 7200;                            #最大租约期限 (units per second) log-facility local7;                            #使用rsyslogStorage Log subnet 192.168.3.0 netmask 255.255.255.0 {  range 192.168.3.10  192.168.3.254;           #地址池   option routers  192.168.3.1;                  #网关   option broadcast-address 192.168.3.31;      #广播地址    default-lease-time 600;                      max-lease-time 7200;  next-server  192.168.3.2;                     #下一个访问的服务器地址 (TFTP)   filename  "pxelinux.0";                      # Files that need to be downloaded on Next-server}

Check the configuration information, and then start the service:

[[Email protected] ~]# service DHCPD configtestsyntax:ok[[email protected] ~]# service DHCPD startstarting dhcpd: [OK]

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/F9/wKiom1XxCcShuz7jAABNhJFi_js888.jpg "title=" u@c@$_ N70$bbt[[41v9onfr.png "alt=" Wkiom1xxccshuz7jaabnhjfi_js888.jpg "/>

The service is running correctly.


Deploying a TFTP server

The TFTP service has XINETD service management, the service is opened in xinetd after the installation is complete, and the XINETD service is restarted.

[[email protected] ~]# yum install tftp-server[[email protected] ~]# chkconfig tftp on
[[email protected] ~]# vim /etc/xinetd.d/tftpservice tftp{         disable = no                                          #服务已变为可用状态          socket_type             =  dgram        protocol                 = udp         wait                     = yes        user                     = root         server                   = /usr/sbin/in.tftpd        server_args              = -s /var/lib/tftpboot         per_source               = 11        cps                      =  100 2        flags                    = ipv4}

SERVER_ARGS Specifies the parameters that the service starts, and-s specifies that its working directory is/var/lib/tftpboot. Place the files required by the client in this directory.

Start the service:

[Email protected] ~]# service xinetd restartstopping xinetd: [failed]starting X INETD: [OK]

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/72/F9/wKiom1XxDSSwUYqoAABJ_LPEknk543.jpg "title=" he%1[j %py$0) 5UE ' g$r@w76.png "alt=" Wkiom1xxdsswuyqoaabj_lpeknk543.jpg "/>

The service is running correctly.


Deploying HTTPD Services

[email protected] ~]# Yum install httpd

/mnt/flash is the Mount directory for the disc, create the directory under/var/www/html, and bind it to/mnt/flash.

[Email protected] ~]# mkdir-pv/var/www/html/centos/6/x86_64mkdir:created directory '/var/www/html/centos ' mkdir: Created directory '/VAR/WWW/HTML/CENTOS/6 ' mkdir:created directory '/var/www/html/centos/6/x86_64 ' [[email protected] ~]# Mount--bind/mnt/flash//var/www/html/centos/6/x86_64/

Once the bindings are complete, you can access the/mnt/flash/(installation source path) directly through/var/www/html/centos/6/x86_64/. Then start the service.

[[Email protected] ~]# service httpd start


Add the required files to the TFTP service directory:

Mount the disc image and copy the required files to the/var/lib/tftpboot directory, and the Mount directory for the disc image is/mnt/flash.

[[email protected] ~]# cp/mnt/flash/images/pxeboot/{vmlinuz,initrd.img}/var/lib/tftpboot/[[email protected] ~]# CP/ Mnt/flash/isolinux/{boot.msg,vesamenu.c32,splash.jpg}/var/lib/tftpboot/[[email protected] ~]# mkdir/var/lib/ Tftpboot/pxelinux.cfg[[email protected] ~]# cp/mnt/flash/isolinux/isolinux.cfg/var/lib/tftpboot/pxelinux.cfg/ Default

provides a PXE working environment that provides pxelinux.0 file):

[[email protected] ~]# yum install syslinux[[email protected] ~]# cp/usr/share/syslinux/pxelinux.0/var/lib/tftpboot/

pxelinux.0 will read VESAMENU.C32 to display the graphical interface during the run, splash.jpg as a background image, VESAMENU.C32 will read the Isolinux.cfg file Display graphic menu, isolinux.cfg file must be in PXELINUX.CF The G directory, and named Default. The graphical menu is as follows:

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/F9/wKiom1XxEHuB5of2AAJMlNyLUes105.jpg "title=" X21b1fmr958pj]732rt ' @05.png "alt=" Wkiom1xxehub5of2aajmlnylues105.jpg "/>

The graphical menu defaults to the first item, the corresponding configuration file is the default file under the Pxelinux.cfg directory, the file is modified, and the startup parameter KS is added for the first entry, so that it can get the kickstart file when the kernel is loaded.

[[email protected] ~]# vim/var/lib/tftpboot/pxelinux.cfg/default .... label Linux menu label ^install or "[E-mail] Upgrade an existing system menu default kernel vmlinuz append initrd=initrd.img ks=http://192.168.3.2/ks_file/ks.cfg t Ext


Provide kickstart file

[Email protected] ~]# cp/root/anaconda-ks.cfg/var/www/html/ks_file/ks.cfg[[email protected] ~]# chmod +r/var/www/ Html/ks_file/ks.cfg

You can use System-config-kickstart to make a kickstart file. The steps are simple, install System-config-kickstart, type the System-config-kickstart command to start a graphical interface, configure the parameters for the installation, and then generate the Kickstart file (similar to installing the operating system process).

in/ Root directory has a anaconda-ks.cfg file, which is the kickstart file, which records the local operating system installation parameters and other information. You can modify them and use them. The following is a modified section:

[[email protected] ~]# vim /var/www/html/ks_file/ks.cfgtext                       # Installing reboot                 in a text interface      #安装完成后自动重启selinux  --disabled        # Disable selinux.....  #以下是磁盘分区内容clearpart  --ALL --DRIVES=SDA PART /BOOT --FSTYPE=EXT4  --size=500part pv.008002 --grow --size=1volgroup vg_node1 --pesize=4096  pv.008002logvol /home --fstype=ext4 --name=lv_home --vgname=vg_node1 --grow -- Size=100logvol / --fstype=ext4 --name=lv_root --vgname=vg_node1 --grow --size= 1024 --maxsize=51200logvol swap --name=lv_swap --vgname=vg_node1 --grow --size= 1984 --maxsize=1984 urL --url= "http://192.168.3.2/centos/6/x86_64" repo --name= "CentOS"   --baseurl=http:// 192.168.3.2/centos/6/x86_64  --cost=100

The repo parameter above specifies the installation source path, which points to the disc mirroring path on the httpd server.


Test is available

Deploy a virtual machine without an operating system within the network segment and start. You can also set a virtual machine's first boot device as a network card.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/F9/wKiom1XxGQ3TmLLkAADtABGEc94716.jpg "title=" RF42STG3) ' hq{bxny_j]x ' I.png "alt=" Wkiom1xxgq3tmllkaadtabgec94716.jpg "/>

Boot interface

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/F6/wKioL1XxG4Tw3cZqAAIlmexDhQc194.jpg "title=" 4cq{53 %i[%h@hyym{]7a@87.png "alt=" Wkiol1xxg4tw3czqaailmexdhqc194.jpg "/>

Locate the installation source

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/72/F6/wKioL1XxHHzihlJXAAB2C8OhOlg917.jpg "title=" 9e@k7efs290o1au6@$5b{{7.png "alt=" Wkiol1xxhhzihljxaab2c8oholg917.jpg "/>

Installing the package process

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/72/F9/wKiom1XxGnaT1ldPAAEGOZUVttY692.jpg "title=" 28viv$ Iln%rq_0gwcun5uts.png "alt=" Wkiom1xxgnat1ldpaaegozuvtty692.jpg "/>

Complete the test .... ^_^ ....????




Pxe+kickstart for automatic installation centOS6.5

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.