實現基於PXE安裝centos7,centos6 系統

實現基於PXE安裝centos7,centos6 系統

 

centos 6 ks6_mini.cfg

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
text
reboot
url --url="http://192.168.209.19/centos/6/os/x86_64"
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$GCv0ZPTezB/WrPey$88EAdsXyDjdSXdn8ly/ntjh3DiUyH/UyiFDp72Y1CMsv2EydA3LrEzOHQcKIKtjXUtrtsSkUOPLlC52kRVV4V/
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
clearpart --all
zerombr

part /boot --fstype=ext4 --size=500
part / --fstype=ext4 --size=20000
part /data --fstype=ext4 --size=10000
part swap --size=2048


%packages
%end

%post
cat > /etc/yum.repos.d/test.repo <<EOF
[base]
baseurl=http://192.168.209.19/centos/6/os/x86_64
gpgcheck=0
EOF
%end

centos 7 ks7_mini.cfghtml

install
keyboard 'us'
rootpw --plaintext centos
url --url="http://192.168.209.19/centos/7/os/x86_64"
lang en_US
auth  --useshadow  --passalgo=sha512
text
firstboot --disable
selinux --disabled
firewall --disabled
network  --bootproto=dhcp --device=eth0
reboot
timezone Asia/Shanghai
bootloader --append="net.ifnames=0" --location=mbr
zerombr
clearpart --all
part / --fstype="xfs" --size=20000
part /boot --fstype="xfs" --size=500
part swap --fstype="swap" --size=2000

%packages
@^minimal
autofs
%end

%post
mv /etc/sysconfig/network-scripts/ifcfg-{ens33,eth0}
sed -i 's@ens33@eth0@g' /etc/sysconfig/network-scripts/ifcfg-eth0
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak
cat > /etc/yum.repos.d/test.repo <<EOF
[base]
baseurl=http://192.168.209.19/centos/7/os/x86_64
gpgcheck=0
EOF
%end

pxe 服務器的配置

yum install tftp-server httpd dhcp syslinux -y
systemctl start tftp httpd
systemctl enable tftp httpd 

vim /etc/dhcp/dhcpd.conf
	option domain-name "xuepeng.com";
	option domain-name-servers 180.76.76.76,114.114.114.114;
	default-lease-time 86400;
	max-lease-time 864000;
	subnet 192.168.209.0 netmask 255.255.255.0 {
	range 192.168.209.200 192.168.209.250;
	option routers 192.168.209.2;
	next-server 192.168.209.19;
	filename "pxelinux.0";
	}
	
systemctl start|enable dhcpd

mkdir -p /var/www/html/centos/{6,7}/os/x86_64
添加一塊光驅 /dev/sr1
mount /dev/sr0 /var/www/html/centos/7/os/x86_64
mount /dev/sr1 /var/www/html/centos/6/os/x86_64

mkdir /var/www/html/ksdir
vim /var/www/html/ksdir/{ks7_mini.cfg,ks6_mini.cfg}  //在上面單獨列出來了

cd /var/lib/lftp/
cp /usr/share/syslinux/{pxelinux.0,menu.c32} .
mkdir centos{6,7}
cp /var/www/html/centos/7/os/x86_64/isolinux/{vmlinuz,initrd.img} centos7/
cp /var/www/html/centos/6/os/x86_64/isolinux/{vmlinuz,initrd.img} centos6/
mkdir pxelinux.cfg/

vim pxelinux.cfg/default 
	default menu.c32
	timeout 600
	menu title CentOS Auto Install

	label mini 7
	menu label Install CentOS ^Mini 7
	kernel centos7/vmlinuz
	append initrd=centos7/initrd.img ks=http://192.168.209.19/ksdir/ks7_mini.cfg

	label mini 6
	menu label Install CentOS ^Mini 6
	kernel centso6/vmlinuz
	append initrd=centos6/initrd.img ks=http://192.168.209.19/ksdir/ks6_mini.cfg

	label local
	menu default
	menu label Boot form ^local drive
	localboot 0xffff

pxe 客戶端的配置

    從網卡啓動,選擇本身想要安裝的選項,便可自動安裝系統linux

相關文章
相關標籤/搜索