Centos6.5下 PXE+Kickstart无人值守安装
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos6.5下 PXE+Kickstart无人值守安装相关的知识,希望对你有一定的参考价值。
Centos6.5下 PXE+Kickstart无人值守安装
PXE(Preboot eXecute Environment,预启动执行环境)是由Intel公司开发的技术,可以让计算机通过网络来启动操作系统(前提是计算机上安装的网卡支持PXE技术),主要用于在无人值守安装系统中引导客户端主机安装Linux操作系统。Kickstart是一种无人值守的安装方式,其工作原理是预先把原本需要运维人员手工填写的参数保存成一个ks.cfg文件,当安装过程中需要填写参数时则自动匹配Kickstart生成的文件。
为了让服务器与客户端主机进行文件传输,并分配IP可用的地址 我们先来配置DHCP服务
[[email protected] ~]# 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的配置文件
[[email protected] ~] cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
cp: overwrite `/etc/dhcp/dhcpd.conf‘? y
修改dhcp配置文件[[email protected] ~]# 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服务提供引导及驱动文件
[[email protected] ~]# 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服务
[[email protected] ~]# 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存储目录[[email protected] ~]# mkdir /tftpboot
安装syslinux软件 (提供引导文件)
[[email protected] ~]# 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目录下[[email protected] ~]# cp /usr/share/syslinux/pxelinux.0 /tftpboot/
安装镜像还有引导文件 需要复制到tftpboot下面[[email protected] ~]# cp /mnt/isolinux/* /tftpboot/
tftpboot目录下创立pxelinux.cfg目录 并复制isolinux.cfg 改名为default
#default文件是开机时的选项菜单
[[email protected] tftpboot]# mkdir pxelinux.cfg
[[email protected] tftpboot]#
[[email protected] tftpboot]#
[[email protected] tftpboot]# cp isolinux.cfg pxelinux.cfg/default
[[email protected] 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传输光盘镜像给客户机
[[email protected] 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的匿名目录下
[[email protected] tftpboot] cp -rp /mnt/* /var/ftp/pub/
[[email protected] pub] cp /root/anaconda-ks.cfg /var/ftp/pub/ks.cfg
[[email protected] 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无人值守安装的主要内容,如果未能解决你的问题,请参考以下文章
KickStart+nfs+dhcp+tftp无人值守批量安装CentOS6.5(或CentOS7)