PXE之Centos系统安装

PXE

PXE介绍
Preboot Excution Environment 预启动执行环境
Intel 公司研发
基于Client/Server的网络模式,支持远程主机通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统
PXE可以引导和安装Windows,linux等多种操作系统
PXE工作原理
PXE之Centos系统安装
Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地址,同时将启动文件pxelinux.0的位置信息一并传送给Client
Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.0
Client执行接收到的pxelinux.0文件
Client向TFTP Server发送针对本机的配置信息文件(在TFTP 服务的pxelinux.cfg目录下),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操作。
Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发送给Client
Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件系统
Client启动Linux内核
Client下载安装源文件,读取自动化安装脚本
PXE自动化安装CentOS 7
1.关闭防火墙和SElinux
# systemctl stop firewalld.service
# setenforce 0
SELinux 配置文件:
vim /etc/sysconfig/selinux
SELINUX=disabled
2.安装程序包(tftp-server,http,dhcp,syslinux),启动服务并设置为开机自启动
# yum install dhcp tftp-server syslinux http
# systemctl enable dhcpd tftp httpd
# systemctl start httpd tftp.socket
# rpm -ql dhcp 查看配置文件: /etc/dhcp/dhcpd.conf
# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
# vim /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.10 192.168.1.100;
option routers 192.168.1.254; #指定网关
option domain-name-servers 223.5.5.5, 114.114.114.114; #指定域名服务器
next-server 192.168.1.5; #指定获取系统引导文件的服务器IP(tftp)
filename “pxelinux.0”; #引导文件名称
}
补充:dhcpd服务需要修改配置文件才可启动
# systemctl start dhcpd
# ss -tunlp 来查看对应的服务端口是否打开(dhcpd:67(dhclient: 68) tftp:69 httpd:80)
3.创建光盘挂载点和ks文件目录
# mkdir /var/www/html/centos/{6,7} -pv
# mkdir /var/www/html/ksdir/{6,7} -pv
# vim /etc/fstab
/dev/sr0 /var/www/html/centos/6/ iso9660 defaults 0 0 (Centos7光盘)
/dev/sr1 /var/www/html/centos/7/ iso9660 defaults 0 0 (Centos6光盘)
# mount -a
# df -h 查看是否挂载成功
# cat /var/www/html/ksdir/6/ks_centos6.cfg(chmod +r ks_centos6.cfg)
ks_centos6.cfg(Mini)
*****************************************************************************************************
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
url –url=http://192.168.1.5/centos/6
lang en_US.UTF-8
keyboard us
network –onboot yes –device eth0 –bootproto dhcp –noipv6 –nameserver 8.8.8.8 –hostname centos6.localdomain
rootpw –iscrypted $6$NjFYm33MgYv/N9I6$wqynBfE5UfImxskNKNSII0jdo/1pp8BxMrO2cwZJxfJUbheSNdvAqgOpaJegzO.SRvACIswIHsWw4FAzD92RY0
firewall –disabled
authconfig –enableshadow –passalgo=sha512
selinux –disabled
timezone Asia/Shanghai
bootloader –location=mbr –driveorder=sda –append=”crashkernel=auto rhgb quiet”
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
zerombr
clearpart –all
part /boot –fstype=ext4 –size=500
part / –fstype=ext4 –size=20000
part /data –fstype=ext4 –size=20000
part swap –size=2048
reboot
%packages
@core
@server-policy
@workstation-policy
%end
******************************************************************************************************
# cat /var/www/html/ksdir/7/ks_centos7.cfg(chmod +r ks_centos7.cfg)
ks_centos7.cfg(Mini)
******************************************************************************************************
#version=DEVEL
# System authorization information
auth –enableshadow –passalgo=sha512
# Use CDROM installation media
url –url=http://192.168.1.5:/centos/7
# Use graphical install
text
# Run the Setup Agent on first boot
firstboot –enable
ignoredisk –only-use=sda
# Keyboard layouts
keyboard –vckeymap=us –xlayouts=’us’
# System language
lang en_US.UTF-8
selinux –disabled
firewall –disabled
# Network information
network –bootproto=dhcp –device=ens33 –onboot=on –ipv6=auto –activate
network –hostname=centos7.localdomain
# Root password
rootpw –iscrypted $6$gBxf9D1qFAeD4TiK$rAZGNzOE3TFWE7x.dPk6zmwGT4QzGko9QdIK4cofzhTvAIAeqxcJYCL7d8JAHWQYkUQ57R/iiJoTIXHugOZYy0
# System services
services –disabled=”chronyd”
# System timezone
timezone Asia/Shanghai –isUtc –nontp
# System bootloader configuration
bootloader –append=” crashkernel=auto” –location=mbr –boot-drive=sda
autopart –type=lvm
# Partition clearing information
zerombr
clearpart –all
reboot
%packages
@^minimal
@core
kexec-tools
%end
%addon com_redhat_kdump –enable –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
******************************************************************************************************
4.tftp服务器分别创建centos6和centos7文件夹,并复制系统引导文件至tftp服务器
# mkdir /var/lib/tftpboot/centos{6,7}
# cp /var/www/html/centos/7/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/centos7
# cp /var/www/html/centos/6/isolinux/{initrd.img,vmlinuz} /var/lib/tftpboot/centos6
5.创建pxelinux.cfg文件夹,复制syslinux 软件包中的pxelinux.0 引导文件和菜单背景图片
# mkdir /var/lib/tftpboot/pxelinux.cfg
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
# cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
# cp /var/www/html/centos/6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
# cat /var/lib/tftpboot/pxelinux.cfg/default
*************************************************************************************
default menu.c32
#prompt 1
timeout 600
menu title Welcome to Install CentOS System!
label Centos6_mini
menu label ^Install Centos ^6 Mini System
kernel centos6/vmlinuz 注意此处与下处的路径(相对于pxelinux.cfg文件夹所在的路径)
append initrd=centos6/initrd.img ks=http://192.168.1.5/ksdir/6/ks_centos6.cfg
label Centos7_mini
menu label Install Centos ^7 Mini System
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.1.5/ksdir/7/ks_centos7.cfg
label local
menu label Boot from ^local drive
localboot 0xffff
menu end
**************************************************************************************
6.创建新的虚拟机并通过网卡来引导系统

本文来自投稿,不代表Linux运维部落立场,如若转载,请注明出处:http://www.178linux.com/99599

(0)
涤生涤生
上一篇 2018-05-27
下一篇 2018-05-27

相关推荐

  • 一些常用的文本工具

    cat命令:查看文本内容 cat [选项]… [文件]… -E    显示行结束符 -n    显示文本内容时显示行号 -A    显示所以控制符 -b    非空行编号 -s     压缩连续的空行成一行 head命令 : -n  显示文件前n行,默认显示前10行 -c # 显示文件前#个字节内容 tail命令: tail [选项]…

    2018-04-09
  • linux下find的用法及练习

    find命令详解

    Linux笔记 2018-04-15
  • 文件管理基础知识

                   文件管理 目录篇 / :根目录 bin    boot    dev    etc    home    root    run     sbin    tmp    usr   var 字符界面颜色的意义: 蓝色=目录、绿色=可执行文件、红色=压缩文件、浅蓝色=链接文件 灰色=其他文件 boot:引导文件的存放目录  bin:…

    Linux笔记 2018-04-08
  • linux sed用法总结

    处理文本的工具sedStream EDitor, 行编辑器sed是一种流编辑器,它一次处理一行内容。处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。然后读入下行,执行下一个循环。如果没有使诸如‘D’的特殊命令,那会在两个循环之间清空模式空间,…

    Linux笔记 2018-04-15
  • CENTOS开机流程

    开机流程 centos 5和6版本开机流程kernel==>rootfs(根文件系统)首先内核启动,然后加载根文件系统,然后启动init(第一个文件系统)它负责所有的程序的启动、管理、调用、删除等(这一切是运行在用户空间的)。 “`kernel:进程管理内存管理网络管理驱动程序文件系统安全功能 rootfs:glibc“` 库:…

    Linux笔记 2018-05-13
  • 实验:正向主DNS实现 实验:反向解析DNS 实验:从DNS服务器实现

    实验:正向主DNS实现实验:反向解析DNS 实验:从DNS服务器实现 在主服务器vim /etc/named.confallow-transfer { slaveip;}; 加此行从服务器vim /etc/named.confallow-transfer { none;}; 加此行 vim /etc/named.rfc1912.zoneszone &#822…

    2018-06-01