Linux系統PXE高效批量網絡裝機的配置

Linux系統PXE高效批量網絡裝機的配置

配置環境:html

服務器IP地址爲192.168.1.10,所在網段爲192.168.1.0/24;linux

1、首先須要準備系統安裝源centos

 

[root@www ~]# mkdir -pv /var/ftp/centos6/
[root@www ~]# cp -rf /media/cdrom/* /var/ftp/centos6/

 

2、部署FTP服務服務器

 

[root@www ~]# yum -y install vsftpd
[root@www ~]# service vsftpd start

 

3、部署TFTP服務網絡

[root@www ~]# yum -y install tftp-server

編輯 /etc/xinetd.d/tftp配置文件,將disable=yes改成disable=no 重啓xinetd服務便可。app

# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = no   //把yes改成no  
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no     //把yes改成no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

啓動服務less

[root@www ~]# service xinetd start

4、準備linux內核和初始化文件。socket

Linux內核和初始化鏡像文件能夠從linux鏡像中找到,位於文件夾/images/pxeboot中,將vmlinuz和initrd.img複製到tftp的根目錄/var/lib/tftpboot/下ide

Vmlinuz:linux內核                    測試

initrd.img:初始化鏡像文件

[root@www ~]# cd /media/cdrom/images/pxeboot/
[root@www pxeboot]# ls
initrd.img  TRANS.TBL  vmlinuz
[root@www pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/

5、接下來在準備PEX引導程序,啓動菜單文件

Linux引導程序爲pxelinux.0 該文件由syslinux軟件包提供,所以咱們要安裝syslinux軟件包,並複製到tftp根目錄下

 

[root@www ~]# yum -y install syslinux
[root@www ~]# cd /usr/share/syslinux/
[root@www syslinux]# cp pxelinux.0 /var/lib/tftpboot/

 

默認的啓動菜單爲default,該文件應該放置在tftp根目錄的pxelinux.cfg中,並重命名爲default。

[root@www ~]# cd /media/cdrom/
[root@www cdrom]# ls
CentOS_BuildTag  isolinux                  RPM-GPG-KEY-CentOS-Debug-6
EFI              Packages                  RPM-GPG-KEY-CentOS-Security-6
EULA             RELEASE-NOTES-en-US.html  RPM-GPG-KEY-CentOS-Testing-6
GPL              repodata                  TRANS.TBL
images           RPM-GPG-KEY-CentOS-6
[root@www cdrom]# cd isolinux/
[root@www isolinux]# ls
boot.cat  grub.conf   isolinux.bin  memtest     TRANS.TBL     vmlinuz
boot.msg  initrd.img  isolinux.cfg  splash.jpg  vesamenu.c32
[root@www isolinux]# cp isolinux.cfg /var/lib/tftpboot/

 

[root@www syslinux]# cd /var/lib/tftpboot/
[root@www tftpboot]# mkdir pxelinux.cfg
[root@www tftpboot]# cp isolinux.cfg pxelinux.cfg/default

修改default文件內容以下:

default linux       //名字隨便起
prompt 0           //0表示自動選擇,1表示等待用戶確認
timeout 600       //超時時間  60s



label linux
  menu label ^Install or upgrade an existing system
  menu default
  kernel vmlinuz
  append  initrd=initrd.img
label text            //文本安裝
  menu label Install system with ^basic video driver
  kernel vmlinuz
  append text initrd=initrd.img xdriver=vesa nomodeset
label rescue        //救援模式
  menu label ^Rescue installed system
  kernel vmlinuz

6、安裝部署DHCP服務

[root@www ~]# yum -y install dhcp
[root@www ~]# cd /usr/share/doc/dhcp-4.1.1/
[root@www dhcp-4.1.1]# cp dhcpd.conf.sample /etc/dhcp/dhcpd.conf 

修改配置文件以下:

只需在配置文件裏添加網段聲明便可;

subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.10 192.168.1.20;
  option routers 192.168.1.10;
  filename "pxelinux.0";             //制定PXE引導程序名
  next-server 192.168.1.10;      //添加ftp服務器的
}
[root@www ~]# service dhcpd start

這裏爲了方便測試,咱們把防火牆規則清空;

[root@www ~]# iptables -F
[root@www ~]# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

最後就是新建虛擬機進行測試了,此過程略過,須要注意的是把新建的虛擬機網卡選擇在同一個網卡下;

在這裏,咱們一塊兒成長!!!

相關文章
相關標籤/搜索