服务器端配置
第一步:关闭iptables和SElinux
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# service iptables stop
[root@localhost ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
第二步:挂载镜像,安装TFTP与DHCP服务,并进行配置。
[root@localhost ~]# mount /dev/hdc /mnt
mount: block device /dev/hdc is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/Server/
[root@localhost Server]# rpm -ivh tftp-server-0.42-3.1.i386.rpm
warning: tftp-server-0.42-3.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
package tftp-server-0.42-3.1.i386 is already installed
[root@localhost Server]# rpm -ivh dhcp-3.0.5-18.el5.i386.rpm
warning: dhcp-3.0.5-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
配置TFTP服务器
[root@localhost Server]# vi /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 = -u nobody -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
第四步:安装并配置NFS服务器
#查看是否已安装NFS服务器,如果没有安装,进入/mnt/Server/进行安装
[root@localhost ~]# rpm -qa | grep "nfs\|portmap"
portmap-4.0-65.2.2.1
nfs-utils-1.0.9-40.el5
nfs-utils-lib-1.0.8-7.2.z2
[root@localhost ~]# vi /etc/exports
/disk *(ro.sync)
[root@localhost ~]# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [FAILED]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@localhost ~]# exportfs //输出NFS配置文件,检查是否生效
/disk <world>
第五步:启动DHCP、NFS、TFTP服务
[root@localhost disk]# service dhcpd start
Starting dhcpd: [ OK ]
[root@localhost disk]# service portmap start
Starting portmap: [ OK ]
[root@localhost disk]# service nfs start
[root@localhost disk]# service xinetd start
Starting xinetd:
第六步:将安装配置脚本文件(/root/anaconda-ks.cfg),重命名为ks.cfg,复制到/disk目录下,然后并共享出/disk目录。
[root@localhost disk]# cd /root
[root@localhost ~]# ls
anaconda-ks.cfg Desktop install.log install.log.syslog
[root@localhost ~]# cp anaconda-ks.cfg /disk/ks.cfg
[root@localhost ~]# exportfs -a; service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@localhost ~]# vi /disk/ks.cfg
将cdrom修改为:nfs --server=192.168.1.146 --dir=/disk
将network --device eth0 --bootproto dhcp修改为:network --device eth0 --bootproto dhcp
将#clearpart --all --drives=sda修改为:clearpart --all –initlabel
第七步:配置支持PXE,复制启动时所需要文件。
#确保/tftproot目录存在,不存在,手工创建。
[root@localhost ~]# ls -d /tftpboot/ || make /tftpboot/
/tftpboot/
[root@localhost ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/
注意:如果找不到syslinux目录与pxelinux.0文件,那么你就必须安装软件包:syslinux-3.11-4.i386.rpm
[root@localhost ~]# mkdir /tftpboot/pxelinux.cfg
[root@localhost ~]# cd /media/
[root@localhost media]# ls
RHEL_5.3 i386 DVD
[root@localhost media]# cp /media/RHEL_5.3\ i386\ DVD/isolinux/isolinux.cfg /tftpboot/pxelinux.cfg/default
[root@localhost media]# cp /media/RHEL_5.3\ i386\ DVD/isolinux/* /tftpboot/
[root@localhost media]# chmod u+w /tftpboot/pxelinux.cfg/default
[root@localhost media]# vi /tftpboot/pxelinux.cfg/default
timeout 60 //将超时时间修改为60秒
append initrd=initrd.img text 修改为:append ks=nfs:192.168.1.146:/disk/ks.cfg initrd=initrd.img
第八步:重启DHCP、NFS、TFTP服务。
[root@localhost ~]# service nfs restart
Shutting down NFS mountd: [ OK ]
Shutting down NFS daemon: [ OK ]
Shutting down NFS quotas: [ OK ]
Shutting down NFS services: [ OK ]
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@localhost ~]# service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
[root@localhost ~]# service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
Starting xinetd: [ OK ]
接下来,创建新的linux虚拟机,点击开机按钮, 即可到系统的安装界面。