環境:CentOS 6.3 X86 minimal 安裝
所需軟體包:dhcp、tftp-server、syslinux、nfs、kickstart
1、 安裝、配置dncp服務。
安裝:yum -y install dhcp
複制配置檔案并改名
cp /usr/share/doc/dhcp-…/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
配置:vim /etc/dhcp/dhcpd.conf 以下為配置檔案内容
option domain-name-servers 202.106.0.20,202.106.46.151; //DNS
default-lease-time 600;
max-lease-time 7200;
ddns-update-style interim; //這個必須有
authoritative;
subnet 192.168.0.0 netmask 255.255.255.0 { //申明網段
range 192.168.0.220 192.168.0.230; //配置設定位址範圍
option routers 192.168.0.1; //客戶機網關
option subnet-mask 255.255.255.0; //子網路遮罩
next-server 192.168.0.210; //指定tftp伺服器位址
filename "/pxelinux.0"; //指定啟動檔案 (相對與../tftpboot路徑)
}
DHCP 配置完成。
2、 安裝、配置tftp-server服務。
安裝:yum -y install tftp-server (tftp被xinetd管理)
配置:vim /etc/xinetd.d/tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -u nobody -s /var/lib/tftpboot //加了 -u nobody 所有人可以使用
disable = no //原為yes 改為no 為啟用的意思
per_source = 11
cps = 100 2
flags = IPv4
tftp-server 配置完成。
3、 安裝syslinux (為了生成pxelinux.0這個檔案)
安裝:yum -y install syslinux
檔案在 /usr/share/syslinux/pxelinux.0
4、 配置
将pxelinux.0複制到tftp共享目錄
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
挂載CD光牒,并複制isolinux目錄下所有檔案到tftp共享目錄
mount /dev/cdrom /mnt
cp /mnt/isolinux/* /var/lib/tftpboot/
cd /var/lib/tftpboot/
建立pxelinux.cfg目錄,并将isolinux.cfg移動到目錄下改名為default
mkdir pxelinux.cfg
mv isolinux.cfg pxelinux.cfg/default
5、 配置nfs服務(預設已經安裝)網上說有個portmap 這已經不用了,改為rpcbind
vim /etc/exports //預設為空檔案
/mnt 192.168.0.0/24(ro,sync) //ro 隻讀共享,sync 在記憶體中共享
儲存退出,導出共享目錄,啟動所有服務,關閉防火牆、SElinux,設定啟動級别

至此,已經可以實作pxe引導安裝,但還不是無人值守!
這裡選擇nfs directory
預設,自動擷取IP位址
設定NFS伺服器IP iso鏡像存放位置 之後就進入安裝頁面!
6、 安裝、配置kickstart 實作無人值守安裝。
首先要有桌面環境支援,由于我系統是minimal安裝的,是以沒有裝桌面,我們要先安裝桌面(GNOME)。而桌面(GNOME)又由X-window環境支援,所有還要裝X-window。
yum grouplist | grep -i “x window system” yum grouplist | grep -i desktop
雖然顯示有這兩個包,但是直接安裝完還是不能用,要先執行yum update
安裝:yum -y groupinstall “X Window System” //嚴格區分大小寫
yum -y groupinstall “Desktop” //嚴格區分大小寫
yum -y groupinstall “Chinese Support” //安裝中文支援
OK!我們切換到圖形界面執行接下來的步驟。init 5
安裝:yum -y install system-config-kickstart
啟動:system-config-kickstart //進入工具界面配置
點選<檔案>儲存到<檔案系統>選擇路徑/nfsinstall
mkdir /nfsinstall cp ks.cfg /nfsinstall chmod 777 ks.cfg
vim /etc/exports
/nfsinstall 192.168.0.0/24(ro,srnc) //共享/nfsinstall 這個目錄
編輯default檔案
vim /var/lib/tftpboot/pxelinux.cfg/default
加入 ks=nfs:192.168.0.210:/nfsinstall/ks.cfg
ß---------------------------------default 檔案内容-----------------------------------------à
default vesamenu.c32
#prompt 1
timeout 50 //這裡改為50,為等待5秒 預設為600 即60秒
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.3!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000
label linux
menu label ^Install or upgrade an existing system
menu default
kernel vmlinuz
append ks=nfs:192.168.0.210:/nfsinstall/ks.cfg initrd=initrd.img //紅色字型為添加後的
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
menu label ^Rescue installed system
kernel vmlinuz
append initrd=initrd.img rescue
label local
menu label Boot from ^local drive
localboot 0xffff
label memtest86
menu label ^Memory test
kernel memtest
append -
ß--------------------------------------default---------------------------------------------à
ß----------------------------------ks.cfg 檔案内容-----------------------------------------à
#platform=x86, AMD64, 或 Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use NFS installation media
nfs --server=192.168.0.210 --dir=/mnt
# Root password
rootpw --iscrypted $1$R0pI15Yt$hlTsbDR5TFDCIDTLtgT2w.
# System authorization information
auth --useshadow --passalgo=sha512
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Africa/Abidjan
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --asprimary --fstype="ext3" --size=200
part swap --fstype="swap" --size=2048
part / --fstype="ext3" --grow --size=1
%packages
@basic-desktop
@chinese-support
@input-methods
@internet-applications
@internet-browser
@x11
%end
ß--------------------------------------ks.cfg----------------------------------------------à
OK 然後,重新開機所有服務 開始測試。
成功标志為:測試機隻需開機(引導方式為網絡引導),就可以完成安裝。
真正的無人值守 ^_^