SHELL脚本之配置PXE批量无人值守装机
发表于:2025-02-21 作者:千家信息网编辑
千家信息网最后更新 2025年02月21日,PXE批量无人值守装机脚本准备2个网卡:第一个网卡使用NET,用来安装服务第2个网卡用来提供dhcp服务#!/bin/bash#部署pxe批量装机服务#配置双网卡#定义网卡配置文件位置k=/etc/s
千家信息网最后更新 2025年02月21日SHELL脚本之配置PXE批量无人值守装机
PXE批量无人值守装机脚本
准备2个网卡:
第一个网卡使用NET,用来安装服务
第2个网卡用来提供dhcp服务
#!/bin/bash#部署pxe批量装机服务#配置双网卡#定义网卡配置文件位置k=/etc/sysconfig/network-scripts#复制网卡配置文件模板cd /etc/sysconfig/network-scriptscp -p ifcfg-ens33 ifcfg-ens36#修改第2块网卡配置文件sed -i 's/dhcp/static/' $k/ifcfg-ens36sed -i 's/ens33/ens36/' $k/ifcfg-ens36sed -i '/UUID/d' $k/ifcfg-ens36cat >>$k/ifcfg-ens36 <<-EOFIPADDR=192.168.100.100NETMASK=255.255.255.0GATEWAY=192.168.100.1EOF#重启网络服务systemctl restart network#防止yum安装进程休眠rm -rf /var/run/yum.pid#安装必要服务yum install dhcp syslinux tftp-server vsftpd -y#修改DHCP服务配置文件cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.confcat >>/etc/dhcp/dhcpd.conf <<-EOFsubnet 192.168.100.0 netmask 255.255.255.0 {range 192.168.100.10 192.168.100.20;option routers 192.168.100.100;next-server 192.168.100.100;filename "pxelinux.0";}EOF#定义要经常用的tftp站点tftp=/var/lib/tftpboot#复制引导程序到tftp站点cp /usr/share/syslinux/pxelinux.0 $tftp/#修改tftp配置文件sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp#创建镜像文件挂载点cd /var/ftpmkdir centos7#挂载镜像文件mount /dev/sr0 /var/ftp/centos7#复制压缩内核和系统初始化文件到tftp站点cd centos7/images/pxebootcp initrd.img vmlinuz $tftp#在tftp站点中创建启动菜单存放位置cd $tftpmkdir pxelinux.cfgcd pxelinux.cfg#创建启动菜单文件cat >default <<-EOFdefault autoprompt 1label autokernel vmlinuzappend initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfglabel linux textkernel vmlinuzappend text initrd=initrd.img method=ftp://192.168.100.100/centos7label linux rescuekernel vmlinuzappend rescue initrd=initrd.img method=ftp://192.168.100.100/centos7EOF#安装系统工具yum install system-config-kickstart -y#创建系统安装过程文件cat >/var/ftp/ks.cfg <<-EOF#platform=x86, AMD64, 或 Intel EM64T#version=DEVEL#Install OS instead of upgradeinstall#Keyboard layoutskeyboard 'us'#Root passwordrootpw --plaintext 123#Use network installationurl --url="ftp://192.168.100.100/centos7/"#System languagelang zh_CN#System authorization informationauth --useshadow --passalgo=sha512#Use graphical installgraphicalfirstboot --disable#SELinux configurationselinux --disabled#Firewall configurationfirewall --disabled#Network informationnetwork --bootproto=dhcp --device=ens33#Reboot after installationreboot#System timezonetimezone Asia/Shanghai#System bootloader configurationbootloader --location=mbr#Partition clearing informationclearpart --all#Disk partitioning informationpart /boot --fstype="xfs" --size=500part swap --fstype="swap" --size=4096part /home --fstype="xfs" --size=4096part / --fstype="xfs" --grow --size=1%packages@^gnome-desktop-environment@base@core@desktop-debugging@dial-up@directory-client@fonts@gnome-desktop@guest-agents@guest-desktop-agents@input-methods@internet-browser@java-platform@multimedia@network-file-system-client@networkmanager-submodules@print-client@x11chronykexec-tools%endEOF#关闭防火墙systemctl stop firewalld.servicesetenforce 0#启动所有服务systemctl start dhcpdsystemctl start tftpsystemctl start vsftpd
网卡
配置
服务
文件
脚本
位置
模板
防火墙
准备
防火
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
采购管理数据库设计
米家小白网络安全问题
硬盘格式化软件开发
360G9服务器电池报错
银行软件开发规范
亿点智堂武汉网络技术有限公司
网络安全展览网站
浙大清华网络安全哪个好
数据库什么时候做索引
登录页面调用数据库原理
计算机网络技术高级术语
蜡笔网络安全绘画简笔画
中国日报网网络安全
2018网络安全教育
软件开发 需求变更
命令提示符怎么进入服务器的后台
怎样理解数据库中的实体
为企业内部的管理服务器
数据库部署要求
使用的数据库管理系统
方舟生存进化专用服务器快速驯龙
思科模拟器的web服务器在哪里
国家网络安全法教育日
五大连池app软件开发
excel内容变成数据库
西安市网络安全应急管理
北京软件开发费用
软件开发计算机工程
pwt数据库
数据库软件安装为何失败