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安裝系統的全過程

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