PXE

概述:
在实际工作中,我们经常会遇到这样的情况:想要安装Linux但是计算机没有光驱,或者是有大批量的计算机需要同时安装Linux,如果通过光驱的方式一个个安装,不仅效率低,也不利于维护。这是时候你就需要PXE的强大功能了。本文基于centos7进行;
实验环境描述:
文件服务器为http
dhcp和tftp及httpd服务器都为同一台CentOS 6主机;
网络环境都为VMnat2.
1、安装dhcp服务器,配置自定义作用域;

yum install dhcp -y

# cd /etc/dhcp/
# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample ./dhcpd.conf
# vim dhcpd.conf 

PXE
将文件中的不需要用到的进行注释掉;
PXE
PXE
PXE
启动DHCP服务器;
PXE
2.配置tftp服务器,启动

yum install tftp-server tftp -y

# service xinetd restart 

PXE
3.准备安装的系统文件

yum install syslinux -y

# cp /usr/share/syslinux/pxelinux.0  /var/lib/tftpboot/
# cp /var/www/html/CentOS6/images/pxeboot/{vmlinuz,initrd.img} /var/lib/tftpboot/
# cp /var/www/html/CentOS6/isolinux/{boot.msg,vesamenu.c32,splash.jpg} /var/lib/tftpboot/

PXE

4.在/var/lib/tftpboot下创建提供菜单的配置文件(菜单加载时用到的配置文件信息)
PXE
5.制作kickstart文件,放到/var/www/html/kickstarts/下
PXE
PXE
KS文件示例:
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL

Firewall configuration

firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.91.100/centos/"
# Root password
rootpw --iscrypted $1$iRHppr42$VMesh73wBqhUTjKp6OYOD.
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info --host=10.1.0.1
# Reboot after installation
reboot
# System timezone
timezone  Asia/Shanghai
# System bootloader configuration
bootloader --append="rhgb crashkernel=auto quiet" --location=mbr --driveorder="sda"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all  
# Disk partitioning information
part /boot --fstype="ext4" --size=200
part pv.008 --size=61440

volgroup vg0 --pesize=8192 pv.008
logvol / --fstype=ext4 --name=root --vgname=vg0 --size=20480
logvol swap --name=swap --vgname=vg0 --size=2048
logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=10240
logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=20480

%post

%end

%packages
@base
@basic-desktop
@chinese-support
@client-mgmt-tools
@core
@desktop-platform
@fonts
@general-desktop
@graphical-admin-tools
@legacy-x
@network-file-system-client
@perl-runtime
@remote-desktop-clients
@x11

%end

6.在/var/lib/tftpboot/pxelinux.cfg/default 中配置引导保证能加载kickstart文件,如下:
PXE

7.新建一个虚拟机,要和服务器主机在同一网络中(VMnat2),启动后,成功获取ip,跳转到安装界面,可以看到我们自定义的auto安装项;
PXE
PXE
PXE
以上,就是使用PXE安装系统的全过程

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章