笔者是在虚拟机上操作的,首先需要做一个准备工作,就是预装一台linux的服务器。并且配置成nat上网的方式,vmware如何配置nat上网,请参考http://www.lishiming.net/thread-626-1-1.html。
此时,我的linuxIP为192.168.205.3,网关和dns地址都为192.168.205.2.
我们的目标是:
tftpd服务器: 192.168.205.3
dhcp服务器: 192.168.205.3
nfs服务器: 192.168.205.3
如果是虚拟机,请把你的CentOS光盘插到光驱中(或者设置一下虚拟光驱),这一步必须要做。
1. 搭建tftp服务器
yum install -y tftp tftp-server xinetd
vim /etc/xinetd.d/tftp // 内容如下:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no // 只需要更改蓝色字体的这一部分
per_source = 11
cps = 100 2
flags = IPv4
}
修改完后要启动tftpd服务
service xinetd start
2. 配置dhcpd服务
yum install -y dhcp
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
vim /etc/dhcpd.conf // 请复制以下内容:
ddns-update-style interim;
ignore client-updates;
subnet 192.168.205.0 netmask 255.255.255.0 {
allow booting;
allow bootp;
allow unknown-clients;
option routers 192.168.205.2;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.205.2;
option time-offset -18000; # Eastern Standard Time
# --- 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.205.100 192.168.205.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.205.3;
filename "pxelinux.0";
}
// 说明一下,我的服务器IP为 192.168.205.3, 网关和dns都是192.168.205.2 , 所以该配置文件中的相关配置请注意一下
启动dhcp服务 service dhcpd start
3. 配置支持pxe
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
mkdir /install
mount /dev/cdrom /install
cd /install/images/pxeboot/
cp initrd.img vmlinuz /tftpboot
mkdir /tftpboot/pxelinux.cfg
vim /tftpboot/pxelinux.cfg/default // 内容为:
default linux
prompt 1
timeout 30
label linux
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.168.205.3:/install2/ks.cfg
4. 配置 ks.cfg
mkdir /install2
vim /install2/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 --enabled
# 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 NFS installation media
nfs --server=192.168.205.3 --dir=/install
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
#Root password
rootpw --iscrypted $1$BYSimLw0$I515yLiKzudlwkIskBqQE1
# SELinux configuration
selinux --disabled
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
#xconfig --defaultdesktop=GNOME --depth=32 --resolution=800x600
reboot
text
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=256
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages --ignoremissing
@editors
@graphics
@x-software-development
@development-libs
@development-tools
kernel-devel
e2fsprogs
kernel
5. 配置NFS
vim /etc/exports
/install * (ro,no_root_squash,sync)
/install2 *(ro,no_root_squash,sync)
启动NFS服务:
service portmap restart //如果centos6,命令是 service rpcbind restart
service nfs restart
6. 创建一个新的虚拟机,设置网络为nat模式,默认就是使用dhcp方式安装系统的。
//最后再,强调一下,这个只是我在虚拟机上试验用的,如果你用做生成环境可能不太合适,相关的设置请自行修改。
此时,我的linuxIP为192.168.205.3,网关和dns地址都为192.168.205.2.
我们的目标是:
tftpd服务器: 192.168.205.3
dhcp服务器: 192.168.205.3
nfs服务器: 192.168.205.3
如果是虚拟机,请把你的CentOS光盘插到光驱中(或者设置一下虚拟光驱),这一步必须要做。
1. 搭建tftp服务器
yum install -y tftp tftp-server xinetd
vim /etc/xinetd.d/tftp // 内容如下:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no // 只需要更改蓝色字体的这一部分
per_source = 11
cps = 100 2
flags = IPv4
}
修改完后要启动tftpd服务
service xinetd start
2. 配置dhcpd服务
yum install -y dhcp
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
vim /etc/dhcpd.conf // 请复制以下内容:
ddns-update-style interim;
ignore client-updates;
subnet 192.168.205.0 netmask 255.255.255.0 {
allow booting;
allow bootp;
allow unknown-clients;
option routers 192.168.205.2;
option subnet-mask 255.255.255.0;
option domain-name-servers 192.168.205.2;
option time-offset -18000; # Eastern Standard Time
# --- 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.205.100 192.168.205.254;
default-lease-time 21600;
max-lease-time 43200;
next-server 192.168.205.3;
filename "pxelinux.0";
}
// 说明一下,我的服务器IP为 192.168.205.3, 网关和dns都是192.168.205.2 , 所以该配置文件中的相关配置请注意一下
启动dhcp服务 service dhcpd start
3. 配置支持pxe
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
mkdir /install
mount /dev/cdrom /install
cd /install/images/pxeboot/
cp initrd.img vmlinuz /tftpboot
mkdir /tftpboot/pxelinux.cfg
vim /tftpboot/pxelinux.cfg/default // 内容为:
default linux
prompt 1
timeout 30
label linux
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.168.205.3:/install2/ks.cfg
4. 配置 ks.cfg
mkdir /install2
vim /install2/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 --enabled
# 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 NFS installation media
nfs --server=192.168.205.3 --dir=/install
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
#Root password
rootpw --iscrypted $1$BYSimLw0$I515yLiKzudlwkIskBqQE1
# SELinux configuration
selinux --disabled
# System timezone
timezone Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
#xconfig --defaultdesktop=GNOME --depth=32 --resolution=800x600
reboot
text
# Disk partitioning information
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=100
part swap --bytes-per-inode=4096 --fstype="swap" --size=256
part / --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages --ignoremissing
@editors
@graphics
@x-software-development
@development-libs
@development-tools
kernel-devel
e2fsprogs
kernel
5. 配置NFS
vim /etc/exports
/install * (ro,no_root_squash,sync)
/install2 *(ro,no_root_squash,sync)
启动NFS服务:
service portmap restart //如果centos6,命令是 service rpcbind restart
service nfs restart
6. 创建一个新的虚拟机,设置网络为nat模式,默认就是使用dhcp方式安装系统的。
//最后再,强调一下,这个只是我在虚拟机上试验用的,如果你用做生成环境可能不太合适,相关的设置请自行修改。
编辑回复