Chinaunix首页 | 论坛 | 博客
  • 博客访问: 308189
  • 博文数量: 120
  • 博客积分: 3000
  • 博客等级: 中校
  • 技术积分: 1290
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-19 01:46
文章分类

全部博文(120)

文章存档

2010年(84)

2009年(36)

我的朋友

分类: LINUX

2009-12-19 02:00:25

IBM中文技术文档:

http://www.ibm.com/developerworks/cn/aix/library/0912_wangxp_unixinstall/index.html


下面这个地址写得比我好得多,大家可以参考一下:
http://baidu.blog.51cto.com/71938/158675

-、配置DHCP

[root@host66 ~]# yum -y install dhcp

[root@host66 ~]# cat /etc/dhcpd.conf

# DHCP Server Configuration file.

# see /usr/share/doc/dhcp*/dhcpd.conf.sample

ddns-update-style interim;

ignore client-updates;

filename "pxelinux.0";

next-server 192.168.5.66;

#此处两项必须,其它根据情况而定

subnet 192.168.5.0 netmask 255.255.255.0 {

# --- default gateway

option routers 192.168.5.1;

option subnet-mask 255.255.255.0;

# option nis-domain "domain.org";

# option domain-name "domain.org";

option domain-name-servers 192.168.10.181;

option time-offset -18000; # Eastern Standard Time

# option ntp-servers 192.168.1.1;

# option netbios-name-servers 192.168.1.1;

# --- Selects point-to-point node (default is hybrid). Don't change this unless

# -- you understand Netbios very well

# option netbios-node-type 2;

range dynamic-bootp 192.168.5.67 192.168.5.69;

default-lease-time 21600;

max-lease-time 43200;

# we want the nameserver to appear at a fixed address

# host ns {

# next-server marvin.redhat.com;

# hardware ethernet 12:34:56:78:AB:CD;

# fixed-address 207.175.42.254;

# }

}

#

二、配置TFTP

[root@host66 ~]# yum -y install tftp tftp-server

[root@host66 ~]# cat /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

{

disable = no

#此处设置为NO

socket_type = dgram

protocol = udp

wait = yes

user = root

server = /usr/sbin/in.tftpd

server_args = -s /tftpboot

per_source = 11

cps = 100 2

flags = Ipv4

}

三、挂载ISO,配置NFS 以及TFTP目录

[root@host66 ~]# mkdir /mnt/os

[root@host66 ~]# mount -o loop /sun/CentOS/CentOS-5.2-i386-bin-DVD.iso /mnt/os

[root@host66 ~]# echo "mount -o loop /sun/CentOS/CentOS-5.2-i386-bin-DVD.iso /mnt/os" >>/etc/rc.local

[root@host66 ~]# cat /etc/exports  (这个是NFS的配置文件)

/mnt/ *(ro,sync)

[root@host66 ~]# cp /usr/lib/syslinux/pxelinux.0 /tftpboot/ (必须先安装syslinux-3.11-4.rpm包才能得到此文件 )

[root@host66 ~]# cp -a /mnt/OS/images/* /tftpboot/

[root@host66 ~]# mkdir /tftpboot/pxelinux.cfg

[root@host66 ~]# cp /tftpboot/isolinux.cfg /tftpboot/pxelinux.cfg/default

文件和目录结构如下:

[root@host66 ~]# tree /tftpboot
/tftpboot
|-- TRANS.TBL
|-- boot.cat
|-- boot.msg
|-- general.msg
|-- initrd.img
|-- isolinux.bin
|-- isolinux.cfg
|-- memtest
|-- options.msg
|-- param.msg
|-- pxelinux.0
|-- pxelinux.cfg
|   `-- default
|-- rescue.msg
|-- splash.lss
`-- vmlinuz

1 directory, 15 files

四、编写KS脚本

[root@host66 ~]# yum install system-config-kickstart

[root@host66 ~]# system-config-kickstart

#运行此命令可用图形化工具编写KS脚本

[root@host66 ~]# mkdir /mnt/ks/

[root@host66 ~]# cp /root/ks.cfg /mnt/ks/

五、启动服务

[root@host66 ~]# service dhcp restart

[root@host66 ~]# service portmap restart NFS依赖PORTMAP(要先启动portmap后,nfs才能正确启动)

[root@host66 ~]# service nfs restart

[root@host66 ~]# service xinetd restart

XINETD管理TFTP

[root@host66 ~]# chkconfig dhcpd on

[root@host66 ~]# chkconfig nfs on

[root@host66 ~]# chkconfig portmap on

[root@host66 ~]# chkconfig xinetd on

至此服务器端的设置完成

================================

客户端:

1、设置BIOS选择PXE引导

2、当进入LINUX安装向导时,输入如下命令即可

boot: linux ks=nfs:192.168.5.66:/mnt/ks/ks.cfg

还可编辑/tftpboot/pxelinux.cfg/default 加上ks路径,实现无干预安装(如下例:)

也可编辑/tftpboot/boot.msg给予提示

[root@host66 ~]# cat /tftpboot/pxelinux.cfg/default

default linux

prompt 1

timeout 600

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

label text

kernel vmlinuz

append initrd=initrd.img text


label vnc
  kernel vmlinuz
  append initrd=initrd.img vnc vncpassword=123456 ip=192.168.5.70 netmask=255.255.255.0 ks=nfs:192.168.5.66:/mnt/ks/ks-vnc.cfg

label ship
  kernel vmlinuz
  append ks=nfs:192.168.5.66:/mnt/ks/ks-vnc.cfg initrd=initrd.img

label kickstart

kernel vmlinuz

append ks=nfs:192.168.5.66:/mnt/ks/ks.cfg initrd=initrd.img

ks=

ks=

(只有NFS才支持图形化界面安装,而且只有在图形化界面安装时才能在安装过程中安装RAID和LVM. ftp和http则不支持)

label local

localboot 1

label memtest86

kernel memtest

append -

另注:

如输入如下命令,则在本地通过VNC连接进行远程安装

boot: linux vnc vncpassword=123456 ip=192.168.5.67 netmask=255.255.255.0

引导后会给出提示要求连接:1号桌面

本地输入如下:

[root@host66 ~]# vncviewer 192.168.5.67:1

输入密码后则可连接远端主机




如果是相通过LINUX服务器安装WINDOWS,则可GOOGLE一下"rislinux-autoinst",这个没有试验过,不过听说可以实现!




下面是一个DHCP的配置实例

ddns-update-style interim;
ignore client-updates;
allow booting;    #定义可以PXE 8)  8) 启动
allow bootp;      #定义支持boottp

subnet 192.168.168.0 netmask 255.255.255.0 {
option routers                  192.168.168.230;  #定义默认网关
option subnet-mask              255.255.255.0;     
option domain-name-servers      192.168.168.6;    #定义nameServer
option time-offset              -18000; # Eastern Standard Time
range dynamic-bootp 192.168.168.12 192.168.168.254;
default-lease-time 21600;
max-lease-time 43200;
# Group the PXE bootable hosts together  定义可以PEX启动的主机的组
        group {
                # PXE-specific configuration directives...
                next-server 192.168.168.6;    #TFTPServer的IP
                filename "/pxelinux.0";#pxelinux loader文件位置
                # You need an entry like this for every host
                # unless you're using dynamic addresses #可PEX启动的主
#机的IP与MAC地址的邦定
                host wy {
                        hardware ethernet 00:00:E2:89:9B:DB;
                        fixed-address 192.168.168.128;
                }
        }
}




下面是一些本机上的实例文件::



[root@host66 ~]# cat /etc/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample 
ddns-update-style interim;
ignore client-updates;
filename "pxelinux.0";
next-server 192.168.5.66;
subnet 192.168.5.0 netmask 255.255.255.0 {

# --- default gateway
        option routers                  192.168.5.1;
        option subnet-mask              255.255.255.0;

#       option nis-domain               "domain.org";
#       option domain-name              "domain.org";
        option domain-name-servers      192.168.10.181;

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              192.168.1.1;
#       option netbios-name-servers     192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

        range dynamic-bootp 192.168.5.67 192.168.5.79;
        default-lease-time 21600;
        max-lease-time 43200;

        # we want the nameserver to appear at a fixed address
#       host ns {
#               next-server marvin.redhat.com;
#               hardware ethernet 12:34:56:78:AB:CD;
#               fixed-address 207.175.42.254;
#       }
}
#
-----------------------------------------------------------------------------
[root@host66 ~]# cat /etc/exports
/mnt/   *(ro,sync)

-----------------------------------------------------------------------------
[root@host66 ~]# cat /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
{
        disable = no
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /tftpboot
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
_________________________________________________________________________________

[root@host66 tftpboot]# cat /tftpboot/boot.msg

 
splash.lss

 -  To install or upgrade in graphical mode, press the 0b07 key.

 -  To install or upgrade in text mode, type: 0blinux text 07.

 -  To ship IP and mount option mode, type: 0bship 07.

 -  To install or upgrade in kickstart mode, type: 0bkickstart 07.

 -  To install or upgrade in vnc mode, type: 0b vnc 07.
              0b vncviewer 192.168.5.70:1   passwd=12345607

 -  Use the function keys listed below for more information.

0f[F1-Main] [F2-Options] [F3-General] [F4-Kernel] [F5-Rescue]07
____________________________________________________________________________
[root@host66 tftpboot]# cat /tftpboot/pxelinux.cfg/default
default linux
prompt 1
timeout 600
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
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 -

label vnc
  kernel vmlinuz
  append initrd=initrd.img vnc vncpassword=123456 ip=192.168.5.70 netmask=255.255.255.0 ks=nfs:192.168.5.66:/mnt/ks/ks-vnc.cfg

label kickstart
  kernel vmlinuz
  append ks=nfs:192.168.5.66:/mnt/ks/ks.cfg initrd=initrd.img
label ship
  kernel vmlinuz
  append ks=nfs:192.168.5.66:/mnt/ks/ks-vnc.cfg initrd=initrd.img
______________________--_____________________________________________
[root@host66 ~]# cat /mnt/ks/ks.cfg
#platform=x86, AMD64, or Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
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 zh_CN
#lang en_US
# Installation logging level
logging --level=info
# Use NFS installation media
nfs --server=192.168.5.66 --dir=/mnt/os/
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
# Reboot after installation
reboot
#Root password
rootpw --iscrypted $1$3diADdmY$/yxuonmoRzjVwFogrHNgF0

# SELinux configuration
selinux --disabled
# System timezone
timezone --isUtc Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig  --defaultdesktop=GNOME --depth=8 --resolution=640x480 --startxonboot
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=2000
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1


%packages
@server-cfg
@base-x
@gnome-desktop
@development-libs
@base
@office
@sound-and-video
@kde-desktop
@chinese-support
@java-development
@mail-server
@graphical-internet
@system-tools
@editors
@text-internet
@graphics
@java
@games
@engineering-and-scientific
______________________________________________________________________
[root@host66 ~]# cat /mnt/ks/ks-vnc.cfg
keyboard us
lang en_US
nfs --server=192.168.5.66 --dir=/mnt/os/







=================================================================================
ks=nfs::/

安​装​程​序​在 NFS 服​务​器 上​的 里​寻​找 kickstart 文​件​。​安​装​程​序​使​用 DHCP 来​配​置​以​太​网​卡​。​例​如​,如​果​你​的 NFS 服​务​器​是 server.example.com 且 kickstart 文​件​是 NFS 共​享​目​录​的​里 /mydir/ks.cfg,正​确​的​引​导​命​令​应​该​是 ks=nfs:server.example.com:/mydir/ks.cfg

ks=http:///

安​装​程​序​在 HTTP 服​务​器 上​的 里​寻​找 kickstart 文​件​。​安​装​程​序​使​用 DHCP 来​配​置​以​太​网​卡​。​例​如​,如​果​你​的 HTTP 服​务​器​是 server.example.com 且 kickstart 文​件​是 HTTP 目​录​的​里 /mydir/ks.cfg,正​确​的​引​导​命​令​应​该​是 ks=

ks=floppy

安​装​程​序​在 /dev/fd0 里​的​软​盘​上​的 vfat 或 ext2 文​件​系​统​里​寻​找 ks.cfg 文​件​。

ks=floppy:/

安​装​程​序​在 /dev/fd0 里​的​软​盘​上​以 寻​找 kickstart 文​件​。

ks=hd::/

安​装​程​序​把​文​件​系​统​挂​载​在 (必​须​是 vfat 或 ext2),而​且​在​该​文​件​系​统​里​以 来​寻​找 kickstart 文​件​(例​如​,ks=hd:sda3:/mydir/ks.cfg)。

ks=file:/

安​装​程​序​试​图​从​文​件​系​统​里​读​取 ;并​没​有​挂​载​任​何​文​件​。​如​果 kickstart 文​件​已​经​在 initrd 映​像​里​时​我​们​通​常​使​用​这​个​方​法​。

ks=cdrom:/

安​装​程​序​以 在​光​盘​上​寻​找 kickstart 文​件​。




=========================================================================
下面是一个用XP亻服务器网络安装RHEL5的例子,(此例来自网络)
_=============================================================================

实验环境:

服务器:Windows XP +hane dhcp server3.0.12 + Serv-U FTP server

1、从官方网站下载“hanewin dhcp server”软件。

2、安装hane dhcp server软件,并注册。(在Windows XP下安装过程比较简单,此处就不细讲)。

3、配置Hane DHCP Server:

(1)双击桌面上“DHCP Server”图标,运行Hane DHCP Server。单击“文件”菜单下的“服务”中的“启动”菜单项。

(2)选择菜单“选项”中的“选项”菜单项,单击,选择DHCP选项卡。从中只选择以下三项:

 
(3)选择“TFTP”选项卡,指定TFTP根目录(此处把引导文件pxelinux.0放在了F:\Linux目录下),并将“运行模式”下的几个复选框清空。单击“确定”关闭此对话框。

(4)选择“选项”菜单下的“If-192.168.0.5”(因为本机IP地址是192.168.0.5),从中指定DHCP地址范围(此处设为192.168.0.200—192.168.0.254。

(5)从本对话框中选择“引导”选项卡,从中指定引导文件“pxelinux.0”(这个文件是从一个已经安装好的RHEL5机器上的/usr/lib/syslinux/目录下拷贝来的)

(6)单击“确定”关闭此对话框。配置完成。

4、准备引导文件:

(1)pxelinux.0:从一台已经安装好的Linux机器上拷贝过来,或者从网上找到syslinux安装包,从中释放出这个文件来。拷贝到TFTP指定的根目录下(此处为F:\linux\)

(2)default:因为pxelinux 要使用目录pxelinux.cfg中的文件default),即pxelinux.cfg/default,下面建立default文件

Default文件的内容是:

label linux

kernel vmlinuz

append initrd=initrd.img devfs=nomount ramdisk_size=9216

(3)将RHEL5光盘中的images目录下的pxeboot目录下的vmlinuz和initrd.img文件拷贝到TFTP指定的根目录(此处是F:\linux)下。

5、建立提供RHEL5安装文件的FTP服务器:

(1)从网上下载Serv-U FTP Server软件,安装注册并运行。

(2)配置用户(此处为linux)指定其根目录为RHEL5安装光盘释放的目录(此处为F:\rhel5)。

6、客户端安装:

(1)客户机的网卡带有PXE芯片,只是默认没有开启,可以从BIOS中的“Advanced”中的“onboard chip ”中开启。

(2)重启进入BIOS设置BOOT顺利,从网卡启动。

(3)退出BIOS,启动计算机。将自动获得IP地址和引导文件,引导计算机。

(4)选择FTP方式安装:

(5)输入FTP服务器的地址(此处为192.168.0.5,这就用到了Serv-U FTP Server服务器),指定服务器软件所在目录为“/”,选择复选框“Use non-anonymous ftp”选项。

(6)输入在Serv-U FTP Server中建立的用户Linux和其密码。

(7)下面就进入了正常安装linux的状态。按照以前用光盘安装的步骤一步步安装即可。




参考文献:
1. 红帽官方文档之KICKSTART无人职守安装:

/ch-kickstart2.html
2. 基于网络的 Red Hat 无人值守安装:
http://www.ibm.com/developerworks/cn/linux/l-autoinstl/index.html
3. 关于LINUX-PXE主要参考资料:
http://www.ibm.com/developerworks/cn/linux/l-tip-prompt/l-pex
4. PXELINUX相关内容:

5. Net Booting With DHCP,PXE-LINUX and TFTP Server:

阅读(1264) | 评论(1) | 转发(0) |
0

上一篇:没有了

下一篇:CentOS5构建本地yum仓库(同步网站)

给主人留下些什么吧!~~

chinaunix网友2010-01-22 19:56:17

呵呵,照着这个总算是搞定了,谢谢~!