一、原理 KCMLinux联盟
无光驱、软驱的一台服务器,想要安装Linux系统。我们需要通过网卡的PXE协议,引导之后安装Linux。流程:机器启动-网卡引导-通过DHCP获得IP地址-通过tftp获得最基础的内核文件,使用该内核文件启动机器-启动之后可以对安装程序配置,选择使用http、ftp、nfs方式远程获得安装所需要的软件包。 KCMLinux联盟
显然,网络安装是必须配置服务器端的。我们的服务端需要提供以下服务: KCMLinux联盟
DHCP KCMLinux联盟
TFTP KCMLinux联盟
HTTP(FTP,NFS) KCMLinux联盟
二、服务配置 KCMLinux联盟
1.DHCP KCMLinux联盟
配置文件: KCMLinux联盟
option domain-name "mydomain"; KCMLinux联盟
ddns-update-style none; KCMLinux联盟
default-lease-time 600; KCMLinux联盟
max-lease-time 7200; KCMLinux联盟
server-name "bootserver"; KCMLinux联盟
subnet 192.168.123.0 netmask 255.255.255.0 { KCMLinux联盟
range 192.168.123.200 192.168.123.201; KCMLinux联盟
deny unknown-clients; KCMLinux联盟
} KCMLinux联盟
host MyP5 { KCMLinux联盟
filename "pxelinux.0"; KCMLinux联盟
server-name "bootserver"; KCMLinux联盟
hardware ethernet ae:32:20:00:b0:02; KCMLinux联盟
fixed-address 192.168.123.90; KCMLinux联盟
} KCMLinux联盟
这是复制来的配置文件,稍微解释一下: KCMLinux联盟
filename 后面是tftp目录下的文件,pxelinux.0 则是 syslinux 包内的文件。默认 pxelinux.0 可能在 /usr/lib/syslinux 目录下,必须将其复制到 tftp 目录下。 KCMLinux联盟
host MyP5 下出现的: KCMLinux联盟
hardware ethernet ae:32:20:00:b0:02; KCMLinux联盟
fixed-address 192.168.123.90; KCMLinux联盟
为客户机(需要安装系统的机器)的 MAC 地址和所分配的IP地址。 KCMLinux联盟
2.TFTP KCMLinux联盟
由于必须支持TSIZE协议,所以不能安装最原始的TFTP包。我选择使用 tftp-hpa 。 KCMLinux联盟
编辑文件 /etc/xinetd.d/tftp (若没有,则添加tftp文件)(若不存在xinetd.d,请安装 xinetd 包) KCMLinux联盟
# default: off KCMLinux联盟
# description: The tftp server serves files using the trivial file transfer \ KCMLinux联盟
# protocol. The tftp protocol is often used to boot diskless \ KCMLinux联盟
# workstations, download configuration files to network-aware printers, \ KCMLinux联盟
# and to start the installation process for some operating systems. KCMLinux联盟
service tftp KCMLinux联盟
{ KCMLinux联盟
disable = no KCMLinux联盟
socket_type = dgram KCMLinux联盟
protocol = udp KCMLinux联盟
wait = yes KCMLinux联盟
user = root KCMLinux联盟
server = /usr/sbin/in.tftpd KCMLinux联盟
server_args = -s /tftpboot KCMLinux联盟
per_source = 11 KCMLinux联盟
cps = 100 2 KCMLinux联盟
flags = IPv4 KCMLinux联盟
} KCMLinux联盟
这里将 /tftpboot 定义为 tftp 服务的默认目录,您可以自行修改。 KCMLinux联盟
保存之后重启 /etc/init.d/xinetd 服务,即可开启 tftp 服务。 KCMLinux联盟
如何测试 tftp 是否成功开启? KCMLinux联盟
在 tftp 目录下创建一个文件,比如 1.txt 。 KCMLinux联盟
在 Shell 中连接 tftp 服务: KCMLinux联盟
tftp 127.0.0.1 KCMLinux联盟
tftp>get 1.txt KCMLinux联盟
若服务成功开启,则能看到成功下载文件的提示。并在当前目录下找到1.txt文件。 KCMLinux联盟
接着复制光盘中 isolinux 目录下的 vmlinuz、initrd.img 文件到 /tftpboot 目录下。 KCMLinux联盟
在 /tftpboot 中创建文件夹 syslinux.cfg 。syslinux.cfg 中保存了 pxelinux 的两个配置文件:default、list。 KCMLinux联盟
default: KCMLinux联盟
default linux KCMLinux联盟
label linux KCMLinux联盟
kernel vmlinuz KCMLinux联盟
append initrd=initrd.img devfs=nomount nofb ramdisk_size=9216 KCMLinux联盟
你可以写很多个label,这取决于你同时想在这台服务器上提供多少种版本的 Linux 给客户机安装。一个版本一个label,当然kernel、与initrd文件名不可以重复。 KCMLinux联盟
list: KCMLinux联盟
Choose one of the following Linux distributions for your installation: KCMLinux联盟
Name Distribution Arch. Installation media KCMLinux联盟
----------------------- KCMLinux联盟
CentOS CentOS 4.4 i386 192.168.99.90:/ KCMLinux联盟
你也可以添加多行,用来选择不同的发行版本。在选择的时候填写Name下的内容即可。 KCMLinux联盟
三、复制光盘文件 KCMLinux联盟
将光盘文件复制到对应目录(ftp、http、nfs),如果是使用 http 使用以下命令将多张光盘复制到一个目录里面: KCMLinux联盟
[root@bootserver] # cp -arv /media/cdrom/* /install KCMLinux联盟
如果使用 ftp,请确保可以访问(可以有用户名、密码)。 KCMLinux联盟