PXE批量化安装操作系统

  1. 安装所需服务

    yum install dhcp xinetd syslinux tftp-server httpd
    
  2. 配置dhcp服务
    vi /etc/dhcp/dhcpd.conf

    subnet 192.168.100.0 netmask 255.255.255.0 {
    	range 192.168.100.201 192.168.100.240;	#动态地址范围
    	option subnet-mask 255.255.255.0;		#子网掩码
    	option routers 192.168.100.1;		#网关地址192.168.100.1
    	# 指定引导服务器,即本机IP
    	next-server 192.168.100.150;	#本机ip192.168.100.150
    	# 引导文件
    	filename "pxelinux.0";
    }
    
  3. 重启dhcpd服务

    systemctl restart dhcpd
    systemctl enable dhcp
    
  4. 编辑tftp文件

    vi /etc/xinetd.d/tftp

    disable                 = no
    
  5. 重启服务

    systemctl restart xinetd
    systemctl restart tftp
    systemctl enable xinetd
    systemctl enable tftp
    
  6. 挂载需要安装的镜像到http访问目录

    mkdir /var/www/html/centos/7
    mount -o loop /home/CentOS7.2.iso /var/www/html/centos/7/
    
  7. 拷贝ks.cfg文件到http访问目录

    mkdir /var/www/html/centos/ks7/
    cp /home/ks.cfg /var/www/html/centos/ks7/
    
  8. 复制引导内核文件initrd.img和vmlinuz到tftp目录

    mkdir /var/lib/tftpboot/centos7
    cp /var/www/html/centos/7/images/pxeboot/initrd.img /var/lib/tftpboot/centos7/
    cp /var/www/html/centos/7/images/pxeboot/vmlinuz /var/lib/tftpboot/centos7/
    
  9. 设置syslinux加载器

    cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot
    cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
    
  10. 创建pxelinux.cfg目录并创建default引导菜单文件:

    mkdir /var/lib/tftpboot/pxelinux.cfg

    vi /var/lib/tftpboot/pxelinux.cfg/default

    default menu.c32
    	prompt 0
    	timeout 300
    	ONTIMEOUT local
    menu title ########## PXE Boot Menu ##########
    label 1
    menu label ^1) Install CentOS 7 x64 ^Minimal
    kernel centos7/vmlinuz
    append initrd=centos7/initrd.img ks=http://192.168.100.150/centos/ks7/ks.cfg10
    
  11. 关闭防火墙

    systemctl stop firewalld
    systemctl start tftp
    
  12. yum install system-config-kickstart

    ks.cfg

    #platform=x86, AMD64, or Intel EM64T
    #version=DEVEL
    # Install OS instead of upgrade
    install  	#开头
    # Keyboard layouts
    keyboard 'us'	# 设置系统键盘类型为us
    # Root password root密码
    rootpw --iscrypted $1$TBt8ea9M$HLbnZFucYSJyQRE2qK2bD/	
    # System language 语言
    lang zh_CN
    # System authorization information
    auth  --useshadow  --passalgo=sha512	# 系统认证信息,这里要是写密文密码需加  设置密码加密方式为sha512 启用
    # Use graphical install
    graphical
    firstboot --disable
    # SELinux configuration
    selinux --disabled
    # Firewall configuration
    firewall --disabled
    # Network information
    network  --bootproto=dhcp --device=ens33
    #network  --bootproto=static --device=eth0 --gateway=10.0.0.254 --ip=10.0.0.202 --nameserver=223.5.5.5 --netmask=255.255.255.0 --activate	#静态设置网卡
    # Reboot after installation
    reboot
    # System timezone 时区
    timezone Asia/Shanghai
    # Use network installation 镜像地址
    url --url="http://192.168.2.171/centos/7/"
    # System bootloader configuration
    bootloader --location=mbr
    # Clear the Master Boot Record	# 清除mbr引导信息
    zerombr
    # Partition clearing information
    clearpart --all --initlabel		#清空分区
    # Disk partitioning information 分区
    part /boot --fstype="xfs" --asprimary --size=1024
    part / --fstype="xfs" --asprimary --size=20480
    part swap --fstype="swap" --asprimary --size=1024
    part /home --fstype="xfs" --asprimary --size=10240
    #最小安装
    %packages --nobase
    @core
    %end
    

##需启动的服务tftp、dhcpd、xined、httpd
##需关闭的firewalld、selinux

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值