CentOS 5 无值守安装(Linux)
CentOS 5 无值守安装(Linux)文章内容:DHCP/ TFTP/ NFS/ KickStart/ PXE实现无值守自动安装服务器
一、环境描述:
1、提供自动安装服务的主机:VMWare 虚拟机 CPU 1个,内存 1GB
2、服务器操作系统:CentOS 5.3i686 完全安装
3、要安装的操作系统为:CentOS 5.3i686
4、局域网IP地址情况:
子网范围: 192.168.1.0/24
服务器IP: 192.168.1.5/24
自动分配的IP范围: 192.168.1.32 至 192.168.1.63 共32个
网关地址: 192.168.1.1
DNS服务器地址: 202.106.0.20
5、要自动安装系统的主机:VMWare 虚拟机 CPU 1个,内存 1GB
二、说明
1、DHCP服务:DHCP服务的作用,是为那些需要PXE网络启动的计算机分配IP地址。
2、tftp服务:tftp服务的作用,是为那些需要PXE网络启动的计算机提供引导文件。
3、NFS服务: NFS服务的作用,是为远程安装提供相应的安装文件。可以用HTTP或FTP等服务替代。
4、KickStart: KickStart 用来定义安装过程,从而使安装过程能自动完成,而不必手工的选择安装中的选项。
三、服务器端的设置过程:
1、开启DHCP服务
# cp /usr/share/doc/dhcp-3.0.1/dhcpd.conf.sample/etc/dhcpd.conf
通常,CentOS 5 安装好以后,其 dhcp 服务的配置文件是没有内容的,一般是两行提示,该提示的意思就是执行上面的命令,从而可以拷贝一个事先定义好的配置文件,再加以修改就可以用了。
要注意的是随着使用的系统版本不同,dhcp的版本号会有一定的差异,我这里是 3.0.1 ,在拷贝前自行查看,不要原样照抄上面的命令。
# vi /etc/dhcpd.conf
编辑 dhcp 服务的配置文件 ,内容如下:
ddns-update-style interim;
ignore client-updates;
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
option nis-domain "domain.org";
option domain-name "domain.org";
option domain-name-servers 202.98.0.68;
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;
allow bootp;
allow booting;
next-server 192.168.1.5;
filename "pxelinux.0";
range dynamic-bootp 192.168.1.32192.168.1.63;
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;
}
}
注:红色部分是我修改过的行,蓝色部分是我添加的行。
# service dhcpd restart
重启 dhcpd 服务程序
# chkconfig dhcpd on
设置 dhcpd 服务程序开机启动
# ps aux |grep dhcpd 或 netstat –an |grep 67
检查有无UDP的67在监听,以测试dhcpd是否启动
2、配置启动 TFTP 服务
# vi /etc/xinetd.d/tftp
修改其中的disable = yes 为 disable = no
# service xinetd restart
重启 xinetd 服务,以启动 tftp 服务程序
# netstat –an |grep 69
检查有无UDP的69在监听,以测试tftp是否启动
3、配置启动 NFS 服务
本例中,我将 CentOS 5.3 安装DVD光盘下的所有文件都复制到了/server/CentOS 下,并设/server/CentOS 的属主为root
# vi/etc/exports
加入下面一行内容
/server/CentOS192.168.1.0/255.255.255.0(ro,no_root_squash)
# service nfs restart
重新启动 NFS 服务
# chkconfig nfs on
设置 NFS 开机自动启动
# exportfs
检查是否NFS正确输出了/server/CentOS
# ps aux |grep nfsd
检查nfs是否启动成功
4、**相关的启动文件
# cp/server/CentOS/isolinux/vmlinuz/tftpboot
# cp/server/CentOS/isolinux/initrd.img/tftpboot
# mkdir /tftpboot/pxelinux.cfg
# cp/server/CentOS/isolinux/isolinux.cfg/tftpboot/pxelinux.cfg/default
# vi/tftpboot/pxelinux.cfg/default
编辑默认启动配置文件,内容如下
default linux
prompt 1
timeout 10
display boot.msg
F1 boot.msg
F2 options.msg
F3 general.msg
F4 param.msg
F5 rescue.msg
F7 snake.msg
label linux
kernel vmlinuz
append initrd=initrd.img ramdisk_size=8192 ks=nfs:192.168.1.5:/server/CentOS/ks.cfg
label text
kernel vmlinuz
append initrd=initrd.img text ramdisk_size=8192
label expert
kernel vmlinuz
append expert initrd=initrd.img ramdisk_size=8192
label ks
kernel vmlinuz
append ks initrd=initrd.img ramdisk_size=8192
label lowres
kernel vmlinuz
append initrd=initrd.img lowres ramdisk_size=8192
label local
localboot 1
label memtest86
kernel memtest
append –
注:红色是我改动过的部分,目的是实现自动启动安装程序。
# cp /tftpboot/linux-install/pxelinux.0/tftpboot/
5、kickstart的设置:
a)在基本配置中,要注意选中那个根口令,并设置根口令,另外我选择了下面的用文本方式安装
b)安装方法中,我选择了NFS,服务器是192.168.1.5,安装目录是/server/CentOS
c)分区信息,我加了三个分区,/ /boot和 swap
d)网络配置,我加了一个eth0 并设为dhcp
e)防火墙我选了禁用
f)包选择处,我选了全部包
g)保存为 /server/CentOS/ks.cfg
四、要自动安装系统的计算机:
设置主机启动顺序为先硬盘后网卡PXE模式,开机后,正常开始安装。
页:
[1]