pxe+dhcp+kickstart

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pxe+dhcp+kickstart相关的知识,希望对你有一定的参考价值。

废话少来,只接开干;

一、安装 dhcp、tftp-server、httpd、syslinux、system-config-kickstart、桌面环境。其中syslinux是为了生成pxelinux.0文件;system-config-kickstart配置ks.cfg文件工具


1、 # yum -y  install  dhcp  tftp-server  httpd  syslinux  system-config-kickstart



2、 配置dhcp

      # cp  /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf

      # vim  /etc/dhcp/dhcpd.conf

                #全局配置:
                ddns-update-style interim;
                ignore client-updates;
                default-lease-time 86400;
                max-lease-time 86400;
                #子网作用域:
                subnet 192.168.1.0 netmask 255.255.255.0 {
                            range dynamic-bootp 192.168.1.22 192.168.1.30;
                            option routers 192.168.1.1;
                            option subnet-mask 255.255.255.0;
                            allow booting;
                            allow bootp;
                            filename "pxelinux.0";
                            next-server 192.168.1.200;
                 }
                #保留地址:
                #host passacaglia {
                #}


3、配置tftp

     # vim /etc/xinetd.d/tftp

            service 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

            }


4、http配置,默认安装完成即可。只需创建一个存放iso的目录

    # mkdir  -pv /var/www/html/centos6


二、启动文件及系统镜像的准备

    1、准备系统iso,可将安装光盘下所有文件copy至 /var/www/html/centos6/下,或只接挂载光盘。本文采用只接挂载方式:

        # mount /dev/sr0 /var/www/html/centos6/

    2、准备pxe启动所需文件:

        # cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/         \\pxelinux.0一个强大的网络引导程序,复制到tftp主目录下

        # cp /var/www/html/centos6/images/pxeboot/{vmlinuz,initrd.img}  /var/lib/tftp/boot/   \\复制光盘中内核、remdisk文件

        # cp /var/www/html/centos6/isolinux/{boot.msg,vesamenu.c32,splash.jpg} /var/lib/tftpboot/    \\复制启动菜单等文件

        # mkdir -pv /var/lib/tftpboot/pxelinux.cfg    \\创建一个存放菜单配置文件的目录

        # cp /var/www/html/centos6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default  \\复制菜单配置文件并改名

        说明:以上所注意的是光盘中images是存放内核的目录,isolinux是存放系统启动所需的系统文件。pxelinux.0是通过安装包所得。

    3、编辑启动菜单配置文件default:简单修改

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

                    default vesa     \\选择安装标签
                       #prompt 1       \\是否显示boot:
                       timeout 3600    \\超时时间

                        display boot.msg

                        menu background splash.jpg
                        menu title Welcome to CentOS 6.8!
                        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
                        menu label ^Install or upgrade an existing system
                        menu default
                        kernel vmlinuz
                        append initrd=initrd.img
                        label vesa
                        menu label Install system with ^basic video driver
                        kernel vmlinuz
                        append ks=http://192.168.1.200/ks.cfg initrd=initrd.img nomodeset
                        label rescue
                       menu label ^Rescue installed system
                       kernel vmlinuz
                       append initrd=initrd.img rescue
                       label local
                       menu label Boot from ^local drive
                       localboot 0xffff
                       label memtest86
                      menu label ^Memory test
                      kernel memtest
                      append -

    4、在桌面模式下生成ks.cfg文件并复制到/var/www/html/ks.cfg

        # system-config-kickstart

              51cto贴图太tm坑了吧! 吐槽一下!不爽!

        步骤:

            选择时区、选择安装完重启、选择重置bootloader、选择清除所有分区、选择安装方式:http--->http://192.168.1.200   目录:centos6 、配置安装的分区,选择安装包。ok搞定,保存文件至/var/www/html/ks.cfg。

    5、开启服务:

        # service httpd start

        # service dhcpd start

        # service xinetd restart


    6、测试:

        先测试httpd:打开浏览器输入:http://192.168.1.200/ks.cfg   然后输入:http://192.168.1.200/centos6  如果打开不正常请检查httpd 服务是否正常 ,防火墙是否正常。

        开启客户端网卡启动。

                            

本文出自 “allen03301” 博客,请务必保留此出处http://allen03301.blog.51cto.com/1300992/1881347

以上是关于pxe+dhcp+kickstart的主要内容,如果未能解决你的问题,请参考以下文章

PXE

PXE基础装机环境 案例2:配置并验证DHCP服务 案例3:配置PXE引导

ironic 裸金属pxe获取dhcp失败

pxe+http 批量安装虚拟机

linux-PXE-12

pxe+dhcp+kickstart