xiaozi今天向大家介绍一下linux下的PXE网络安装


PXE网络安装可以使用http、ftp或nfs等方式安装,今天,xiaozi仅在此介绍http的方式:

首先安装服务:

yum install -y httpd tftp* dhcp* bind* caching* system-config-kickstart

xiaozi在此对以上服务的配置就不罗嗦了,我们要访问的网站是 www.xiaozi.com,那么,首先要将named搭建好,并且能够解析正确,

然后使用命令将tftp打开:

chkconfig tftp on

tftp服务是托在xinetd服务之下的,配置文件为:/etc/xinetd.d/tftp

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

切换目录到 /tftpboot 下,将目录清空,复制光盘的linux内核文件和启动脚本:

cp /media/p_w_picpaths/pxeboot/{initrd.img,vmlinuz} /tftpboot/
cp /media/isolinux/isolinux.cfg /tftpboot/
cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

在 /tftpboot 下新建目录:pxelinux.cfg,将 isolinux.cfg 复制到此目录下,改名为default

cd /tftpboot
mkdir pxelinux.cfg
cp /media/isolinux/isolinux.cfg default
chmod 777 default
#pxelinux.0为启动脚本,它在执行时,所加载的配置文件存放在/tftpboot/pxelinux.cfg 目录下,如果分配到的ip地址转化为十六进制为:ABCD , 则其加载配置文件的顺序为:ABCD<ABC<AB<A<default,所以当没有其他文件时,它会加载default,为了配置default,需要给其可写权限

配置default:

default linux                    #默认加载的label为linux
prompt 1
timeout 1                        #安装时等待的时长,可以将其设为1,但不可将其设为0,否则会一直等下去
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
label linux
  kernel vmlinuz
  append initrd=initrd.img ks=http://www.xiaozi.com/ks.cfg          #ks文件的位置
label text
  kernel vmlinuz
  append initrd=initrd.img text
label ks
  kernel vmlinuz
  append ks initrd=initrd.img
label local
  localboot 1
label memtest86
  kernel memtest
  append -

接下来配置dhcpd:

ddns-update-style interim;
ignore client-updates;
filename        "pxelinux.0";                #执行的脚本文件名
next-server        192.168.0.1;            #服务器的ip地址
subnet 192.168.0.0 netmask 255.255.255.0 {
# --- default gateway
        option routers                  192.168.0.1;
        option subnet-mask              255.255.255.0;
        option nis-domain               "domain.org";
        option domain-name              "xiaozi.com";
        option domain-name-servers      192.168.0.1;
        option time-offset              -18000;
        range dynamic-bootp 192.168.0.128 192.168.0.254;
        default-lease-time 21600;
        max-lease-time 43200;
}

使用yum安装httpd,其默认的目录为/var/www/html

在/var/www/html目录下新建目录,用来挂在镜像:

cd /var/www/html
mkdir -m 777 cdrom
mount /dev/cdrom /var/www/html/cdrom

配置yum:

cd /etc/yum.repos.d/
touch xiaozi.repo

配置xiaozi.repo:

[base]                    #这里一定要使用base作为名字,否则会出错
baseurl = file:///var/www/html/cdrom/Server
gpgcheck = 0

现在就可以使用 system-config-kickstart 生成ks文件了,一下是xiaozi的配置实例,可供大家参考一下,使用命令 system-config-kickstart 打开kickstart:

RHEL 5 无人值守安装_RHEL 5

RHEL 5 无人值守安装_RHEL 5_02

RHEL 5 无人值守安装_无人值守安装_03

RHEL 5 无人值守安装_pxe_04

RHEL 5 无人值守安装_无人值守安装_05

RHEL 5 无人值守安装_RHEL 5_06

RHEL 5 无人值守安装_pxe_07

RHEL 5 无人值守安装_pxe_08

RHEL 5 无人值守安装_无人值守安装_09

RHEL 5 无人值守安装_pxe_10

大家注意,在配置时,一定要将它的 selinux 和 iptables 关掉,然后将其保存(点击左上角的File,下拉菜单中有save,点击即可),

保存为ks.cfg ,将其移动到 /var/www/html ,给它777的权限:

mv ks.cfg /var/www/html/
chmod 777 /var/www/html/ks.cfg

我们知道,在安装RHEL-5时,会让我们输入序列号,所以,我们在生成ks文件时,第一步的图中,可以发现,要求输入学列号的选项就在输入密码的选项之后,我们可以修改ks.cfg,在密码后输入一行配置:key --skip

#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
key    --skip                        #跳过序列号
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=http://www.xiaozi.com/cdrom
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$W1ZdCznv$2H8Ty7WW05GBqb/x9mBRX1
# SELinux configuration
selinux --disabled
# System timezone
timezone  America/New_York
# Install OS instead of upgrade
install

最后,为了确保配置生效,可以将我们所涉及到的服务重新加载一次,可以使用service xinetd restart 来重新启动tftp服务

还有就是注意 selinux 和 iptables 的配置

准备一台裸机来实验一下吧!


RHEL 5 无人值守安装_pxe_11 、、、xiaozi的无人值守安装介绍到此,大家有什么意见尽管提噢,谢谢!