通过使用PXE实现无人值守安装操作系统

一、环境准备

  • 一台centos7操作系统,地址:172.16.16.253/24
  • 关闭防火墙、selinux
  • 配置本地yum源

二、服务安装

yum install -y dhcp tftp-server httpd syslinux

三、服务配置

[root@pxe ~]# cat /etc/dhcp/dhcpd.conf
subnet 172.16.16.0 netmask 255.255.255.0 {
  range 172.16.16.10 172.16.16.210;  #地址范围
  default-lease-time 3600;  #默认超时时间
  next-server 172.16.16.253;  #TFTP服务器地址
  filename "pxelinux.0";  #引导文件syslinux
}
[root@pxe ~]# cat /etc/xinetd.d/tftp
# 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                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no  #修改此处为no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
cp /mnt/isolinux/vmlinuz /var/lib/tftpboot
cp /mnt/isolinux/initrd.img /var/lib/tftpboot
mkdir pxelinux.cfg
touch default
[root@pxe pxelinux.cfg]# vim default
default menu.c32  #调用菜单文件
timeout 300  #设置超时时间
prompt 0  
label 1  #菜单
menu label ^1) install centos7  #显示内容
menu default  #默认菜单
kernel vmlinuz  #调用内核文件
append initrd=initrd.img method=http://172.16.16.253/centos7 ks=http://172.16.16.253/ks.cfg
mkdir /var/www/html/centos7
cp /mnt/* /var/www/html/centos7
cp anaconda-ks.cfg /var/www/html/ks.cfg

四、重启服务

重启所有服务,将网络与需要部署的服务器连接,开始自动部署操作系统。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值