RHEL6.0系统自动安装之PXE

 

一、原理篇

 

原理请基于博文“ubuntu 10.04系统自动安装之PXE(局域网内)”

二、实战篇

1.准备工作

PXE server 系统是:rhel-server-6.0-i386,内核版本:2.6.32-71.el6.i686

镜像下载:https://content-web.rhn.redhat.com/rhn/isos/rhel-6.0/md5sum/291d234c93442405972689b4b41c14bc/rhel-server-6.0-i386-dvd.iso?__gda__=1289452095_01d4d0835d8bf9a5fe6f7b34caea76a6&ext=.iso

关闭防火墙:service iptables stop

关闭selinux:

#vim /etc/sysconfig/selinux

SELINUX=disabled

2.yum 环境的搭建

光盘文件copy:

#mount /dev/cdrom /mnt

#mkdir /home/var/isofile -p

#cp –r /mnt/* /home/var/isofile

yum的搭建:

#vim /etc/yum.repo.d/pxeserver.repo

[base]

name=base

baseurl=file:///home/var/isofile

gpgcheck=no

 

测试yum的搭建是否正确: #yum list

3.dhcp的安装与配置

#yum install dhcp

配置dhcp:

#vim /etc/dhcp/dhcpd.conf

subnet 192.168.0.0 netmask 255.255.255.0 { #dhcpserver 分配ip的子网192.168.0网段,必须和PXE server的一个网卡同一个网段
range 192.168.0.100 192.168.0.200; #为客户端分配ip范围
option domain-name "192.168.0.105";
option domain-name-servers 192.168.0.105; #此项不写可能在自动安装时让您手动添加,这样达不到自动化的目的
option routers 192.168.0.111;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.0.105; #指定tftp server的ip
filename "pxelinux.0"; #通过tftp找到pxelinux.0文件,并下载
}

启动并设置成开机启动:

#service dhcpd start

#chkconfig dhcpd on

4.apache的安装与配置

#yum install httpd

启动并设置开机启动:

#service httpd start

#chkconfig httpd on

做安装文件的软连接:

#ln –s /home/var/isofile /var/www/html/rhel6

保证通过浏览器访问:http://192.168.0.105/rhel6 可以看到安装文件(注意:iptables 和 selinux)

5.tftp的安装与配置以及syslinux的安装

#yum install tftp*

#vim /etc/xinetd.d/tftp

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot #tftp服务目录
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

启动tftp服务并设置开机启动:

#service xinetd start

#chkconfig xinetd on

 

安装syslinux,主要用其提供的pxelinux.0文件

#yum install syslinux

copy内核文件到/var/lib/tftpboot目录下:

# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#cp /home/var/isofile/isolinux/initrd.img /var/lib/tftpboot

#cp /home/var/isofile/isolinux/vmlinuz /var/lib/tftpboot

#cp /home/var/isofile/isolinux/vesamenu.c32 /var/lib/tftpboot

创建目录:

#mkdir /var/lib/tftpboot/pxelinux.cfg

#cp /home/var/isofile/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

修改default文件:

#vim /var/lib/tftpboot/pxelinux.cfg/default

default vesamenu.c32
#prompt 1
timeout 1 #这个时间改为1,一秒后自动帮您选择install

display boot.msg

menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.0!
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=http://192.168.0.105/rhel6/ks.cfg #指明ks.cfg文件的位置

6.kickstart的安装与配置

#yum install system-config-kickstart

启动kickstark并生成ks.cfg文件到/root目录下:

#system-config-kickstart &

#mv /root/ks.cfg /var/www/html/rhel6

这一步可能遇到的问题:

a.yum 安装kickstart任然缺少依赖包

解决方法:

把yum源换成Centos6.2的源,众所周知rhel和centos是兼容的;把pxeserver.repo文件内容换为:

#vim /etc/yum.repos.d/pxeserver.repo

[base]
name=CentOS-6.2 - Base
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.2 - Updates
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

#packages used/produced in the build but not released
[addons]
name=CentOS-6.2 - Addons
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-6.2 - Extras
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6.2 ¨C Plus
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-6.2 - Contrib
baseurl=http://mirrors.163.com/centos/6.2/os/$basearch/
http://mirrors.163.com/centos/6.2/os/$basearch/
gpgcheck=0
gpgkey=http://mirrors.163.com/centos/6.2/os/i386/RPM-GPG-KEY-CentOS-6

这样就解决了

b.kickstart启动不了

因为kickstart启动要弹出一个图形化界面,如果你没有安装x windwow或者不支持桌面,那么kickstart就启动不了。

解决方法:安装桌面环境

#yum groupinstall “X Window System”

#yum groupinstall “Desktop”

再次#system-config-kickstart & 启动就ok了

三、测试篇

1.设置客户端网络启动,效果如下

  

easy吧,只要原理理解不管是http、nfs、ftp、cd-rom还是Hard Drive只要明白其原理,所有的操作系统实现自动安装就easy了。

你可能感兴趣的:(安装,系统,border,target,blank)