PXE+TFTP+FTP+kickstart完成自动化安装CentOS7.4

39 篇文章 1 订阅
24 篇文章 0 订阅

准备工作

  • 服务机IP
    • 192.168.200.200
  • 关闭selinux
    • 打开/etc/selinux/config
    • 将selinux=enforceing 改为 selinux=disabled
  • 关闭firewalld
    • systemctl stop firewalld
    • systemctl disable firewalld

DHCPD

  • 安装
    • yum -y install dhcp
  • 配置文件
    • /etc/dhcp/dhcpd.conf
  • 参数说明
    • default-lease-time 默认超过时间
    • max-lease-time 最大超时时间
    • subnet 网段
    • netmask 掩码
    • option routers 本身IP
    • range dynamic-bootp 起始IP和结束IP
  • 启动
    • systemctl start dhcpd
    • systemctl enable dhcpd
  • 现阶段配置
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

subnet 192.168.200.0 netmask 255.255.255.0 {
	option routers	192.168.200.200;
	option subnet-mask	255.255.255.0;
	option time-offset	-18000;
	range dynamic-bootp	192.168.200.125 192.168.200.126;
	next-server 192.168.200.200;
	filename "pxelinux.0";
}

FTP

  • 安装
    • yum -y install vsftpd
  • 挂载
    • 挂载cdrom到 /var/ftp/pub
    • mount /dev/cdrom /var/ftp/pub
    • 必要的话可以把这句哈写到rc.local里,避免重启之后还需手动挂载
  • 启动
    • systemctl start vsftpd
    • systemctl enable vsftpd

xinetd

  • 安装
    • yum -y install xinetd
    • yum -y install tftp-server tftp syslinux-tftpboot
  • 配置文件
    • /etc/xinetd.d/tftp
    • 将disable=yes 改为 disable=no

syslinux

  • 安装
    • yum -y install syslinux

复制操作

  • 复制网络启动所需文件到tftp服务器的根目录下
    • cp -rf /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
    • cp /var/ftp/pub/isolinux/{boot.cat,boot.msg,grub.conf,isolinux.bin,splash.png,TRANS.TBL,vesamenu.c32} /var/lib/tftpboot
    • cp /var/ftp/pub/images/pxeboot/initrd.img /var/lib/tftpboot/
    • cp /var/ftp/pub/images/pxeboot/vmlinuz /var/lib/tftpboot/
  • 创建启动菜单目录
    • mkdir /var/lib/tftpboot/pxelinux.cfg
  • 将启动菜单放到固定目录中,并且修改文件名为default
    • cp /var/ftp/pub/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
  • 修改default文件
    • 前三行改为
      • default linux
      • prompt 1
      • timeout 1
    • 找到 label linux 这一块,改为
      • label linux
      • menu label ^Install CentOS7
      • kernel vmlinuz
      • append initrd=initrd.img text ks=ftp://192.168.200.200/ks.cfg
  • 复制无人值守自动应答文件
    • cp ~/anaconda-ks.cfg /var/ftp/ks.cfg

ks配置文件

  • 路径
    • 服务机:/var/lib/ks.cfg
  • 参数说明
    • install
      • 全新安装
    • firewall -disabled
      • 关闭防火墙
    • auth --enableshadow --passalgo=sha512
      • 认证方式
    • graphical
      • 安装图形化
    • keyboard --vckeymap=us --xlayouts=‘us’
      • 键盘布局格式
    • lang en_US.UTF-8
      • 系统语言
    • rootpw --iscrypted $alnfaafa…
      • root密码,后面是加密过的
    • selinux --disabled
      • 关闭selinux
    • clearpart --all
      • 清除旧磁盘上的数据。旧磁盘可能会有其他数据谨慎操作
    • zerombr
      • 清除MBR分区表
    • bootloader --append="…"
      • bootloader相关参数的设定
    • part /data00 --fstype=“xfs” --ondisk=sda --size=20000 --grow
      • –fstype=“xfs”
        • 指定类型为xfs
      • –ondisk=sda
        • 指定磁盘为sda
      • –size=20000
        • 指定大小为20000MB
      • –grow
        • 将这个磁盘剩余所有的空间全部分给这个部分
    • %packages
    • %end
      • 将要安装的包名放在?两个标签之中
    • %post
    • %end
      • 将自定义的shell脚本放在?两个标签中间
  • 给ks.cfg权限
    • chmod +r /var/ftp/ks.cfg

重启

  • 重启xinetd
    • systemctl start xinetd
    • systemctl enable xinetd
  • 重启dhcpd
    • systemctl start dhcpd
    • systemctl enable dhcpd
  • 重启vsftpd
    • systemctl start vsftpd
    • systemctl enable vsftpd

使用

  • 将客户机与服务机是用网线相连
  • 设置客户机为网卡启动
  • 开机即可自动安装
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值