基于网络PXE自动化安装CentOS 7
来源:互联网 发布:德国骨科 知乎 编辑:程序博客网 时间:2024/06/06 05:48
PXE原理:
Preboot Excution Environment 预启动执行环境,是Intel公司研发
基于Client/Server的网络模式,支持远程主机通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统PXE可以引导和安装Windows,linux等多种操作系统。PXE自动安装系统过程如下所示:
基于PXE安装centos7 过程:
- 1.安装前准备:关闭防火墙和SELINUX
[root@centos7 ~]#getenforce 检查selinux 状态Disabled[root@centos7 ~]#iptables -vnLChain INPUT (policy ACCEPT 201K packets, 8505K bytes) pkts bytes target prot opt in out source destination Chain FORWARD (policy ACCEPT 0 packets, 0 bytes) pkts bytes target prot opt in out source destination Chain OUTPUT (policy ACCEPT 201K packets, 2597M bytes) pkts bytes target prot opt in out source destination
防火墙可以通过 iptables -F 来关闭。
selinux 可以通过 setenforce 0 临时关闭。
- 2安装相关软件包
yum install httpd tftp-server dhcp syslinux
- 3 配置文件共享服务和yum源
systemctl enable httpd 设置为开机启动
systemctl start httpd 启动httpd 服务
mkdir /var/www/html/centos/7
mount /dev/sr0 /var/www/html/centos/7 把光盘挂载到目录下,也可以copy 到该目录下。
- 4 准备kickstart文件
cp /root/anaconda-ks.cfg /var/www/html/ksdir/ks7-1.cfg chmod +r /var/www/html/ksdir/ks7-1.cfgvim /var/www/html/ksdir/ks7-1.cfg cat ks7-1.cfg #version=DEVEL# System authorization informationauth --enableshadow --passalgo=sha512# Use CDROM installation media url --url=http://192.168.10.33/centos/7# Use graphical install text# Run the Setup Agent on first bootfirstboot --enableignoredisk --only-use=sda# Keyboard layoutskeyboard --vckeymap=us --xlayouts='us'# System languagelang en_US.UTF-8# Network information network --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --activatenetwork --hostname=centos7.magedu.com# Root passwordrootpw --iscrypted $6$Z7LBEUpwj3iQdYZ3$olYQ.Lj1xV2VAGS1UiNflKF0oMGip3b6tU9QFcp0i2JBjwKlY/Yaexul57NHpIJc.Y2V1hWAOueaqwjuWDGMk0# System servicesservices --disabled="chronyd"# System timezonetimezone Asia/Shanghai --isUtc --nontpuser --name=wang --password=$6$v.VphW/puRblcrFB$uaSrdEhGAwMXap27WIKTn5lyOOfoFyB/SNxyyL3og6s9/VQoAKoL2KQjKmeYFmoYTuYkSNL7BBxgbJzeryKr9. --iscrypted --gecos="wang"# X Window System configuration informationxconfig --startxonboot# System bootloader configurationbootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda# Partition clearing information zerombr clearpart --all# Disk partitioning informationpart swap --fstype="swap" --ondisk=sda --size=2048part /app --fstype="xfs" --ondisk=sda --size=51200part / --fstype="xfs" --ondisk=sda --size=51200part /boot --fstype="xfs" --ondisk=sda --size=1024 reboot%packages@^graphical-server-environment@base@core@desktop-debugging@dial-up@fonts@gnome-desktop@guest-agents@guest-desktop-agents@hardware-monitoring@input-methods@internet-browser@multimedia@print-client@x11kexec-tools autofs%end%addon com_redhat_kdump --enable --reserve-mb='auto'%end%anacondapwpolicy root --minlen=6 --minquality=50 --notstrict --nochanges --notemptypwpolicy user --minlen=6 --minquality=50 --notstrict --nochanges --notemptypwpolicy luks --minlen=6 --minquality=50 --notstrict --nochanges --notempty%end%postsystemctl enable autofsrm -rf /etc/yum.repos.d/*cat > /etc/yum.repos.d/base.repo <<eof[base]name=basebaseurl=file:///misc/cdgpgcheck=0eof%end
- 5.配置tftp
systemctl enable tftp.socket 设置开机启动
systemctl start tftp.socket 启动tftp服务
netstat -unl 检查状态DHCP服务
- 6.配置DHCP服务
vim /etc/dhcp/dhcpd.confoption domain-name "example.com";default-lease-time 600;max-lease-time 7200;subnet 192.168.10.0 netmask 255.255.255.0 { range 192.168.10.50 192.168.10.100; next-server 192.168.10.33; filename "pxelinux.0";}systemctl enable dhcpdsystemctl start dhcpd
- 7 准备PXE相关文件
mkdir /var/lib/tftpboot/pxelinux.cfg/ 创建目录
cp/usr/share/syslinux/{pxelinux.0,menu.c32} /var/lib/tftpboot/
cp /misc/cd/isolinux/{vmlinuz,initrd.img,} /var/lib/tftpboot/ 把光盘里的内核文件和伪根文件拷贝到tftpboot 目录下
cp /misc/cd/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
- 8 制作启动菜单文件
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout 600
menu title CentOS Linux 7 PXE Install
label desktop
menu label Auto Install CentOS Linux 7 ^Desktop
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.10.33/ksdir/ks7-1.cfg #tftp server 地址
label mini
menu label Auto Install CentOS Linux 7 M^ini
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.10.33/ksdir/ks7-2.cfg
label local
menu default
menu label Boot from ^local drive
localboot 0xffff
menu end
文件列表如下:
[root@centos7 ~]#tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── initrd.img
├── menu.c32
├── pxelinux.0
├── pxelinux.cfg
│ └── default
└── vmlinuz
- 9 新机器系统安装
安装时候可以根据需要选择,我们选桌面版,这样就可以顺利完成安装了。
- 基于网络PXE自动化安装CentOS 7
- pxe网络自动化安装
- 网络PXE自动化安装
- CentOS 6.5基于DHCP的PXE自动化安装系统详解
- PXE, DHCP, TFPT 实现自动化安装 CentOS
- CentOS 6.5自动化运维之基于DHCP和TFTP服务的PXE自动化安装centos操作系统详解
- PXE网络引导自动化安装系统详解
- Centos6/7来网络引导(pxe)安装centos
- Centos 6.5 基于PXE自动安装Linux
- PXE 自动化安装注意事项
- pxe&全自动化安装
- pxe自动化安装配置
- 通过网络启动自动化安装CentOS 7
- CentOS 基于Kickstart自动化安装
- Centos安装TFTP/NFS/PXE服务器网络引导安装系统
- 网络自动安装centos{dhcp+pxe+tftp+http)
- Kickstart+PXE+DHCP+TFTP+FTP网络安装CentOS系统
- pxe全自动化安装虚拟机
- poj1463 Strategic game 树形dp
- Spring MVC学习指南(5-7章总结)
- CentOS下Maven的安装
- 深度学习Caffe
- Spark +hadoop 完全分布式搭建 以及常见问题
- 基于网络PXE自动化安装CentOS 7
- linux 查看运行进程所在目录
- JVM 垃圾回收机制主要原理
- Zabbix使用微信发送告警(附Python代码)
- 悲观锁与乐观锁
- Git 和 SVN 之间的五个基本区别
- String、Stringbuilder和Stringbuffer
- 打开虚拟机时显示不是有效的虚拟机配置文件是什么原因啊
- hdu1028(母函数应用)