Centos6.5下 PXE+Kickstart無人值守安裝
阿新 • • 發佈:2018-01-27
transacti == cdrom resolved finished png share max ase Centos6.5下 PXE+Kickstart無人值守安裝
PXE(Preboot eXecute Environment,預啟動執行環境)是由Intel公司開發的技術,可以讓計算機通過網絡來啟動操作系統(前提是計算機上安裝的網卡支持PXE技術),主要用於在無人值守安裝系統中引導客戶端主機安裝Linux操作系統。Kickstart是一種無人值守的安裝方式,其工作原理是預先把原本需要運維人員手工填寫的參數保存成一個ks.cfg文件,當安裝過程中需要填寫參數時則自動匹配Kickstart生成的文件。
為了讓服務器與客戶端主機進行文件傳輸,並分配IP可用的地址 我們先來配置DHCP服務
[root@localhost ~]# yum install dhcp -y Loaded plugins: fastestmirror Determining fastest mirrors * c6-media: Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package dhcp.x86_64 12:4.1.1-38.P1.el6.centos will be installed --> Processing Dependency: portreserve for package: 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 --> Running transaction check ---> Package portreserve.x86_64 0:0.0.4-9.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================== Package Arch Version Repository Size ============================================================== Installing: dhcp x86_64 12:4.1.1-38.P1.el6.centos c6-media 817 k Installing for dependencies: portreserve x86_64 0.0.4-9.el6 c6-media 23 k Transaction Summary ============================================================= Install 2 Package(s) Total download size: 840 k Installed size: 1.9 M Downloading Packages: ------------------------------------------------------------------------------------------------------------- Total 12 MB/s | 840 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : portreserve-0.0.4-9.el6.x86_64 1/2 Installing : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 2/2 Verifying : 12:dhcp-4.1.1-38.P1.el6.centos.x86_64 1/2 Verifying : portreserve-0.0.4-9.el6.x86_64 2/2 Installed: dhcp.x86_64 12:4.1.1-38.P1.el6.centos Dependency Installed: portreserve.x86_64 0:0.0.4-9.el6 Complete!
復制這個文件為dhcp的配置文件
[root@localhost ~] cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf‘? y
修改dhcp配置文件[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
指定引導服務器和引導驅動文件 “pxelinux.0” # A slightly different configuration for an internal subnet. subnet 192.168.100.0 netmask 255.255.255.0 { range 192.168.100.10 192.168.100.50; default-lease-time 600; max-lease-time 7200; next-server 192.168.100.1; filename "pxelinux.0"; }
保存退出
安裝tftp服務提供引導及驅動文件
[root@localhost ~]# yum install tftp-server -y Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * c6-media: Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package tftp-server.x86_64 0:0.49-7.el6 will be installed --> Processing Dependency: xinetd for package: tftp-server-0.49-7.el6.x86_64 --> Running transaction check ---> Package xinetd.x86_64 2:2.3.14-39.el6_4 will be installed --> Finished Dependency Resolution Dependencies Resolved =============================================================================================================================================================== Package Arch Version Repository Size =============================================================================================================================================================== Installing: tftp-server x86_64 0.49-7.el6 c6-media 39 k Installing for dependencies: xinetd x86_64 2:2.3.14-39.el6_4 c6-media 121 k Transaction Summary =============================================================================================================================================================== Install 2 Package(s) Total download size: 161 k Installed size: 317 k Downloading Packages: --------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 3.0 MB/s | 161 kB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : 2:xinetd-2.3.14-39.el6_4.x86_64 1/2 Installing : tftp-server-0.49-7.el6.x86_64 2/2 Verifying : tftp-server-0.49-7.el6.x86_64 1/2 Verifying : 2:xinetd-2.3.14-39.el6_4.x86_64 2/2 Installed: tftp-server.x86_64 0:0.49-7.el6 Dependency Installed: xinetd.x86_64 2:2.3.14-39.el6_4 Complete!
配置tftp服務
[root@localhost ~]# vim /etc/xinetd.d/tftp
# default: off
# description: The tftp server serves files using the trivial file transfer # protocol. The tftp protocol is often used to boot diskless # workstations, download configuration files to network-aware printers, # and to start the installation process for some operating systems.
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
建立tftp存儲目錄[root@localhost ~]# mkdir /tftpboot
安裝syslinux軟件 (提供引導文件)
[root@localhost ~]# yum install syslinux -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package syslinux.x86_64 0:4.02-8.el6 will be installed
--> Processing Dependency: mtools for package: syslinux-4.02-8.el6.x86_64
--> Running transaction check
---> Package mtools.x86_64 0:4.0.12-1.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
syslinux x86_64 4.02-8.el6 c6-media 859 k
Installing for dependencies:
mtools x86_64 4.0.12-1.el6 c6-media 194 k
Transaction Summary
===============================================================================================================================================================
Install 2 Package(s)
Total download size: 1.0 M
Installed size: 2.3 M
Downloading Packages:
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 21 MB/s | 1.0 MB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mtools-4.0.12-1.el6.x86_64 1/2
Installing : syslinux-4.02-8.el6.x86_64 2/2
Verifying : syslinux-4.02-8.el6.x86_64 1/2
Verifying : mtools-4.0.12-1.el6.x86_64 2/2
Installed:
syslinux.x86_64 0:4.02-8.el6
Dependency Installed:
mtools.x86_64 0:4.0.12-1.el6
Complete!
復制引導文件到tftp目錄下[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
安裝鏡像還有引導文件 需要復制到tftpboot下面[root@localhost ~]# cp /mnt/isolinux/* /tftpboot/
tftpboot目錄下創立pxelinux.cfg目錄 並復制isolinux.cfg 改名為default
#default文件是開機時的選項菜單
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]#
[root@localhost tftpboot]#
[root@localhost tftpboot]# cp isolinux.cfg pxelinux.cfg/default
[root@localhost tftpboot]# vim pxelinux.cfg/default
default vesamenu.c32
#prompt 1
timeout 1
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.5!
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 initrd=initrd.img ks=ftp://192.168.100.1/pub/ks.cfg
label vesa
menu label Install system with ^basic video driver
kernel vmlinuz
append initrd=initrd.img xdriver=vesa nomodeset
label rescue
ks.cfg為我們指定的應答文件
安裝vsftpd傳輸光盤鏡像給客戶機
[root@localhost tftpboot]# yum install vsftpd -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c6-media:
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vsftpd.x86_64 0:2.2.2-11.el6_4.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===============================================================================================================================================================
Package Arch Version Repository Size
===============================================================================================================================================================
Installing:
vsftpd x86_64 2.2.2-11.el6_4.1 c6-media 151 k
Transaction Summary
===============================================================================================================================================================
Install 1 Package(s)
Total download size: 151 k
Installed size: 331 k
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1
Verifying : vsftpd-2.2.2-11.el6_4.1.x86_64 1/1
Installed:
vsftpd.x86_64 0:2.2.2-11.el6_4.1
Complete!
將完整光盤鏡像復制到vsftp的匿名目錄下
[root@localhost tftpboot] cp -rp /mnt/* /var/ftp/pub/
[root@localhost pub] cp /root/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[root@localhost pub] vim /var/ftp/pub/ks.cfg
# Kickstart file automatically generated by anaconda.
#version=DEVEL
install
cdrom
url --url=ftp://192.168.100.1/pub
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw --iscrypted $6$1B9c8VVXZm4BJZ6n$BemGfzmvSZ2BmpUeikQhpffk0/58gKCdw9mE1o5Wv9aEjQcj60iUogaNO7KXBuT.dO08JXrde/O6vbihVtzKG.
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
省略.....
repo --name="CentOS" --baseurl=ftp://192.168.100.1/pub
開一臺虛擬機選擇橋接模式 開啟電源
會獲取到鏡像
開始安裝
Centos6.5下 PXE+Kickstart無人值守安裝