linux学习笔记3PXE自动化安装操作系统

centos7 PXE自动化安装

环境配置

(1)关闭防火墙

 

systemctl stop firewalld
systemctl disable firewalld

查看防火墙状态

systemctl status firewalld

(2)关闭selinux

setenforce 0

 

永久关闭

vi /etc/selinux/config 
//将参数修改为
SELINUX=disabled

 

(3)配置网络环境

 

 

修改静态IP

vi /etc/sysconfig/network-scripts/ifcfg-ens33

 

(4)安装相关服务

yum install -y httpd tftp tftp-server dhcp syslinux

 

(5)配置dhcp服务

vi /etc/dhcp/dhcpd.conf

 

参数:

subnet 192.168.128.0 netmask 255.255.255.0 { option routers 192.168.128.1; #网关 range 192.168.128.100 192.168.128.200;#地址池 next-server 192.168.128.128;#dhcp服务器 filename "pxelinux.0"; }

开启dhcp服务

systemctl start dhcpd

查看dhcp服务是否开启

systemctl status dhcpd

 

(6)配置httpd服务

//创建软件包存放目录
mkdir /var/www/html/Centos

将镜像文件临时挂载到此目录

mount /dev/sr0 /var/www/html/Centos

使用df命令查看

df -hT

 

(7)配置所需的文件

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot
cp /var/www/html/Centos/isolinux/{vmlinuz,*.c32,initrd.img} /var/lib/tftpboot/
mkdir /var/lib/tftpboot/pxelinux.cfg
vi /var/lib/tftpboot/pxelinux.cfg/default

 

/var/lib/tftpboot/pxelinux.cfg/default 文件的配置参数:

default linux

prompt 0

timeout 10

label linux

kernel vmlinuz

Append initrd=initrd.img ip=dhcp method=http://192.168.100.106/Centos ks=http://192.168.100.106/ks.cfg

(8)启动tftp服务

systemctl start tftp

查看tftp服务状态

systemctl status tftpshell

 

(9)创建ks.cfg脚本文件

vi /var/www/html/ks.cfg

 

/var/www/html/ks.cfg 文件参数:

ignoredisk --only-use=sda autopart --type=lvm clearpart --all #安装界面的提示界面为图形 graphical #安装界面的提示界面为文字 #text url --url="http://192.168.100.23/Centos/" rootpw --plaintext 123456 keyboard --vckeymap=cn --xlayouts='cn' lang zh_CN.UTF-8 selinux --disabled network --bootproto=dhcp --device=ens33 --ipv6=auto --activate network --hostname=localhost.localdomain xconfig --startxonboot firstboot --disable services --enabled="chronyd"

System timezone

timezone Asia/Shanghai

System bootloader configuration

bootloader --location=mbr

Clear the Master Boot Record

zerombr

Partition clearing information

clearpart --all

Disk partitioning information

reboot eula --agreed %packages #安装图形界面 @^graphical-server-environment #安装命令行界面 #@^infrastructure-server-environment %end %addon com_redhat_kdump --disable --reserve-mb='auto' %end %anaconda pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty %end

(10)修改权限并启动httpd服务

chmod a+r /var/www/html/ks.cfg

启动httpd服务

systemctl start httpd

查看httpd服务状态

systemctl status httpd

 

(11)使用未安装操作系统的虚拟机进行验证

运行截图

 

注:

不管安不安装图形化界面都最好将内存设置到2GB及以上

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值