shell脚本一键装机(pxe配合kickstart无人值守)
shell脚本一键装机(pxe配合kickstart无人值守)
shell脚本实现无人值守安装
图文详细步骤可以参前期博文:
PXE批量网络装机(超详细实验教程)教会你自动化批量安装linux 系统
vim pxe.sh
#!/bin/bash
#安装并启用 TFTP 服务
rpm -qc tftp-server.x86_64if [ $? -ne 0 ]then
yum install -y tftp-server.x86_64 &> /dev/nullfi
rpm -qc xinetdif [ $? -ne 0 ]thenyum -y install xinetd &>/dev/nullfised -i 's/yes/no/g' /etc/xinetd.d/tftp
systemctl start tftp
systemctl enable tftp
systemctl start xinetd
systemctl enable xinetd
#安装并启用 DHCP 服务
yum -y install dhcp &>/dev/null
\cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
echo 'ddns-update-style none;
next-server 192.168.126.20;
filename "pxelinux.0";' >> /etc/dhcp/dhcpd.confecho 'subnet 192.168.126.0 netmask 255.255.255.0 {
range 192.168.126.100 192.168.126.200;
option routers 192.168.126.20;
}' >> /etc/dhcp/dhcpd.conf
systemctl start dhcpd
systemctl enable dhcpd
#准备 Linux 内核、初始化镜像文件
df -h | grep sr0
if [ $? -eq 0 ]
then
echo "光盘镜像已挂在"
elsemount /dev/cdrom /mnt
fi
\cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot
\cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot#准备 PXE 引导程序
yum -y install syslinux &>/dev/null
\cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/#安装FTP服务,准备CentOS 7 安装源
yum -y install vsftpd &>/dev/null
mkdir /var/ftp/centos7
\cp -rf /mnt/* /var/ftp/centos7/
systemctl start vsftpd
systemctl enable vsftpd#配置启动菜单文件
mkdir /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default
cat > /var//lib/tftpboot/pxelinux.cfg/default <<EOF
default auto
prompt 0
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.126.20/centos7 ks=ftp://192.168.126.20/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.126.20/centos7
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.126.20/centos7
EOF
#关闭防火墙,验证PXE安装
systemctl stop firewalld.service
setenforce 0
yum install -y system-config-kickstart &>/dev/null
\cp /root/ks.cfg /var/ftp/ks.cfg
/root/ks.cfg的内容
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Install OS instead of upgrade
install
# Keyboard layouts
keyboard 'us'
# Root password
rootpw --iscrypted $1$W.DC43qQ$xKFG9eiHd9shGDTYvzucb.
# Use network installation
url --url="ftp://192.168.126.20/cenos7"
# System language
lang zh_CN
# Firewall configuration
firewall --disabled
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# SELinux configuration
selinux --enforcing# Network information
network --bootproto=dhcp --device=ens33
# Halt after installation
halt
# System timezone
timezone Asia/Shanghai
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --size=500
part swap --fstype="swap" --size=4096
part /home --fstype="xfs" --size=4096
part / --fstype="xfs" --grow --size=1%post --interpreter=/bin/bash
rm -rf /etc/yum.repos.d/*
echo '[local]
name=local
baseurl=ftp://192.168.126.20/centos7
enabled=1
gpgcheck=0’ > /etc/yum.repos.d/local.repo
%end%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
@x11
chrony
kexec-tools%end
shell脚本一键装机(pxe配合kickstart无人值守)相关推荐
- PXE配合Kickstart无人值守装机
PXE配合Kickstart无人值守装机 一.PXE概述 二.PXE批量部署的优点 三.部署PXE远程安装服务 四.搭建PXE远程安装服务器 1.安装并启用TFTP 服务 2.安装并启用DHCP服务 ...
- 如何不费吹灰之力的装机?部署PXE实现Kickstart无人值守安装 — 装机界的最强王者
部署PXE实现Kickstart无人值守安装 一.部署PXE远程安装服务 1.1 PEX服务相关介绍 1.2 PXE服务的工作原理 1.3 搭建PXE远程安装服务器大概步骤 1.4 实验:使用VMwa ...
- shell脚本一键安装nginx
使用shell脚本一键安装Nginx 操作环境Centos7,联网进行安装. 代码如下: #!/bin/bash #this is nginx.sh #date 2018.10.6 [ $(i ...
- shell脚本一键安装二进制Apache
转载来源 :shell脚本一键安装二进制Apache : http://www.178linux.com/23401 安装背景:用的一台最小化安装的centos6. 编译安装安装的必备安装gcc,gc ...
- 超实用的shell脚本--一键获取进程所有信息
转载来源 :超实用的shell脚本–一键获取进程所有信息 :http://www.safebase.cn/article-257427-1.html 摘要: 概述有时我们想只是通过一个进程PID就可以 ...
- Tomcat脚本一键装机
实验名称:Tomcat一键装机实验 实验目的:练习tomcat脚本一键装机 实验环境:CentOS 7(一台) 配置如下: 1.将tamcat包.tamcat脚本.jdk1.7包复制粘贴到虚拟机 ta ...
- shell脚本一键部署lnmp架构
shell脚本一键部署lnmp架构 1. 创建存放脚本的目录 2. 创建脚本文件 3. 编写脚本 4. 通过IP地址直接访问PHP界面 1. 创建存放脚本的目录 [root@localhost ~]# ...
- shell脚本 一键部署 Lnmp 及社区论坛 服务架构
shell脚本 一键部署 Lnmp 一键部署 Lnmp 一键部署 注:亲,记得把所需要的软件包,先放到/opt目录中:以及该机子的内存大小.核数先设置好! #!/bin/bash #先配置好yum e ...
- shell脚本一键部署LNMP
前言 使用shell脚本一键部署LNMP需要的安装包 nginx-1.15.9.tar.gz mysql-boost-5.7.20.tar.gz php-7.1.10.tar.bz2 Discuz_X ...
最新文章
- 录音转成文字 android,安卓手机自带的录音转文字功能这么强大,堪称会议神器!你会用吗...
- Oracle SQL脚本学习记录一
- C程序中如何获取shell命令执行结果和返回值
- LeetCode 1909. 删除一个元素使数组严格递增
- Apache java文件比对,Java Apache Commons的字符串比较
- 滑动翻页效果_Flutter实现3D效果,一个字,炫!
- js字符串转换为json对象JSON.parse()及将json对象转为json字符串JSON.stringify()
- 洛谷P1821 [USACO07FEB]银牛派对Silver Cow Party
- 前端项目(1)--《学成在线》简单首页
- 未来教育mysql下载_未来教育计算机二级题库中的视频为什么无法播放
- postman下载安装汉化及使用
- 1.为什么要使用token,token是什么?
- 笔记本电脑桌面的计算机图标不见了,win7系统笔记本电脑桌面计算机图标不见了的解决方法...
- 网段划分 特殊网段(localhost0.0.0.01.1.1.1127.0.0.1)
- 小六壬(邵一尘大师博客有介绍)
- 因为Windows防火墙服务未运行,不能正常使用
- 五常大米引入蚂蚁金服区块链,从大米“出生”就开始“验明正身”
- 企业混合多云“芯”体验,上云、用数、赋智“组合拳”
- 三星P528 GPRS配置
- 康佳P200投影仪咋样?和哈趣H1哪个更好,对比两款投影仪参数区别